×

df Command in Linux/Unix with Examples

The 'df' command in Linux is used to display the amount of disk space available on the file system. The command reports the amount of disk space used and available on all mounted file systems, including local and remote file systems. The basic syntax for the 'df' command is:

df [options] [file-system]

Where "options" are any optional flags or settings that you want to use, and "file-system" is the specific file system that you want to check the disk space for.

One of the most basic and common uses of the 'df' command is to display the disk space usage for all mounted file systems. For example, to display the disk space usage for all mounted file systems, you would use the command:

df

The above command shows the disk usage of all mounted filesystems. The output will include the filesystem name, total size, used space, available space and percentage of used space.

Another common usage of the 'df' command is to display the disk space usage for a specific file system. For example, if you want to check the disk space usage of the '/dev/sda1' file system, you would use the command:

df /dev/sda1

The 'df' command also provides options to specify the units of measurement for the output, such as bytes, kilobytes, megabytes, and gigabytes. The '-h' option can be used to display the output in "human-readable" format. This will make the output more readable and easy to understand by showing the sizes in a more user-friendly format.

It's important to note that, when using the 'df' command, it's important to be careful with the options you're using and the file systems you're checking. A small typo or mistake in the options can cause unexpected results and even data loss. It's also important to test the command on a small set of data before applying it to a large set of data.

Additionally, it's worth noting that the 'df' command only shows the usage of the file systems that are currently mounted. If you want to check the usage of a file system that is not currently mounted, you can use the 'du' command which shows the disk usage of a directory and its subdirectories. This command can be useful to check the disk usage of a specific directory, and it can also be used to find large files and directories that are taking up a lot of space.

Another important command related to disk usage is 'df -i' which shows the number of inodes used and available on a file system. Inodes are data structures used by file systems to keep track of files and directories, and inode usage can indicate if a file system is running out of inodes, which would prevent the creation of new files.

In addition to these command line tools, there are also graphical tools available for monitoring disk usage on Linux systems, such as 'gnome-disks' and 'baobab'. These tools provide a graphical interface for managing disk space and can be useful for visualizing disk usage and identifying large files and directories that are taking up a lot of space.

In summary, the 'df' command is an essential tool for managing disk space on Linux systems, but it should be used in conjunction with other tools such as 'du' and 'df -i' to get a full picture of disk usage. Additionally, graphical tools such as 'gnome-disks' and 'baobab' can be useful for visualizing disk usage. It is important to regularly check the disk usage of your system and to take action if the disk usage is too high, to prevent running out of space. With a good understanding of how these commands work and their implications, you will be able to efficiently and effectively manage disk space on your Linux systems.


Related Topics

mkdir Command in Linux/Unix with Examples

The "mkdir" command in Linux (and other Unix-like operating systems) is used to create new directories. The "mkdir" command stands for "make directory" and it is used to create a...

3 minutes read.

touch Command in Linux/Unix with Examples

The "touch" command in Linux (and other Unix-like operating systems) is used to create new empty files or update the timestamps of existing files. The touch command is a simple...

4 minutes read.

man Command in Linux/Unix with Examples

The man command in Linux is used to display the manual pages for a given command or system call. These manual pages provide detailed information on the command's usage, options,...

3 minutes read.

Linux Commands List

Linux Commands List The Linux systems are filled with commands for several use cases. We have divided these commands into some of the most common implementations for a better understanding of...

2 minutes read.

Rename Folder in Linux

Rename Folder in Linux In the Linux system, there is not any single dedicated command for renaming the files and directories. Mostly, the mv command is used extensively for the purpose...

3 minutes read.

Linux Distributions

Linux Distributions Linux OS is not like other operating systems. Linux can be modified according to the user’s requirements, and it is very flexible to any change. Linux distributions are often...

4 minutes read.

sudo Command in Linux/Unix with Examples

The sudo command in Linux is used to run a command or set of commands with the privileges of another user, typically the root user. This allows users to perform...

3 minutes read.

echo Command in Linux/Unix with Examples

The "echo" command in Linux is used to display a line of text on the terminal. It can also be used to print the value of a variable or to...

3 minutes read.

du Command in Linux/Unix with Examples

The "du" command in Linux (and other Unix-like operating systems) is used to estimate the space used by a file or directory. The du command stands for "disk usage," and...

4 minutes read.

Linux rmdir command

The default use case of the rmdir command in the Linux system is to delete an empty directory. The below screenshot shows how to delete the empty directory. First, we...

1 minute read.

ls Command in Linux/Unix with Examples

The ls command in Linux is a command-line utility that is used to list the files and directories in a directory. It is one of the most basic and commonly...

4 minutes read.

sed Command in Linux/Unix with Examples

The 'sed' command in Linux is a powerful text processing tool that allows you to perform various operations on text files, such as searching, replacing, and manipulating text. The command...

3 minutes read.

ps Command in Linux/Unix with Examples

The 'ps' command in Linux is used to display information about the running processes on a system. The command stands for "process status" and it allows you to view details...

4 minutes read.

Linux apt-get command

Apt-get is a command-line that helps to handle the packages in Linux. Its major task is to assist in retrieving data and packages from trusted sources for purposes of installation,...

6 minutes read.

Linux Commands with Examples

Linux Commands with Examples All the Linux commands are executed on the terminal provided by the Linux system. This terminal is a command-line interface to implement and display command outputs. Linux...

10 minutes read.

apt-get Command in Linux with Examples

The apt-get command is a command-line tool that is used to handle packages in Linux. This command handles the processes like retrieving the packages and information from authentic sources for...

5 minutes read.

How to change the ApacheHTTP port in Linux

What is an Apache HTTP server in Linux? When we talk about the most commonly used web servers, one of the web servers that cannot be missed is Apache. With the...

4 minutes read.

rm Command in Linux/Unix with Examples

The "rm" command in Linux (and other Unix-like operating systems) is used to remove files and directories. The "rm" command stands for "remove" and it is used to delete files...

4 minutes read.

curl Command in Linux/Unix with Examples

The 'curl' command in Linux is a command-line tool that allows you to transfer data from or to a server using various protocols, including HTTP, HTTPS, FTP, and many more....

3 minutes read.

Linux Path Completion

Every operating system has some features which make them special. The Linux operating system primarily works on the command line interface, and we do have many features for this CLI....

1 minute read.