System Administration Guide: Advanced Administration

How to Display the Size of Files

  1. Change to the directory where the files you want to check are located.

  2. Display the size of the files.


    $ ls [-lh] [-s]

    -l

    Displays a list of files and directories in long format, showing the sizes in bytes. (See the example that follows.) 

    -h

    Scales file and directory sizes into Kbytes, Mbytes, Gbytes, or Terabytes 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 ls(1).

    -s

    Displays a list of the files and directories, showing the sizes in blocks. 

Examples—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 148
drwxrwxr-x   5 adm      adm          512 Nov 26 09:39 acct/
-rw-------   1 uucp     bin            0 Nov 26 09:25 aculog
drwxr-xr-x   2 adm      adm          512 Nov 26 09:25 exacct/
-r--r--r--   1 root     other       342K Nov 26 13:56 lastlog
drwxr-xr-x   2 adm      adm          512 Nov 26 09:25 log/
-rw-r--r--   1 root     root         20K Nov 26 13:55 messages
drwxr-xr-x   2 adm      adm          512 Nov 26 09:25 passwd/
drwxrwxr-x   2 adm      sys          512 Nov 26 09:39 sa/
drwxr-xr-x   2 root     sys          512 Nov 26 09:49 sm.bin/
-rw-rw-rw-   1 root     bin            0 Nov 26 09:25 spellhist
drwxr-xr-x   2 root     sys          512 Nov 26 09:25 streams/
-rw-r--r--   1 root     bin         3.3K Nov 26 13:56 utmpx
-rw-r--r--   1 root     root           0 Nov 26 10:17 vold.log
-rw-r--r--   1 adm      adm          19K Nov 26 13:56 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