Determining Disk Usage
The du command shows the estimated disk space used by files and directories. If you execute du without any options it will output the sizes of all files starting in your current directory and all subdirectories of your current directory.
Find out how much disk space the /home directory is using with the summarize (-s) and human readable (-h) options:
$ du -sh /home 1.1G /home
Adding the no subdirectories (-S) option shows only the disk space used by files in the /home directory without counting files in subdirectories of /home:
$ du -sSh /home 201M /home
Disk Usage
The df command shows how much space each filesystem is using on the disk and where it is mounted. Using the -i options shows inode usage instead of free space. Each file on the system uses an inode. Running out of free space or inodes will cause serious problems and you should add more disk space to the system if either is in danger of running out!
# df -hi / Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 20M 105K 20M 1% /
With the type (-T) and the human readable (-h) option df shows the filesystem type, and counts sizes in megabytes and gigabytes:
# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/xvda1 xfs 20G 5.3G 15G 27% / devtmpfs devtmpfs 892M 0 892M 0% /dev tmpfs tmpfs 919M 0 919M 0% /dev/shm tmpfs tmpfs 919M 17M 903M 2% /run tmpfs tmpfs 919M 0 919M 0% /sys/fs/cgroup tmpfs tmpfs 184M 0 184M 0% /run/user/1001
Disk Quotas
Linux provides the quota system to control disk usage among users. The quota command, when typed alone at the command line, will show how close you are to your limits. There are hard and soft limits. Depending on system policy, a warning can be sent when you go over a soft limit, and often there is a grace period to allow you time to complete work and then erase or move files so that your disk usage falls back under the soft limit. You may never exceed a hard limit. Quotas may be set on users or groups.
It is important to note that quotas can enforce not only the amount of disk space that a user can use, but also the number of files that a user can create.
The root user may also use the quota command to check on the usage of other users by typing quota -u username at the command line.