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 








Disk Usage of a Specific Directory

Linux Tips by Burleson Consulting

As we create and remove files and directories it is often important to keep track of disk usage.  For that we use the du (disk usage) command.

$ du -hs .
2.3M    .

Here du is called with the options h to show the output in a human readable format and s to show only the summary of all disk usage in this directory.  While we specified the working directory (.) in this example any directory could be given here.

File Commands

Creating an Empty File

Sometimes, it is useful to create an empty file as a placeholder for future content.  The touch command can be used without any options to create an empty file as follows:

$ touch /home/tclark/touch1.fil
$ touch touch2.fil
$ ls ?l
total 4
drwxrwxr-x    2 tclark   tclark       4096 Jan 13 17:48 examples
-rw-rw-r--    1 tclark   tclark          0 Jan 13 19:13 touch1.fil
-rw-rw-r--    1 tclark   tclark          0 Jan 13 19:14 touch2.fil

The touch command also has an option that allows the file timestamp information of an existing file to be changed using the ?t option.  In the following example, the timestamp on the touch1.fil above will be changed to January 10 12:00.  The date format for this option is given as a string of numbers with two digits each for month, date, hour (in 24 hour format) and minute, so the string for January 10 12:00 would be 01101200. For instance, the user may want to change a group of files in a directory to indicate a particular release date.

$ touch -t 01101200 touch1.fil
$ ls -l
total 4
drwxrwxr-x    2 tclark   tclark       4096 Jan 13 17:48 examples
-rw-rw-r--    1 tclark   tclark          0 Jan 10 12:00 touch1.fil
-rw-rw-r--    1 tclark   tclark          0 Jan 13 19:14 touch2.fil

A Brief Discussion about Wildcards

Many of the common file and directory manipulation commands, including most of the ones mentioned in the balance of this chapter, will let you use a partial file or path name and substitute a wildcard character for the rest of one or several files.  These wildcards can save you a lot of typing, but can also leave you with ambiguous results, possibly even causing the accidental deletion of files!

The two most common wildcard characters are the asterisk (*) and the question mark (?).  The *, commonly called the star, will match any number of any characters within a filename, even if there are none.  The ? will match any single character within a filename.

Here are a couple examples which should make wildcards a bit more clear:

$ ls
examples  touch1.fil  touch2.fil
$ ls tou*
touch1.fil  touch2.fil
$ ls touch?.fil
touch1.fil  touch2.fil
$ ls *ch?.fil
touch1.fil  touch2.fil

In the last example we see that multiple wildcards can be used within the same statement and both will be applied to the results.  The most important thing to remember about wildcards is that they will not just match one but will instead match all files which have the pattern you have described.

Deleting Files

The remove (rm) command can be used to delete a file; referencing the file either via an absolute path or via a relative path.  Wildcard symbols such as * and ?, can be used to delete files with similar names. 

* Be careful with the rm command, especially as root!  Linux tends to just delete what you tell it no questions asked!

Here are some examples of the rm command:

$ rm /home/tclark/touch1.fil
$ ls
examples  touch2.fil
$ rm touch2.fil
$ ls
$ touch touch1.fil touch2.fil touch3.fil
$ ls
examples  touch1.fil  touch2.fil  touch3.fil
$ rm touch?.fil
$ ls

The rm command can be used with the ?r (recursive) option to remove a directory and its contents.  The rm ?r command, as with other commands which affect multiple files, should be used with caution.

$ mkdir ?p new_dir3/sub_dir3
$ ls
examples  new_dir3
$ rmdir new_dir3
rmdir: `new_dir3': Directory not empty 

$ rm -r new_dir3
$ ls

Preventing Accidental File Deletion

A little trick that some Linux users like to implement to prevent accidental file deletion is via the use of an alias.  Aliases are similar to variables and can either be set in a session or by placing the command alias in the .bash_profile file with a text editor.

By adding this alias the user will be prompted to confirm each file before it is deleted; otherwise Linux, unlike Microsoft Windows, will delete whatever files match the filename criteria without warning!

$ alias rm='rm -i'
$ touch touch1.fil touch2.fil touch3.fil
$ rm touch*
rm: remove regular empty file `touch1.fil'? y
rm: remove regular empty file `touch2.fil'? y
rm: remove regular empty file `touch3.fil'? y

Deleting Files Using File Properties

When doing some file cleanup operations and it becomes desirable to delete all files within a directory that have not been used or accessed in more than 30 days, the following command example will be useful:

$ find . ?maxdepth 1 -atime +30 -exec rm {} \;

This find command locates files which have not been accessed in 30 days, and then executes a rm command for each file found.  The find command can be very useful for performing operations on multiple files.  We will discuss find in much more detail in chapter 4.

Moving and Renaming Files

The mv (move) command will allow you to move or rename files and directories.  Linux does not discern between these two functions as renaming can be just considered moving a file to a different name. 

The rules for mv are similar to those for rm described earlier, in that file references can be via a fully qualified path or via a relative path.  The use of the wildcard symbols in the filename is also allowed.  The following are some examples:

* Move file example1.fil from the current working directory to the /tmp directory:

$ mv example1.fil /tmp
* Move file example1.fil using the fully qualified path to the /tmp directory:
$ mv /home/tclark/example2.fil /tmp
* Rename temp1.fil in the /tmp directory to from the home directory:
$ cd /tmp
$ touch temp1.fil temp2.fil
$ ls -l temp*
-rw-rw-r--    1 tclark   tclark          0 Jan 13 21:15 temp1.fil
-rw-rw-r--    1 tclark   tclark          0 Jan 13 21:15 temp2.fil
$ cd ?
$ mv /tmp/temp1.fil /tmp/
$ cd -
$ ls temp*  temp2.fil

This example demonstrates how by using absolute paths we can perform a command on a directory which is not our working directory.

* Rename example2.fil in the current working directory to

$ ls
$ touch example1.fil example2.fil
$ ls
example1.fil  example2.fil  examples
$ mv example2.fil
$ ls
example1.fil  examples

So far we've discussed several ways to manipulate files and directories.  Since these commands are so powerful you may find that you want to make a backup before you make certain changes.  We'll look at how to do this in the next section.


This is an excerpt from "Easy Linux Commands" by Linux guru Jon Emmons.  You can purchase it for only $19.95 (30%-off) at this link.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


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