CentOS 7 check disk space

How to check hard disk size in CentOS

CentOS is a Linux-based operating system mainly used for server-side applications. In server management, hard disk size is a very important indicator. Checking the hard disk size can help system administrators effectively manage hard disk space and prevent the hard disk from becoming full.

Method 1: Use the df command

The df command is a commonly used command in Linux for viewing file system disk space. You can check the hard disk size through the following command:
Some are shown below 内联代码片.

df -h

In CentOS 7, you can use the df command to view disk space usage. Here are some common options for using the df command:
-h: Display the disk space in a human-readable format (for example, using units such as GB, MB, etc.).
-T: Display the file system type.
-i: Display the usage of inode (index node).
-a: Display all file systems, including empty file systems.
-x <File system type>: Exclude file systems of the specified type.
The following are some commonly used example commands:
1. View the disk space usage of all mount points:

df -h

2. View the disk space usage of the specified mount point (for example, /dev/sda1):

df -h /dev/sda1

3. View the disk space usage of all file systems, including empty file systems:

df -a

4. View the disk space of the specified file system type```df -h -T ext4
请注意,磁盘空间的使用情况会随着时间变化,因此建议在需要时多次运行 df 命令以获取最新的信息。

Method 2: Use the fdisk command

The fdisk command is a tool used to process hard disk partitions. You can check the hard disk size through the following command:

fdisk -l

This command will display the detailed partition status of all connected disks, including the total capacity of the disk, partition size, partition type and other information. It should be noted that this command needs to be executed with root user privileges.

Method 3: Use the Isblk command

The lsblk command is a tool that lists block device information. You can check the hard disk size with the following command:

lsblk

This command will list relevant information about all block devices connected to the system, including name, capacity, mount point, etc. It should be noted that the output results may be compact and require appropriate printing format processing.

Summarize

The above three methods can all check the hard disk size of CentOS, which is very useful for server management. When using these commands, you need to pay attention to user permissions and output formats for better server management.

Guess you like

Origin blog.csdn.net/feritylamb/article/details/132147674