How to find information related to disk space usage – Solaris


Solaris11-How-to

This how-to article discuss about 

 

  • Displaying Information About File Size and Disk Space 
  • Displaying File Size Information in 1024 Bytes on a System With a ZFS Root File System 
  • Find Large Files from a directory
  • Finding  Files That Exceed a Specified Size Limit 

 

 

Displaying Information About File Size and Disk Space 

In the following example, all the file systems listed are locally mounted except for /usr/dist.
 
$ df
/ (/dev/dsk/c0t0d0s0 ): 101294 blocks 105480 files
/devices (/devices ): 0 blocks 0 files
/system/contract (ctfs ): 0 blocks 2147483578 files
/proc (proc ): 0 blocks 1871 files
/etc/mnttab (mnttab ): 0 blocks 0 files
/etc/svc/volatile (swap ): 992704 blocks 16964 files
/system/object (objfs ): 0 blocks 2147483530 files
/usr (/dev/dsk/c0t0d0s6 ): 503774 blocks 299189 files
/dev/fd (fd ): 0 blocks 0 files
/var/run (swap ): 992704 blocks 16964 files
/tmp (swap ): 992704 blocks 16964 files
/opt (/dev/dsk/c0t0d0s5 ): 23914 blocks 6947 files
/export/home (/dev/dsk/c0t0d0s7 ): 16810 blocks 7160 files

 

Displaying File Size Information in 1024 Bytes on a System With a ZFS Root File System 

 

In the following example, file system information for a system is displayed in 1024 bytes.

 
Filesystem size used avail capacity Mounted on

rpool/ROOT/s1008be 67G 4.6G 58G 8% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 1.9G 1.5M 1.9G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap1.so.1
63G 4.6G 58G 8% /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap1.so.1
63G 4.6G 58G 8% /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd 0K 0K 0K 0% /dev/fd
rpool/ROOT/s1008be/var
67G 73M 58G 1% /var
swap 1.9G 32K 1.9G 1% /tmp
swap 1.9G 40K 1.9G 1% /var/run
rpool/export 67G 20K 58G 1% /export
rpool/export/home 67G 18K 58G 1% /export/home
Example 8-3 Displaying Total Number of Blocks and Files Allocated for a File System
 
The following example shows a list of all mounted file systems, device names, total 512-byte blocks used, and the number of files. The second line of each two-line entry displays the total number of blocks and files that are allocated for the file system.
 
$ df -t
/ (/dev/dsk/c0t0d0s0 ): 101294 blocks 105480 files
total: 509932 blocks 129024 files
/devices (/devices ): 0 blocks 0 files
total: 0 blocks 113 files
/system/contract (ctfs ): 0 blocks 2147483578 files
total: 0 blocks 69 files
/proc (proc ): 0 blocks 1871 files
total: 0 blocks 1916 files
/etc/mnttab (mnttab ): 0 blocks 0 files
total: 0 blocks 1 files
/etc/svc/volatile (swap ): 992608 blocks 16964 files
total: 993360 blocks 17025 files
/system/object (objfs ): 0 blocks 2147483530 files
total: 0 blocks 117 files
/usr (/dev/dsk/c0t0d0s6 ): 503774 blocks 299189 files
total: 6650604 blocks 420480 files
/dev/fd (fd ): 0 blocks 0 files
total: 0 blocks 31 files
/var/run (swap ): 992608 blocks 16964 files
total: 992688 blocks 17025 files
/tmp (swap ): 992608 blocks 16964 files
total: 992688 blocks 17025 files
/opt (/dev/dsk/c0t0d0s5 ): 23914 blocks 6947 files
total: 27404 blocks 7168 files
/export/home (/dev/dsk/c0t0d0s7 ): 16810 blocks 7160 files
total: 18900 blocks 7168 files

 

Find Large Files from a directory

 

Display the size of files in blocks from largest to smallest.
 

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.

 

Finding Large Files (Sorting by the Fifth Field’s Character)

 

