×

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

rename Command in Linux/Unix with Examples

The rename command in Linux is used to rename multiple files at once, using a specified pattern. The command is also known as rename, ren, and mv. This command is...

3 minutes read.

ping Command in Linux/Unix with Examples

The "ping" command in Linux (and other Unix-like operating systems) is used to test the connectivity between two networked devices. The "ping" command sends a small packet of data, called...

4 minutes read.

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.

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.

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.

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.

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.

Top 20 Linux Commands

1) clear command clear is a standard operating system command which is used to clear the terminal screen. This command brings the command line on the top of the terminal. By pressing the...

10 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.

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.

scp Command in Linux/Unix with Examples

The scp (secure copy) command in Linux is a command-line utility that is used to securely transfer files between two hosts over a network. It is similar to the cp...

4 minutes read.

tar Command in Linux/Unix with Examples

The 'tar' command in Linux is used to create, maintain, and extract files from archive files called tarballs. The command stands for "tape archive" and it allows you to combine...

4 minutes read.

Linux ls

The primary use case of the ls command is to list the content available in the directory. The default directory is the current directory of the user. The below screenshot...

5 minutes read.

ssh Command in Linux/Unix with Examples

The ssh (Secure Shell) command in Linux is used to remotely access and control another computer or device over a network. It provides a secure and encrypted connection between the...

6 minutes read.

awk Command in Linux/Unix with Examples

The 'awk' 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...

4 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.

adduser Command in Linux with Examples

What is the adduser command? The adduser command creates a new user, and this command may be used to add apre-existing user to a group that already exists. How to use the...

4 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.

telnet Command in Linux/Unix with Examples

The telnet command in Linux is a command-line utility that allows you to connect to a remote host using the Telnet protocol. Telnet is a network protocol that provides a...

3 minutes read.

Linux Absolute and Relative Path

The concept of the absolute and relative path is very simple. The names “relative path” and “absolute path” give us little understanding of the concept we are learning here. The...

1 minute read.