Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Viewing the UNIX/Linux Command History

Expert Oracle Tips by Burleson Consulting

March 22, 2011

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.

history command

If a list of recently executed commands needs to be viewed, use the history command.

$ history
    1  pwd
    2  ls
    3  ls -l
    4  ls notes
    5  ls -a
    6  cd notes/
    7  pwd
    8  cd ../
    9  pwd
   10  cd ..
   11  pwd
   12  cd jemmons/notes
   13  pwd
   14  cd /home/jemmons/notes
   15  pwd
   16  cd /tmp
   17  cd /home/jemmons/notes
   18  pwd
   19  cd /home/jemmons
   20  pwd
   21  cd ~
   22  pwd
   23  history
   24  history

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 successfully.

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 ~
   22  pwd
   23  hisotory
   24  history
   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:

$ !22

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 Definitive Reference" 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.

Buy it for 30% off directly from the publisher.



Burleson is the American Team

Note: This Oracle 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 Oracle forum.

Verify experience! Anyone 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 publish their Oracle qualifications.

Errata?  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 feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster