Linux Quick Reference: How do I get the size of a folder, a file or a disk

+1 vote
Good day to you!

Please find below my brief cheat notes on finding out the size of a folder, a file and a disk quickly in Linux system.
asked Jan 13, 2017 in System administration by Brian

1 Answer

0 votes

Below, there is my cheat sheet on the useful commands in Linux. If you have forgotten the command you need, you can always look it up here. The most frequently used commands are marked in bold type. 

Finding out the size of a file

To find out the certain file size, type in the following command:

du -h /file_path/file name
du -h.  /file name – if the file is located in that very folder where you are now 

The parameter –h should be added in order to get an understandable representation of the file size.

Finding out the size of a file

To display the list of all files with their size, type in:

ll -h – to display the current folder list
ll -h /path to the folder with files

Finding out folder size in Linux

To find out the size of a folder, use the command:

du -sh  - the current folder size
du -sh /folder_path

h – display the size in understandable representation, s – display the final size only (without the list of all sub-catalogues and files)

Finding out folder size in Linux

If you need to display the list of all sub-folders of the current folder with their size stated – use ll command; the same is used for files.

Finding out disk size, used and empty disk space

To display the list of all mapped disks and file systems, where the total size, as well as empty and used space will be stated, type in the command:

df -ah

The result will look something like this:

Finding out disk size

The lines starting with /dev/ are physical disks; further you can see file systems, located on these disks. Parameter “-a” is necessary for displaying the information about all the disks, installed in the system.
If you have any questions left or need some details – please, ask a question or leave a comment.

answered Jan 13, 2017 by Expert Brian (5,410 points)
Welcome to Help Desk, here you can ask any questions and receive answers from our experts and other members of the community.

If you have any questions, please do not hesitate to contact our help desk!

Make a question!