Home  >  Article  >  Operation and Maintenance  >  How to check the disk usage of Linux system?

How to check the disk usage of Linux system?

WBOY
WBOYOriginal
2024-02-26 15:01:16813browse

How to check the disk usage of Linux system?

Title: How to check disk usage in Linux?

In Linux systems, checking disk usage is one of the common operations for administrators and users. Understanding disk usage can help users free up disk space, manage files, and improve system performance in a timely manner. This article will introduce how to check disk usage in Linux systems and provide specific code examples.

1. Use the df command

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

df -h

This command will display the disk usage of each mount point in the system, including the total disk capacity, used capacity, available capacity and mount point.

If you only want to check the disk usage of a specific mount point, you can use the following command:

df -h /dev/sda1

2. Use the du command

The du command can be used to check Specifies the disk space occupied by the 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 -h

This command will recursively display the disk usage of each folder in the current directory in human-readable format. way to display.

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

du -h <目录或文件路径>

3. Use the ncdu command

ncdu is an interactive Disk usage viewing tool makes it easier to view the usage of various files and directories on the disk. You can install ncdu through the following command:

sudo apt-get install ncdu (Debian/Ubuntu)
sudo yum install ncdu (CentOS/RHEL)

After the installation is complete, you can enter the following command in the terminal to use ncdu:

ncdu

ncdu will display the files and directories on the disk in an interactive interface Occupancy status, users can perform operations through the keyboard, such as checking file size, deleting files, etc.

Summary:

Through commands such as df, du and ncdu, users can easily check the disk usage in the Linux system and take timely measures to release disk space. Proficient in these commands can help users better manage the system and ensure the normal operation of the system. I hope the above content is helpful to readers.

The above is the detailed content of How to check the disk usage of Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn