Linux check disk space with df command
- Open the terminal and type the following command to check disk space.
- The basic syntax for df is:
df [options] [devices]
- df -H
Check disk space with du command
The du command is very useful to track down disk space. It is useful to find out the names of directories and files that consume large amounts of space on a disk. The basic syntax is:
- du /path/do/dir
- du [options] [directories and/or files]
- du -h
How do I summarize disk usage for given directory name?
Pass the -s option to the du command. In this example, ask du command to report only the total disk space occupied by a directory tree and to suppress subdirectories:
Check disk space usage with Ncdu
Ncdu is a command line tool to view and analyse disk space usage on linux. It can drill down into directories and report space used by individual directories. This way it is very easy to track down space consuming files/directories. It actually allows the user to do this much faster than even a GUI file manager.
Ncdu vs du/df
The interface of ncdu is built using ncurses and is interactive. Ncdu is different from df or du.
Ncdu just does the one task of reporting the space used by a directory and drill down. On the other hand the df command reports space used by different storage devices.
The du command is rawer in nature and reports space used by individual files and recursively into subdirectories. Due to this, the output is huge and very cumbersome. The du command needs to be passed few options and combined with other commands via pipes to produce something readable.
Sometimes it is not installed by default