There are several ways to check disk space on a Linux system. Here are a few common methods:
1. Using the df
Command
The df
command (disk free) provides a concise overview of the mounted file systems and their available space.
Example:
df -h
This command displays the disk usage in a human-readable format (with units like 'K', 'M', 'G').
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 49G 28G 21G 58% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 16M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sdb1 99G 13G 86G 14% /mnt/data
The output shows the file system, total size, used space, available space, percentage used, and mount point.
2. Using the du
Command
The du
command (disk usage) calculates the disk space used by files and directories.
Example:
du -sh /home/user/
This command displays the total disk space used by the /home/user/
directory in a human-readable format.
Output:
2.1G /home/user/
3. Using Graphical Disk Usage Analyzers
Several graphical tools are available for visualizing disk usage. Some popular options include:
- Disk Usage Analyzer (DUA): A simple and intuitive tool that offers a graphical representation of disk usage.
- KDE Partition Manager: A powerful tool that allows you to manage partitions, format disks, and analyze disk usage.
- GNOME Disks: A user-friendly tool for managing disks, partitions, and filesystems.
These tools provide a more visual and interactive way to understand disk space utilization.
4. Checking Specific Files or Directories
You can also use the ls
command with the -l
option to check the size of specific files or directories:
ls -l /path/to/file
This command displays detailed information about the file, including its size.
5. Using the stat
Command
The stat
command provides detailed information about files and directories, including their size.
stat -c %s /path/to/file
This command displays the size of the file in bytes.
By using these methods, you can efficiently check disk space usage on your Linux system and identify areas where you might need to free up space.