There are several "shells" that can be used in the command line for Linux and Unix systems.
The default shell for most Linux distributions such as Ubuntu and Fedora is called bash, which stands for "Bourne Again Shell", bash is an improved version of the Bourne Shell.
The first feature I would like to mention is tab
completion.
Typing the first few letters of an executable command, then hitting
tab
completes the command.After entering an executable command, hitting
tab
again shows a list of available arguments. Typing the first letter of the argument then hitting tab shows a list of arguments that start with that letter.tab
completion is especially useful to change directories, for example, to change directories to /home/david/Documents
we could simply type "cd /ho<tab
>/da<tab
/Do<tab
, saving us several keystrokes.In addition to tab completion, the !$ character combination can be used for substitution, for example, if we were examining a file with the cat
, more
or less, then we realized we need to edit it, we don't need to type in the file the second time around:
less foo.txt
vi !$
The second line is equivalent to vi foo.txt
, the !$ character combination is substituted for the last argument in the previous command.
The !! character combination executes the last command executed, preventing us from having to type it again.
We can view the history of the last several commands entered by using the history
command, the output would look something like this:
476 ls
477 ls -larth
478 su
479 history |grep sudo
480 ls
481 ls f*
482 ls -ld fo*
483 cd
484 history
Of course, typical output is much longer, in any case, if we want to re-execute any command in the history, we simply need to enter it's number in the history preceded by an exclamation point, for example, if we wanted to re-execute command number 482, all we would need to enter is:
!482
We can also navigate through the history by simply using the up and down arrows, the up arrow shows the previous command in the history, the down arrow shows the next command in the history.
Knowing these bash shell scripts help us be very proficient with the Unix command line, which I miss dearly when I am using a Windows box (by the way Cygwin provides a bash shell for Unix systems).