Viewing the Command History
As you navigate around and start making changes to your system,
it is sometimes helpful to see what commands have been run recently
and sometimes repeat selected ones. There are a couple of easy ways
to do that in Linux.
If the bash shellis being
used, which is the default in most Linux distros, use the up and
down arrow keys to navigate through recent commands. Pressing the
up arrow displays the next older command at the prompt, and the down
arrow displays the next newer command.
When the command that you are in is found, then edit it or press
Enter to execute that command again. If it is decided that none of
these commands should be executed again, press the down arrow until
a blank line appears or delete the contents of the line you are on.
If a list of recently executed commands needs to be viewed, use
the history command.
3 ls -l
4 ls notes
5 ls -a
6 cd notes/
8 cd ../
10 cd ..
12 cd jemmons/notes
14 cd /home/jemmons/notes
16 cd /tmp
17 cd /home/jemmons/notes
19 cd /home/jemmons
21 cd ~
This can be very useful for documenting the steps that have been
taken. As seen on line 23 of the history output above, history
displays all commands entered, even ones that did not run
After a while, the output of history can get very long. If only
a few commands need to be displayed, call history with a number of
lines as an argument.
$ history 5
21 cd ~
25 history 5
The history can also be cleared and you can start over
again by executing history -c. There is a limit to how many
commands are kept in the history. The default is 1000, but this may
vary by implementation. Another way to repeat previously executed
commands is by using the exclamation point (!) followed by a history
number. After using history to look up the command’s number, the
syntax looks like this:
This is referred to as history expansion.
There are options that will allow previous commands to be repeated
while substituting some of the text of the command, but to get
started, just use history expansion to repeat previous commands.
Great care must be taken when repeating previous commands,
especially when used with commands that make changes. Commands that
make changes will be covered in the next section.
Get the Complete Details on
Linux System Management for Oracle DBAs
The landmark book
"Linux for the Oracle DBA: The
provides comprehensive yet specific
knowledge on administering Oracle on Linux. A
must-have reference for every DBA running or planning to run
Oracle on a Linux platform.
for 30% off directly from the publisher.
Burleson is the American Team
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
and include the URL for the page.
Copyright © 1996 - 2017
All rights reserved by
is the registered trademark of Oracle Corporation.
Remote Emergency Support provided by