$ ls -l | sort +4rn | more
-r–r–r– 1 root root 4568368 Oct 17 08:36 lastlog
-rw-r–r– 1 adm adm 697040 Oct 17 12:30 pacct.9
-rw-r–r– 1 adm adm 280520 Oct 17 13:05 pacct.2
-rw-r–r– 1 adm adm 277360 Oct 17 12:55 pacct.4
-rw-r–r– 1 adm adm 264080 Oct 17 12:45 pacct.6
-rw-r–r– 1 adm adm 255840 Oct 17 12:40 pacct.7
-rw-r–r– 1 adm adm 254120 Oct 17 13:10 pacct.1
-rw-r–r– 1 adm adm 250360 Oct 17 12:25 pacct.10
-rw-r–r– 1 adm adm 248880 Oct 17 13:00 pacct.3
-rw-r–r– 1 adm adm 247200 Oct 17 12:35 pacct.8
-rw-r–r– 1 adm adm 246720 Oct 17 13:15 pacct.0
-rw-r–r– 1 adm adm 245920 Oct 17 12:50 pacct.5
-rw-r–r– 1 root root 190229 Oct 5 03:02 messages.1
-rw-r–r– 1 adm adm 156800 Oct 17 13:17 pacct
-rw-r–r– 1 adm adm 129084 Oct 17 08:36 wtmpx

 

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
48 lastlog
30 messages
24 wtmpx
18 pacct
8 utmpx
2 vold.log
2 sulog
2 sm.bin/
2 sa/
2 passwd/
2 pacct1
2 log/
2 acct/
0 spellhist
0 aculog
total 144
 

 

Finding  Files That Exceed a Specified Size Limit 

To locate and display the names of files that exceed a specified size, use the find command.

$ find directory -size +nnn

directory  :   Identifies the directory that you want to search.

-size +nnn  :  Is a number of 512-byte blocks. Files that exceed this size are listed.

 

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

 

Display the Size of Directories, Subdirectories, and Files

The following example shows the sizes of two directories:
 
$ du -s /var/adm /var/spool/lp
130 /var/adm
40 /var/spool/lp

The following example shows the sizes of two directories and includes the sizes of all the subdirectories and files that are contained within each directory. The total number of blocks that are contained in each directory is also displayed:
 
$ du /var/adm /var/spool/lp
2 /var/adm/exacct
2 /var/adm/log
2 /var/adm/streams
2 /var/adm/acct/fiscal
2 /var/adm/acct/nite
2 /var/adm/acct/sum
8 /var/adm/acct
2 /var/adm/sa
2 /var/adm/sm.bin
258 /var/adm
4 /var/spool/lp/admins
2 /var/spool/lp/requests/printing….
4 /var/spool/lp/requests
4 /var/spool/lp/system
2 /var/spool/lp/fifos
24 /var/spool/lp

The following example shows directory sizes in 1024–byte blocks:
 
$ du -h /usr/share/audio
796K /usr/share/audio/samples/au
797K /usr/share/audio/samples
798K /usr/share/audio

 

 Display the User Ownership of Local UFS File Systems

following example, users of the root (/) file system are displayed. In the subsequent example, users of all mounted UFS file systems are displayed.
 
# quot /
/dev/rdsk/c0t0d0s0:
43340 root
3142 rimmer
47 uucp
35 lp
30 adm
4 bin
4 daemon

 

# quot -a
/dev/rdsk/c0t0d0s0 (/):
43340 root
3150 rimmer
47 uucp
35 lp
30 adm
4 bin
4 daemon
/dev/rdsk/c0t0d0s6 (/usr):
460651 root
206632 bin
791 uucp
46 lp
4 daemon
1 adm
/dev/rdsk/c0t0d0s7 (/export/home):
9 root

 

 

How to List 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
total 134
-rw——- 1 root root 315 Sep 24 14:00 sulog
-r–r–r– 1 root other 350700 Sep 22 11:04 lastlog
-rw-r–r– 1 root bin 4464 Sep 22 11:04 utmpx
-rw-r–r– 1 adm adm 20088 Sep 22 11:04 wtmpx
-rw-r–r– 1 root other 0 Sep 19 03:10 messages
-rw-r–r– 1 root other 0 Sep 12 03:10 messages.0
-rw-r–r– 1 root root 11510 Sep 10 16:13 messages.1
-rw-r–r– 1 root root 0 Sep 10 16:12 vold.log
drwxr-xr-x 2 root sys 512 Sep 10 15:33 sm.bin
drwxrwxr-x 5 adm adm 512 Sep 10 15:19 acct
drwxrwxr-x 2 adm sys 512 Sep 10 15:19 sa
-rw——- 1 uucp bin 0 Sep 10 15:17 aculog
-rw-rw-rw- 1 root bin 0 Sep 10 15:17 spellhist
drwxr-xr-x 2 adm adm 512 Sep 10 15:17 log
drwxr-xr-x 2 adm adm 512 Sep 10 15:17 passwd

 

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`
#

 

 

Finding and Clearing  Core Files

# find . -name core -exec rm {} ;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us