Software & Apps Linux Find How Much Disk Space a File or Folder Uses in Linux Manage hard drive space from the command line by Juergen Haas Writer Former Lifewire writer Juergen Haas is a software developer, data scientist, and a fan of the Linux operating system. our editorial process Juergen Haas Updated on March 24, 2020 Linux Switching from Windows Tweet Share Email This guide shows how to use the Linux command line to find out the amount of disk space a file or folder takes up. Find Out the File Sizes of All Files and Folders The du command summarises the disk usage of each file. In its simplest form, you can run the following command: du This scrolls through the files and folders in the present working directory. For each file that displays, the file size appears alongside it, and at the bottom, the total file size displays. To find out how much space is used on the drive, start at the root folder by using the following command: du / You may need to use sudo along with the du command to elevate your permissions as follows: sudo du / The main issue with the above command is that it only lists the file size of the subfolders and not the files in those subfolders. To get a complete listing, use one of the following commands: du -adu --all To get the output to scroll in pages, use the more command or the less command as follows: du | moredu | less Find out the File Size of Individual Files and Folders When you want to find out the disk usage used by a single file, specify the file name along with the du command as follows: du /path/to/file For example: du image.png The output will be something like this: 36 image.png If you enter a folder name along with the du command, you get a list of all files in the folder. For example: 88 Steam/logs92 Steam The above shows that the Steam folder has a logs folder that has a size of 88, and the total for the Steam folder is 92. It doesn't list the files in the logs folder. To get the list of files, use the following command: du -a Steam The results are now as follows: 84 Steam/logs/bootstrap_log.txt88 Steam/logs92 Steam Change the Output Of the File Size By default, the file sizes are listed as kilobytes. You can change the block size to other values as follows: du -BM For example, a file called zorin.iso, which, by default, is 1630535680 in size. du -BM zorin.iso The above command outputs the size as 1556M. You can also use K or G as follows: du -BK zorin.isodu -BG zorin.iso In kilobytes, the zorin.iso file is listed as 159232K. In gigabytes, the zorin.iso file is listed as 2G. There are eight possible settings, which are as follows: K: KilobytesM: MegabytesG: GigabytesT: TerabytesP: PetabytesE: ExabytesZ: ZettabytesY: Yottabytes If you get a list of files, getting the correct display size is difficult. For example, a file of 100 bytes needs to be displayed as bytes. A file that is 16 gigabytes is better shown in gigabytes. To get the appropriate file size based on the file being displayed, use one of the following commands: du -hdu --human-readable Summarise the Output To get the du command to show the total size of the files and folders, use the following commands: du -cdu --total You can also eliminate most of the other output, such as the listing of files and folders, by using the following commands: du -sdu --summarize Summary You can find out more about the du command by running the man command in the terminal as follows: man du Another command you may wish to read about is the df command. This command reports the file system and disk space usage.