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
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
How to Find and Delete core Files
How to Delete Crash Dump Files
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)
You can check the size of files and sort them by using the ls command. You can find files that exceed a size limit by using the find command. For more information, see the ls(1) and find(1) man pages.
Note - If you run out of space in the /var directory, do not symbolically link the /var directory to a directory on a file system with more disk space. Doing so, even as a temporary measure, might cause problems for certain daemon processes and utilities.
$ ls [-lh] [-s]
Displays a list of files and directories in long format, showing the sizes in bytes. (See the example that follows.)
Scales file sizes and directory sizes into Kbytes, Mbytes, Gbytes, or Tbytes when the file or directory size is larger than 1024 bytes. This option also modifies the output displayed by the -o, -n, -@, and -g options to display file or directory sizes in the new format. For more information, see thels(1) man page.
Displays a list of the files and directories, showing the sizes in blocks.
Example 13-4 Displaying the Size of Files
The following example shows that the lastlog and messages files are larger than the other files in the /var/adm directory.
$ cd /var/adm $ ls -lh total 682 drwxrwxr-x 9 root sys 15 Jan 4 03:10 . drwxr-xr-x 41 root sys 42 Jan 3 19:03 .. drwxrwxr-x 5 adm adm 5 Jan 3 17:26 acct -rw------- 1 uucp bin 0 Jan 3 17:34 aculog drwxr-xr-x 2 adm adm 2 Jan 3 17:26 exacct -r--r--r-- 1 root root 3.2M Jan 4 06:47 lastlog drwxr-xr-x 2 adm adm 2 Jan 3 17:26 log -rw-r--r-- 1 root root 0 Jan 4 03:10 messages -rw-r--r-- 1 root root 55K Jan 3 19:10 messages.0 drwxr-xr-x 2 root sys 2 Jan 3 17:26 pool drwxrwxr-x 2 adm sys 2 Jan 3 17:26 sa drwxr-xr-x 2 root sys 2 Jan 3 17:26 sm.bin drwxr-xr-x 2 root sys 2 Jan 3 17:26 streams lrwxrwxrwx 1 root root 27 Jan 3 17:36 utmpx -> \ ../../system/volatile/utmpx -rw-r--r-- 1 adm adm 10K Jan 4 06:47 wtmpx
The following example shows that the lpsched.1 file uses two blocks.
$ cd /var/lp/logs $ ls -s total 2 0 lpsched 2 lpsched.1
If the characters or columns for the files are different, use the following command to sort a list of files by block size, from largest to smallest.
$ ls -l | sort +4rn | more
Note that this command sorts files in a list by the character that is in the fourth field, starting from the left.
If the characters or columns for the files are the same, use the following command to sort a list of files by block size, from largest to smallest.
$ ls -s | sort -nr | more
Note that this command sorts files in a list, starting with the left most character.
Example 13-5 Finding Large Files (Sorting by the Fifth Field's Character)
$ cd /var/adm $ ls -l | sort +4rn | more -r--r--r-- 1 root root 3353420 Jan 7 06:45 lastlog -rw-r--r-- 1 root root 3221924 Jan 7 12:15 messages -rw-r--r-- 1 root root 56045 Jan 3 19:10 messages.0 -rw-r--r-- 1 adm adm 12648 Jan 7 06:45 wtmpx drwxr-xr-x 41 root sys 42 Jan 3 19:03 .. lrwxrwxrwx 1 root root 27 Jan 3 17:36 utmpx -> ../../system/volatile/utmpx drwxrwxr-x 9 root sys 15 Jan 4 03:10 . drwxrwxr-x 5 adm adm 5 Jan 3 17:26 acct drwxr-xr-x 2 adm adm 2 Jan 3 17:26 exacct drwxr-xr-x 2 adm adm 2 Jan 3 17:26 log drwxr-xr-x 2 root sys 2 Jan 3 17:26 pool drwxr-xr-x 2 root sys 2 Jan 3 17:26 sm.bin drwxr-xr-x 2 root sys 2 Jan 3 17:26 streams drwxrwxr-x 2 adm sys 2 Jan 3 17:26 sa -rw------- 1 uucp bin 0 Jan 3 17:34 aculog
Example 13-6 Finding Large Files (Sorting by the Left Most Character)
In the following example, the lastlog and messages files are the largest files in the /var/adm directory.
$ cd /var/adm $ ls -s | sort -nr | more 6409 -rw-r--r-- 1 root root 3221924 Jan 7 12:15 messages 517 -r--r--r-- 1 root root 3353420 Jan 7 06:45 lastlog 111 -rw-r--r-- 1 root root 56045 Jan 3 19:10 messages.0 26 -rw-r--r-- 1 adm adm 12648 Jan 7 06:45 wtmpx 5 drwxr-xr-x 41 root sys 42 Jan 3 19:03 .. 3 drwxrwxr-x 9 root sys 15 Jan 4 03:10 . 3 drwxrwxr-x 5 adm adm 5 Jan 3 17:26 acct 3 drwxrwxr-x 2 adm sys 2 Jan 3 17:26 sa 3 drwxr-xr-x 2 root sys 2 Jan 3 17:26 streams 3 drwxr-xr-x 2 root sys 2 Jan 3 17:26 sm.bin 3 drwxr-xr-x 2 root sys 2 Jan 3 17:26 pool 3 drwxr-xr-x 2 adm adm 2 Jan 3 17:26 log 3 drwxr-xr-x 2 adm adm 2 Jan 3 17:26 exacct 1 lrwxrwxrwx 1 root root 27 Jan 3 17:36 utmpx -> ../../system/volatile/utmpx 1 -rw------- 1 uucp bin 0 Jan 3 17:34 aculog total 7094
$ find directory -size +nnn
Identifies the directory that you want to search.
Is a number of 512-byte blocks. Files that exceed this size are listed.
Example 13-7 Finding Files That Exceed a Specified Size Limit
The following example shows how to find files larger than 400 blocks in the current working directory. The -print option displays the output of the find command.
$ find . -size +400 -print ./Howto/howto.doc ./Howto/howto.doc.backup ./Howto/howtotest.doc ./Routine/routineBackupconcepts.doc ./Routine/routineIntro.doc ./Routine/routineTroublefsck.doc ./.record ./Mail/pagination ./Config/configPrintadmin.doc ./Config/configPrintsetup.doc ./Config/configMailappx.doc ./Config/configMailconcepts.doc ./snapshot.rs