Detailed explanation of common disk management commands in Linux

from

The du command is used to view the used space on disk for files and directories.

Command syntax:du [参数] [文件或目录名称]

Parameter Description:

parameter illustrate
-a List all file and directory capacities.
-h Returns the capacity in units of G, M, K.
-s List the total.
-S List totals excluding subdirectories.
-k Returns the capacity in KBytes.
-m Returns the capacity in MBytes.

Example of use:

  1. List the capacity of all folders under the current directory.
du

The effect is as follows:

  1. List the capacity of all folders and files in the current directory.
du -a

The effect is as follows:

  1. List the capacity of all folders and files in the current directory, and display the capacity in G, M, K format.
du -ah

The effect is as follows:

  1. List the capacity occupied by each directory under the root directory, and display the capacity in MBytes.
du -sm /*

The effect is as follows:

df

The df command is used to view the disk space usage of the file system.

The difference between the df command and the du command is that the df command is used to view the disk space usage of the entire file system, and the du command is used to view the disk space usage of files and directories.

Command syntax:df [参数] [目录或文件名]

Parameter Description:

parameter illustrate
-a List all file systems, including system-specific file systems such as /proc.
-k Returns the capacity of each file system in KBytes.
-m Returns the capacity of each file system in MBytes.
-h Returns the capacity of each file system in GBytes, MBytes, and KBytes.
-H Display the capacity of each file system with M=1000K instead of M=1024K.
-T Displays the file system type.
-i Display inode information.

Example of use:

  1. Display disk usage.
df

The effect is as follows:

  1. Display disk usage in inode mode.
df -i

The effect is as follows:

  1. Displays all special file formats, names and disk usage in the system.
df -aT

The effect is as follows:

  1. Display the capacity of each file system in GBytes, MBytes, KBytes and other formats.

Run the following command to display the capacity of each file system in GBytes, MBytes, KBytes and other formats.

df -h

The effect is as follows:

fdisk

The fdisk command is used for disk partitioning.

Command syntax:fdisk [-l] 装置名称

After the parameter is used -l, all the partition contents of the following device name are output. If there is only fdisk -l, the system will list all the partitions of the device that can be searched in the whole system.

Example of use:

  1. List partition information for all devices in the system.
fdisk -l

The effect is as follows:

  1. List the disk where the root directory in the system is located, and check the related information in the hard disk.

Execute the following command to find out the name of the disk where the root directory is located:

df /

The effect is as follows:

Run the following command to partition the disk /dev/vda.

fdisk /dev/vda

Tips: When partitioning a disk, the disk name does not contain numbers.

The effect is as follows:

Enter mfor help.

The effect is as follows:

The specific command meanings are as follows:

Order meaning
a Set bootable flags
b Edit bsd disk label
c Set the DOS operating system compatibility flag
d delete a partition
g Create an empty GPT partition table
G Create an IRIX partition table
1 Show known filesystem types
m show help menu
n New partition
O Create a blank DOS partition table
p Show partition list
q Exit without saving
s Create a new blank SUN disk label
t Change the system ID of a partition
u Change the display record unit
v Verify partition table
w save and exit
x Additional Features (Experts Only)

Enter pView disk status.

The effect is as follows:

Enter qdoes not store any actions and leaves.


I have already seen this, you and I must be destined people, leave your likes and attention , and he will become a great thing in the future.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324155905&siteId=291194637