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

 
 Home
 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
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

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

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Viewing the UNIX/Linux Command History

Expert Oracle Tips by Burleson Consulting

March 22, 2011

Viewing the Command History

 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
pwd
/home/jemmons

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.

Changing Things

Once navigating around at the command line feels comfortable, the next thing to master is how to make changes.

mkdir command

To create a new directory in the current directory, use the mkdir command.

$ mkdir lists
$ ls
 

Note:  If you want to create more than one directory at a time, list multiple directories separated by spaces after the mkdir command.

If you want to make multiple directories within one another, use the -p option and separate the directories with a slash (/).


Desktop  lists   notes  to_do.txt

mv command

Now that there is a new directory, move an item into it with the mv command.

$ mv to_do.txt lists/
$ ls lists
 
to_do.txt
 

The mv command requires two arguments in the order of source, then destination.  mv can be used with files, as seen above, or directories.  mv can also be used to rename a file. 

$ cd lists
$ ls
to_do.txt
 
$ mv to_do.txt to_do_list.txt
$ ls
 
to_do_list.txt

touch command

In some instances, it is useful to make an empty file as a place keeper or for editing in the future.  Use the touch commandto create an empty file.

$ touch shopping_list.txt
$ ls
shopping_list.txt  to_do_list.txt
 
This creates a new empty file.  The touch command can also be used on an existing file to update its modification time.

$ ls -l 

total 12
-rw-rw-r-- 1 jemmons jemmons  0 Sep 20 07:34 shopping_list.txt
-rw-rw-r-- 1 jemmons jemmons 53 Sep 17 10:50 to_do_list.txt 

$ touch to_do_list.txt
$ ls -l 

total 12
-rw-rw-r-- 1 jemmons jemmons  0 Sep 20 07:34 shopping_list.txt
-rw-rw-r-- 1 jemmons jemmons 53 Sep 20 07:35 to_do_list.txt

This can be useful when a file needs to appear to be updated even if it has not been, or if there have been issues with the system clock and the timestamp for the file needs to be reset.

rm and rmdir command

Oftentimes, files or directories that are no longer needed need to be removed.  To remove files, use the rm command.

$ ls 
shopping_list.txt  to_do_list.txt 
$ rm shopping_list.txt
$ ls 
to_do_list.txt


Similar to mkdir and many other commands, list multiple files to be removed by separating them with spaces.

The command rmdircan be used to remove empty directories, but it will not work if the directory still has something in it.

$ cd ../
$ ls 

Desktop  lists  notes 

$ mkdir empty_dir
$ ls 

Desktop  empty_dir  lists  notes 

$ rmdir empty_dir
$ ls 

Desktop  lists  notes 

$ rmdir lists 

rmdir: lists: Directory not empty 

$ ls 

Desktop  lists  notes

If you want to remove a directory and its contents, add the -r flag to the rm command.

$ ls

Desktop  lists  notes

$ rm -r lists
$ ls 

Desktop  notes
 

Note:  Before using rm -r, or any other form of rm for that matter, be sure that what is about to be deleted is no longer needed!  There is no undo, and no easy way to recover deleted files!

 

 

 

 

While the examples in this section have been using relative paths, they can also be used with absolute paths.

Commands like mkdir, rm, touch and even ls can act on multiple files or directories at once.  To do this, simply list the files or directories that should be acted on with spaces separating them.

Commands like mv and cp that require a source and destination pair will almost always require them in that order.  Multiple sources can be listed but only if the destination provided is a directory.

 

 

 
 
 
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