CommandsLinux

How To Check Disk Space on Linux: Simple Steps for Better Disk Management

Check Disk Space on Linux

In the world of Linux, checking disk space is an essential task for any system administrator. Knowing how much space is available and how it’s being used is crucial for keeping a system running smoothly and avoiding potential data loss or downtime. Fortunately, Linux offers several tools and methods for checking disk space, including command-line utilities and graphical disk usage analyzers. In this post, we’ll explore the most common and effective ways to check disk space on Linux, including the df and du commands, as well as some popular GUI disk usage analyzers. We’ll also cover some best practices for monitoring disk space, optimizing usage, and avoiding common pitfalls. So, whether you’re a Linux novice or a seasoned pro, read on to learn how to check disk space on Linux and keep your system running smoothly.

Check Disk Space on Linux

  • Using the df Command.

The df command “disk free” is a popular command-line utility that displays the amount of available and used disk space on the file system. It is a simple and efficient way to check disk space on Linux.

To use the df command, open a terminal window and type in the following command:

df -h

Output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       512G   46G  466G  14% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            1.7G  6.0K  1.9G   1% /dev
tmpfs           384M  6.7M  379M   2% /run
none            8.0M     0  5.0M   0% /run/lock
none            1.9G  160M  1.8G   9% /run/shm
none            101M   48K  101M   1% /run/user
/dev/sda5       179G   36G  135G  21% /Data
/dev/loop0       92M   92M     0 100% /snap/core/8592
/dev/loop1      174M  174M     0 100% /snap/skype/112
/dev/loop2       95M   95M     0 100% /snap/core/8689
/dev/loop3       43M   43M     0 100% /snap/gtk-common-themes/1440
/dev/loop4       52M   55M     0 100% /snap/core18/1668
/dev/loop5      164M  164M     0 100% /snap/skype/115
/dev/loop6      141M  141M     0 100% /snap/gnome-3-28-1804/116
/dev/loop7       57M   57M     0 100% /snap/teams-for-linux/79

The “-h” option displays the disk space usage in a human-readable format. The output of the df command shows the file system’s name, total size, used space, available space, and percentage of space used. It also shows the file system’s mount point, which is the directory where the file system is mounted. It is essential to understand the mount point of the file system, as it helps to identify which file system is associated with which directory.

  • Using the du Command

The du command is another popular command-line utility that is used to display the disk usage of files and directories on the file system. It is a more detailed way to check disk space on Linux.

To use the du command, open a terminal window and type in the following command:

du -h /path/to/directory

Output:

308K    ./.anydesk/thumbnails
1.2M    ./.anydesk
182K    ./.gftp
4.0K    ./.xx-svn-diff
4.0K    ./Public
4.0K    ./.local/share/folks
13K     ./.local/share/data/Owncloud
14K     ./.local/share/data
3.0K    ./.local/share/gstreamer-1.0/presets
6.0K    ./.local/share/gstreamer-1.0
20K     ./.local/share/unity-webapps
6.0K    ./.local/share/vlc
6.0K    ./.local/share/evolution/calendar/trash
9.0K    ./.local/share/evolution/calendar/system
36K     ./.local/share/evolution/calendar

The “-h” option displays the disk usage in a human-readable format. This makes it easier to understand the output. Replace “/path/to/directory” with the directory, you want to check disk space.

  • GUI Disk Usage Analyzers

GUI disk usage analyzers provide a visual representation of disk usage and allow users to navigate through the file system and see how much space each directory and file is using. Some popular GUI disk usage analyzers for Linux include:

  1. Baobab (GNOME Desktop Environment)
  2. KDirStat (KDE Desktop Environment)
  3. Filelight (KDE Desktop Environment)

GUI disk usage analyzers have the advantage of providing a graphical representation of disk usage, making it easier to interpret. However, they may not be available on all systems and may not provide the same level of detail as the df and du commands.

Best Practices for Checking Disk Space

It is recommended to check disk space regularly, preferably once a week. This will help you to identify any potential issues before they become a problem.

When checking disk space, it is essential to look for low disk space on critical file systems, such as the root file system. You should also look for large files or directories that can be moved to an external hard drive or removed altogether. This will help to free up space on your system and ensure that it continues to function correctly.

Tips for Managing Disk Space

To manage disk space effectively, it is recommended to:

  • Remove unnecessary files or directories regularly: Deleting files and directories that you no longer need can free up significant amounts of disk space.
  • Consider moving large files or directories to an external hard drive: Moving large files or directories that you don’t need on a day-to-day basis to an external hard drive can free up space on your system.
  • Use compression: Compressing files can help to save disk space. This is particularly useful for files that are rarely accessed.
  • Monitor disk usage regularly: Monitoring disk usage regularly will help you to identify any sudden increases in disk usage. This can be an early indicator of potential issues with your system.

Conclusion

In conclusion, checking disk space on Linux is an essential task that should be performed regularly to ensure the system and applications function correctly. The df command, du command, and GUI disk usage analyzers are three different methods available to check disk space on Linux. GUI disk usage analyzers provide a graphical representation of disk usage, while the df and du commands provide a detailed summary of disk usage. To manage disk space effectively, it is recommended to check disk space regularly, remove unnecessary files or directories, and monitor disk usage regularly. By following these best practices, users can ensure that their Linux system is running smoothly and efficiently.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button