Part2LearningBash - xorkevin/GitIntroduction GitHub Wiki
#part 2: learning bash
##What is Bash?
Unix was one of the first revolutionary operating systems. It has evolved into many other OSes including Mac OSX and Linux. At the center of the Unix user interface is the Bourne shell command line interface.
bash - Bourne-again shell - is the command line interface (cli) that you have been working in which is a redevelopment of the Bourne shell, hence Bourne again.
##Basic Bash Commands
there are several basic commands in bash, used to navigate directories
###ls
######list
lists the items in the current directory of which its path is shown above the $ prompt
example:
user@computername /C/path/to/directory
$ ls
main.java
README.md
source
###cd *directory_name*
######change directory
changes the directory to the specified name
- directory name may be absolute or relative
absolute example:
user@computername /C/path/to/directory
$ ls
main.java
README.md
source
user@computername /C/path/to/directory
$ cd /C/path/to/directory/source
user@computername /C/path/to/directory/source
$
relative example:
user@computername /C/path/to/directory
$ ls
main.java
README.md
source
user@computername /C/path/to/directory
$ cd source
user@computername /C/path/to/directory/source
$
there are also two special directories: "." and ".."
- "." is the current directory
- ".." is the parent directory
example "." :
user@computername /C/path/to/directory
$ cd .
user@computername /C/path/to/directory
$
example ".." :
user@computername /C/path/to/directory
$ cd ..
user@computername /C/path/to
$
PROTIP:
- Pressing
TAB
after typing part of a command or file name will auto-complete as much of the rest of the text as possible until bash cannot determine which filename you are referring to. - Pressing
TAB
after a partial completion of text will automatically invoke thels
command showing you what files/directories are in the directory path you have typed so far.
###less *file_name*
prints out the contents of a file and allows forward and backward navigation through the text.
- you can navigate the file using the
up
,down
,left
, andright
arrow keys j
navigates one line down,k
navigates one line upf
(forward) navigates one page down,b
(back) navigates one page upq
quits lessh
displays help
Fun fact: The program "less" evolved from "more" which is simpler and has less features. So sometimes less really is more.
###OPTIONAL: vi *file_name*
starts vim, a command line text editor.
- Vim tutorial, since there are a lot of shortcut keys to memorize