Compilation of common commands for Linux VPS disk space analysis and cleaning

888u

Last update at :2024-03-20,Edit by888u

Generally speaking, the hard drives of the entry-level Linux VPS we buy are not large. Some merchants’ entry-level packages are even only 10GB in size. Today, this site will compile a few common commands for Linux disk virtual host analysis and cleaning to help Everyone deletes some useless files and frees up the virtual host.

1. Common commands for Linux disk virtual host management

Generally speaking, we will use two commands when analyzing Linux disk virtual hosts: df and dh, and rm when cleaning up disk virtual hosts. Here is an introduction to each.

1. df command

The df command is used to check the disk usage of the file system. It is generally used to check the size of the first-level folder, usage ratio, file system and its mount point.

Commonly used parameters:

  • -h: Indicates using "Human-readable" output, that is, using easy-to-read formats such as GB and MB in the file system size.
  • -a: Display the disk usage of all file systems, including 0-block (block) file systems, such as /proc file system.
  • -k: Display in k bytes.
  • -i: Display i node information instead of disk blocks.
  • -t: Display the disk virtual host usage of each specified type of file system.
  • -x: Lists the usage of disk virtual hosts that are not file systems of a specified type (opposite of the t option).
  • -T: Display file system type.

2. dh command

The du command checks the disk virtual host occupancy. Generally, users check the size of the disk virtual host occupied by a directory or file.

Commonly used parameters:

  • -h: Display in human readable form.
  • -a: Display the size of the disk virtual host occupied by the directory, and also display the size of the disk virtual host occupied by the directories and files under it.
  • -s: Only the disk virtual host size occupied by the directory is displayed, and the disk virtual host size occupied by its subdirectories and files is not displayed.
  • -c: Display the disk virtual host size occupied by several directories or files, and also count their sum.
  • –apparent-size: Display the size of the directory or file itself.
  • -l: Statistics of the size of the disk virtual host occupied by hard links.
  • -L: Statistics of the disk virtual host size occupied by the file pointed to by the symbolic link.

3. rm command

The rm command is a delete command. There are three commonly used methods:

  • Delete files: rm file1 file2
  • Delete folder: rm -rf dir
  • Remove all: rm -rf *

2. Linux disk virtual host cleaning example

The following will share an example of using df, dh and rm to analyze Linux disks.

1. Use the df command to check disk usage

Command: df -h

Here you will see the total capacity, used capacity, used percentage and mount path of the currently available disk:

2. Use the du command to analyze the disk usage of the specified directory

Command: du -h --max-depth=1 /

View the directory and file size under the / path:

As you can see from the picture above, /root mainly occupies the virtual host, so continue to check: du -h --max-depth=1 /root:

Here you can locate that the files in the /root/backup directory occupy a lot of virtual hosts.

3. Use the rm command to delete junk files

Command: rm -rf *

Enter /root/backup and delete all files or unnecessary files. The above command will delete all files in this directory. For more usage, please refer to the introduction in the first part.

Recommended site search: multi-ip station group server, anti-complaint server, website space domain name, Hong Kong server rental 99idc, high-defense US server, independent IP virtual host, US server rental, vps server, Hong Kong server hosting, US server,

Compilation of common commands for Linux VPS disk space analysis and cleaning

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码