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
When using a graphical user interface, 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. There are a number of other terminal
emulators available for Linux, but they all basically do the same thing; give us access to
the shell. You will probably
Your First Keystrokes
So let’s get started. Launch the terminal emulator! Once it comes up, we should see
something like this:
This is called a shell prompt and it will appear whenever the shell is ready to accept
input. While it may vary in appearance somewhat depending on the distribution, it will
usually include your username@machinename, followed by the current working
directory (more about that in a little bit) and a dollar sign.
If the last character of the prompt is a pound sign (“#”) rather than a dollar 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.
Assuming that things are good so far, let’s try some typing. Type some gibberish at the
prompt like so:
[me@linuxbox ~]$ kaekfjaeifj
Since this command makes no sense, the shell will tell us so and give us another chance:
bash: kaekfjaeifj: command not found [me@linuxbox ~]$
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 five hundred commands by default. Press the down-arrow key and the
previous command disappears.
Recall the previous command with the up-arrow key again. Now try the left and rightarrow
keys. See how we can position the cursor anywhere on the command line? This
makes editing commands easy.
A Few Words About Mice And Focus
While the shell is all about the keyboard, you can also use a mouse with your
terminal emulator. There is a mechanism built into the X Window System (the
underlying engine that makes the GUI go) that supports a quick copy and paste
technique. If you highlight some text by holding down the left mouse button and
dragging the mouse over it (or double clicking on a word), it is copied into a
buffer maintained by X. Pressing the middle mouse button will cause the text to
be pasted at the cursor location. Try it.
Note: Don’t be tempted to use Ctrl-c and Ctrl-v to perform copy and paste
inside a terminal window. They don’t work. These control codes have different
meanings to the shell and were assigned many years before Microsoft Windows.
Your graphical desktop environment (most likely KDE or GNOME), in an effort
to behave like Windows, probably has its focus policy set to “click to focus.”
This means for a window to get focus (become active) you need to click on it.
This is contrary to the traditional X behavior of “focus follows mouse” which
means that a window gets focus by just passing the mouse over it. The window
will not come to the foreground until you click on it but it will be able to receive
input. Setting the focus policy to “focus follows mouse” will make the copy and
paste technique even more useful. Give it a try. I think if you give it a chance
you will prefer it. You will find this setting in the configuration program for your
Try Some Simple Commands
Now that we have learned to type, let’s try a few simple commands. The first one is
date. This command displays the current time and date.
[me@linuxbox ~]$ date Thu Oct 25 13:51:54 EDT 2015