Finding Commands Quickly; Tips On Using Command History - Red Hat ENTERPRISE LINUX 4 - STEP BY STEP GUIDE Manual

Table of Contents

Advertisement

128

14.7. Finding Commands Quickly

I was looking at a man page yesterday, but I cannot remember the name of the command I was reading
about, and I did not write it down. How do I get the man page back?
The command you used is stored in a file called
500 commands you typed at the shell prompt.
You can glimpse the history of your commands by typing
are displayed too quickly for you to read every line.
Another way to view
at the shell prompt and the results will display one page at a time. To move forward a screen, press
the [Space] bar; to move back a screen, press the [b] key, and to quit, press [q].
Paging through
.bash_history
through the file for keywords using grep, a powerful search utility.
Say you were reading the man page the day before, but cannot recall its name. To search for the
command, type:
history | grep man
All the commands you typed which have the word man in them are now highlighted.
There are many ways to use your command history. For other tips and tricks, see
Section 14.8 Tips on Using Command History.

14.8. Tips on Using Command History

What are some other ways I can use command history?
If you type history, a numbered list scrolls by very quickly, showing you the previous 500 com-
mands you have used.
You probably do not need to see all of the last 500 commands, so the command history 20 might
be useful. This way, only the previous 20 commands you typed are displayed (you can use any quantity
as an argument of the
14.8.1. Other Shortcuts
Here are other command history shortcuts which may be useful to you:
"Bang, bang": Typing
"Bang number": Typing
the history file.
"Bang string": Typing
ing string from the history file.
[Up arrow] and [down arrow]: At the shell or GUI terminal prompt, you can press the up arrow
to move back through previous commands in your history list (the down arrow moves you for-
ward through the commands) until you find the command you want. Press [Enter] to execute the
command, just as if you had typed it on the command line.
is with a utility such as less. Type less .bash_history
.bash_history
to find a command can be tedious. Alternatively, you can search
command).
history
(called "bang bang") executes the last command in the history.
!!
(as in
!number
(as in
!string
Chapter 14. Frequently Asked Questions
. By default, this file records the last
.bash_history
history
) executes the command which is numbered 302 in
!302
) executes a command with the most recent match-
!rpm
at the shell prompt, but the results

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 4

Table of Contents