This is a draft cheat sheet. It is a work in progress and is not finished yet.
What is shell
When we speak of the command line, we are really referring to the shell. The shell is a program that takes keyboard commands and passes them to the operating system to carry out. Almost all Linux distributions supply a shell program from the GNU Project called bash. The name “bash” is an acronym for “Bourne Again Shell”, a reference to the fact bash is an enhanced replacement for sh, the original Unix shell program written by Steve Bourne. |
Terminal Emulator
When using a graphical user interface (GUI), we need another program called a terminal emulator to interact with the shell. If we look through our desktop menus, we will probably find one. KDE uses konsole and GNOME uses gnome-terminal, though it's likely called simply “terminal” on our menu. A number of other terminal emulators are available for Linux, but they all basically do the same thing; give us access to the shell. You will probably develop a preference for one or another terminal emulator based on the number of bells and whistles it has. |
|
|
Making Your First Keystrokes
[me@linuxbox ~]$ This is called a shell prompt and it will appear whenever the shell is ready to accept input. |
Note: If the last character of the prompt is a pound sign (“#”) rather than a dollar 2 sign, the terminal session has superuser privileges. This means either we are logged in as the root user or we selected a terminal emulator that provides superuser (administrative) privileges. |
[me@linuxbox ]$ kaekfjaeifj Because this command makes no sense, the shell tells us so and give us another chance. bash: kaekfjaeifj: command not found [me@linuxbox ]$ |
Command History If we press the up-arrow key, we will see that the previous command kaekfjaeifj reappears after the prompt. This is called command history. Most Linux distributions remember the last 1000 commands by default. Press the down-arrow key and the previous command disappears. Cursor Movement Recall the previous command by pressing the up-arrow key again. If we try the left and right-arrow keys, we'll see how we can position the cursor anywhere on the command line. This makes editing commands easy. |
date command [me@linuxbox ~]$ date Thu Mar 8 15:09:41 EST 2018 |
command is cal which, by default, displays a calendar of the current month. [me@linuxbox ~]$ cal March 2018 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
To see the current amount of free space on our disk drives, enter df. 4 Try Some Simple Commands [me@linuxbox ~]$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 15115452 5012392 9949716 34% / /dev/sda5 59631908 26545424 30008432 47% /home /dev/sda1 147764 17370 122765 13% /boot tmpfs 256856 0 256856 0% /dev/shm |
Likewise, to display the amount of free memory, enter the free command. [me@linuxbox ~]$ free total used free shared buffers cached Mem: 513712 503976 9736 0 5312 122916 -/+ buffers/cache: 375748 137964 Swap: 1052248 104712 947536 |
Ending a Terminal Session We can end a terminal session by either closing the terminal emulator window, by entering the exit command at the shell prompt, or pressing Ctrl-d. [me@linuxbox ~]$ exit |
|
|
|
|
|