Skip Navigation Links | |
Exit Print View | |
![]() |
Oracle Solaris Administration: Common Tasks Oracle Solaris 11 Information Library |
1. Locating Information About Oracle Solaris Commands
2. Managing User Accounts and Groups (Overview)
3. Managing User Accounts and Groups (Tasks)
4. Booting and Shutting Down an Oracle Solaris System
5. Working With Oracle Configuration Manager
6. Managing Services (Overview)
9. Managing System Information (Tasks)
10. Managing System Processes (Tasks)
11. Monitoring System Performance (Tasks)
12. Managing Software Packages (Tasks)
Displaying Information About Files and Disk Space
How to Display Information About Files and Disk Space
How to Display the Size of Files
How to Find Files That Exceed a Specified Size Limit
Checking the Size of Directories
How to Display the Size of Directories, Subdirectories, and Files
Finding and Removing Old or Inactive Files
How to Find and Remove Old or Inactive Files
How to Clear Out Temporary Directories
14. Scheduling System Tasks (Tasks)
15. Setting Up and Administering Printers by Using CUPS (Tasks)
16. Managing the System Console, Terminal Devices, and Power Services (Tasks)
17. Managing System Crash Information (Tasks)
18. Managing Core Files (Tasks)
19. Troubleshooting System and Software Problems (Tasks)
20. Troubleshooting Miscellaneous System and Software Problems (Tasks)
Part of the job of cleaning up heavily loaded file systems involves locating and removing files that have not been used recently. You can locate unused files by using the ls or find commands. For more information, see the ls(1) and find(1) man pages.
Other ways to conserve disk space include emptying temporary directories such as the directories located in /var/tmp or /var/spool, and deleting core and crash dump files. For more information about crash dump files, refer to Chapter 17, Managing System Crash Information (Tasks).
$ ls -t [directory]
Sorts files by latest time stamp first.
Identifies the directory that you want to search.
Example 13-9 Listing the Newest Files
The following example shows how to use the ls -tl command to locate the most recently created or changed files within the /var/adm directory. The sulog file was created or edited most recently.
$ ls -tl /var/adm -rw-r--r-- 1 root root 3227516 Jan 7 12:22 messages -rw-r--r-- 1 adm adm 12648 Jan 7 06:45 wtmpx -r--r--r-- 1 root root 3353420 Jan 7 06:45 lastlog drwxrwxr-x 9 root sys 15 Jan 4 03:10 . -rw-r--r-- 1 root root 56045 Jan 3 19:10 messages.0 drwxr-xr-x 41 root sys 42 Jan 3 19:03 .. lrwxrwxrwx 1 root root 27 Jan 3 17:36 utmpx -> ../../system/volatile/utmpx -rw------- 1 uucp bin 0 Jan 3 17:34 aculog drwxr-xr-x 2 root sys 2 Jan 3 17:26 streams drwxr-xr-x 2 root sys 2 Jan 3 17:26 sm.bin drwxrwxr-x 2 adm sys 2 Jan 3 17:26 sa drwxr-xr-x 2 root sys 2 Jan 3 17:26 pool drwxr-xr-x 2 adm adm 2 Jan 3 17:26 log drwxr-xr-x 2 adm adm 2 Jan 3 17:26 exacct drwxrwxr-x 5 adm adm 5 Jan 3 17:26 acct
For more information, see How to Obtain Administrative Rights in Oracle Solaris Administration: Security Services.
# find directory -type f[-atime +nnn] [-mtime +nnn] -print > filename &
Identifies the directory you want to search. Directories below this directory are also searched.
Finds files that have not been accessed within the number of days (nnn) that you specify.
Finds files that have not been modified within the number of days (nnn) that you specify.
Identifies the file that contains the list of inactive files.
# rm `cat filename`
where filename identifies the file that was created in the previous step. This file contains the list of inactive files.
Example 13-10 Finding and Removing Old or Inactive Files
The following example shows files in the /var/adm directory and the subdirectories that have not been accessed in the last 60 days. The /var/tmp/deadfiles file contains the list of inactive files. The rm command removes these inactive files.
# find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles & # more /var/tmp/deadfiles /var/adm/aculog /var/adm/spellhist /var/adm/wtmpx /var/adm/sa/sa13 /var/adm/sa/sa27 /var/adm/sa/sa11 /var/adm/sa/sa23 /var/adm/sulog /var/adm/vold.log /var/adm/messages.1 /var/adm/messages.2 /var/adm/messages.3 # rm `cat /var/tmp/deadfiles` #
For more information, see How to Obtain Administrative Rights in Oracle Solaris Administration: Security Services.
# cd directory
![]() | Caution - Ensure that you are in the correct directory before completing Step 3. Step 3 deletes all files in the current directory. |
# rm -r *
Example 13-11 Clearing Out Temporary Directories
The following example shows how to clear out the mywork directory, and how to verify that all files and subdirectories were removed.
# cd mywork # ls filea.000 fileb.000 filec.001 # rm -r * # ls #
# find . -name core -exec rm {} \;
Example 13-12 Finding and Deleting core Files
The following example shows how to find and remove core files from the jones user account by using the find command.
# cd /home/jones # find . -name core -exec rm {} \;
Crash dump files can be very large. If you have enabled your system to store these files, do not retain them for longer than necessary.
# cd /var/crash/
![]() | Caution - Ensure you are in the correct directory before completing Step 3. Step 3 deletes all files in the current directory. |
# rm *
# ls
Example 13-13 Deleting Crash Dump Files
The following example shows how to remove crash dump files from the system venus, and how to verify that the crash dump files were removed.
# cd /var/crash # rm * # ls