Hello, I’m Liang Xu.

Hard disk is a very important part of the computer, whether it is code, or UI, sound, documents, or is no one secretly watching a small video, all need to be saved in the hard disk.

For many Linux servers, a lot of compilation is done. Compilation operations in many cases produce a large number of intermediate files, which take up a lot of disk space and cause disk space to be stretched.

Don’t ask why I know, said more are tears.

This article describes several commands, some disk-related and some file-related, to help you analyze disk usage and free up disk space.

ls -al

The familiar command displays detailed information about all files and directories in the current directory, which files occupy more disk space in the current directory. Well, it’s even better if you add the -h option.

stat

The stat command displays more detailed information about a given file/directory, including size, block, inode, creation/access/modification time, and so on.

df

The df command is short for disk free and is used to display the available disk space. The most common options are:

  • df -h: Displays the available disk space in a user-friendly manner.
  • df -a: Displays complete disk usage, including disk areas with 0 free space.

  • df -T: Displays disk usage by file system type, such as XFS, ext2, ext3, BTRFS, and so on.
  • df -i: Displays used and idle inodes.

In addition to using the command line, you can also use a graphic tool called disks. Using this tool, you can see the disk usage very intuitively.

2020 selected Ali/Tencent and other front-line big factory interview, resume, advanced, e-book public number “Liang Xu Linux” background reply “information” free access

du

Du is short for the English phrase Disk useage. It shows the usage of elements such as files and directories on a disk. Common uses are as follows:

  • du -h: Display the usage of all directories and subdirectories in a human-readable format;
  • du -a: Displays the disk usage of all files in the current directory.
  • du -s: Displays only the total value and lists only the final sum. (Used to display directory size)

fdisk -l

Fdisk is a program that creates and maintains partition tables, compatible with DOS type partition tables, BSD, or SUN type disk lists. The fdisk -l command displays information about disk partitions.

Those of you who have played around with partition tables should be familiar with this step, and then you can create, delete, modify, and other related operations. But in this case, we just use the -L option to take a look at the current partition and do nothing further.

Don’t use any of fdisk’s other options if you don’t know how to partition. It can cause devastating damage, and it may be too late to run away

summary

This section describes several commands related to file size and disk space. You can use these commands to learn about disk information and provide reference for disk clearing. Using these commands properly, you can slim down your disk

All you see is true love. Why don’t you like it before you leave? Your “sanlian” is the biggest motivation for liang Xu’s continuous creation!

  1. Pay attention to the original public number “good Xu Linux”, the first time to get the latest Linux dry goods!
  2. Public number background reply [information] [interview] [resume] to get selected first-line big factory interview, self-improvement, resume and other information.
  3. Follow my blog: lxLinux.net