Installation guide

Chapter 11. Shell Prompt Basics 115
cat sneakrs.txt
Nothing happens, of course, because there is no sneakrs.txt file. No problem. We will just use the
up-arrow key to bring back the command, then use the left-arrow key to get to the point where we
missed the "e." Insert the letter and press [Enter] again.
We now see the contents of sneakers.txt.
By default, up to 500 commands can be stored in the bash command line history file.
Tip
By typing the env command at a shell prompt, we can see the environment variable that controls
the size of the command line history. The line which reads, HISTFILESIZE=500 shows the number of
commands that bash will store.
The command line history is actually kept in a file, called .bash_history in our login directory. We
can read it in a number of ways: by using pico, cat, less, more, and others.
Be aware that the file can be long. To read it with the more command, from your home directory type:
more .bash_history
To move forward a screen, press [Space]; to move back a screen, press [b]; to quit, press [q].
Tip
To find a command in your history file without having to keep hitting the arrow keys or page through
the history file, use grep, a powerful search utility (see Section 11.11.3. Here is how you can quickly
find a previously used command: say you are searching for a command that is similar to cat sneak-
something. You have used the command and you think it might be in your history file. At the shell
prompt, type:
history | grep sneak
Another time-saving tool is known as command completion. If you type part of a file, command, or
pathname and then press the [Tab] key, bash will present you with either the remaining portion of the
file/path, or a beep (if sound is enabled on your system). If you get a beep, just press [Tab] again to
obtain a list of the files/paths that match what has been typed so far.
For example, if you forget the command updatedb, but remember a portion of the command, you
can su to root, then at the shell prompt, type up, press the [Tab] key twice and you will see a list
of possible completions, including updatedb and uptime. By typing the partial command upd and
pressing [Tab] again, your command is completed for you.
11.13. Using Multiple Commands
Linux allows you to enter multiple commands at one time. The only requirement is that you separate
the commands with a semicolon (you can see an example in Figure 11-7).
Want to see how long you have been online? Just combine the date command with Mozillas com-
mand.
date; mozilla; date