HowTo: Linux / Unix See File Size Command

I am a new Linux user. How do I find and list file sizes on Linux? How can I find out file size under Linux using bash shell/terminal prompt?

You can use any one of the following command line options to display file size on Linux or Unix-like operating systems:

a] ls command – list directory contents.

b] du command – estimate file space usage.

c] stat command – display file or file system status.


To determine the size of a file called /bin/grep, enter:

ls -l /bin/grep

Sample outputs:

-rwxr-xr-x 1 root root 175488 May 13  2012 /bin/grep

In the above output example, the 175488 is the size of the file. For a more user friendly output, pass the -h option to the ls command:

ls -lh /bin/grep

Sample outputs:

-rwxr-xr-x 1 root root 172K May 13  2012 /bin/grep

In the above output example, the 172K is the size of the file. The du command provides the same output in a more user friendly way and it hides all other details too:
du -h /bin/grep
Sample outputs:

172K	/bin/grep

Finally, stat command also provide file size:
stat /bin/grep
Sample outputs:

stat /bin/grep 
  File: `/bin/grep'
  Size: 175488    	Blocks: 344        IO Block: 4096   regular file
Device: 900h/2304d	Inode: 5505033     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-06-10 01:31:37.520022359 +0530
Modify: 2012-05-13 18:17:28.000000000 +0530
Change: 2013-05-17 02:16:17.138033825 +0530

The following commands are executed on Apple OS X Unix operating systems to file out the file size of the /usr/bin/vim binary file:
$ ls -l /usr/bin/vim
$ ls -lh /usr/bin/vim
$ stat -x /usr/bin/vim

Sample outputs:

Fig.01: Finding out file size using various command line options on OS X Unix OS

See also
  • ls(1)

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts