How Do I View Disk Usage on a Linux System?

Mondo Technology Updated on 2024-03-07

In Linux, it is very important to understand and manage disk usage, which can help us free up disk space, manage files, and improve system performance. How do I check disk usage on a Linux system? The following is an introduction to the commonly used methods.

1. Use the df command

The df command is a commonly used command that displays disk space usage. You can check the disk usage by entering the following command in the terminal:

df -h: This command displays the disk usage of each mount point in the system, including the total disk capacity, used capacity, available capacity, and mount point.

If you want to view the disk usage of a specific mount point, you can run the following command:

df -h /dev/sda1

2. Use the du command

The du command can be used to view the disk space occupied by a specified directory or file. You can view the disk usage of each folder in the current directory by entering the following command in the terminal:

du -hThis command will recursively display the disk usage of each folder in the current directory in a human-readable manner.

If you want to see the disk usage of a specific directory or file, you can use the following command:

du -h Directory or File Path

3. Use the ncdu command

NCDU is an interactive disk usage viewing tool that makes it easier to view the usage of individual files and directories on a disk. NCDU can be installed with the following command:

sudo apt-get install ncdu(debian/ubuntu)

sudo yum install ncdu(cenos/rhel)

Once the installation is complete, you can use NCDU by entering the following command in the terminal:

ncduncdu will display the usage of files and directories on the disk in an interactive interface, and users can perform operations through the keyboard, such as viewing file size, deleting files, etc.

Related Pages