Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check the status information of disk and directory under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to view the disk and directory status information under Linux, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The use of two commands on a linux system-the df and du,df commands can view disk usage information on a file system, and du can be used to view the size of a file or directory.

Df

Usage: df [option]

Common options:

-a shows all file systems

-h is displayed in a readable manner

-I do not show disk capacity, but the number of inode used to show

-T display file system

Let's do a demonstration.

1. Do not add any parameters

# dfFilesystem 1K-blocks Used Available Use% Mounted ondevtmpfs 3986648 0 3986648 / devtmpfs 3999984 0 3999984 / dev/shmtmpfs 3999984 528 3999456.1 / runtmpfs 3999984 039999840 / sys/fs/cgroup/dev/vda1 41931,756 19293976 22637780 47% / dev/vdb1 52403200 476572 519266281 / data/dev/vdb2 104806400 27960008 76846392 27% / wwwtmpfs 799996 07999996% / run/user/0

two。 Add the-h option

You can get the disk usage of each mount point, but it is not too easy to read. Let's add the-h option to see the effect.

# df-hFilesystem Size Used Avail Use% Mounted ondevtmpfs 3.9G 0 3.9G 0 / devtmpfs 3.9G 0 3.9G 0 / dev/shmtmpfs 3.9G 528K 3.9G 1% / runtmpfs 3.9G 03.9G 0 0% / sys/fs/cgroup/dev/vda1 40G 19G 22G 47% / / dev/vdb1 50G 466m 50G 1% / data/dev/vdb2 100G 27G 74G 27% / wwwtmpfs 782M 0782m 0% / run/user/0

3. Add the-T option

We also want to know what kind of file system the mount point is using, so we need to add the-T option

# df-hTFilesystem Type Size Used Avail Use% Mounted ondevtmpfs devtmpfs 3.9G 0 3.9G 0 / devtmpfs tmpfs 3.9G 0 3.9G 0 / dev/shmtmpfs tmpfs 3.9G 528K 3.9G 1% / runtmpfs tmpfs 3.9G 0 3.9G 0 0 / sys/fs/cgroup/dev/vda1 xfs 40G 19G 22G 47% / dev/vdb1 xfs 50G 466M 50G 1% / data/dev/vdb2 xfs 100G 27G 74G 27% / wwwtmpfs tmpfs 782M 0782M 0% / run/user/0

4. Add the-I option

If we want to see inode usage, then we need to use the-I option

# df-ihFilesystem Inodes IUsed IFree IUse% Mounted ondevtmpfs 974K 359 973K 1% / devtmpfs 977K 1 977K 1 / dev/shmtmpfs 977K 562 977K 1% / runtmpfs 977K 17 977K 1% / sys/fs/cgroup/dev/vda1 20m 188K 20m 1% / / dev/vdb1 25M 4 25m 1% / data/dev/vdb2 50m 494K 50M1 / wwwtmpfs 977K 5977K1 / run/user/0

In addition to the options above, df has a very useful small feature that lets you see which file system a file belongs to.

# df / etc/my.cnfFilesystem 1K-blocks Used Available Use% Mounted on/dev/vda1 41931756 19294292 22637464 47% /

Du

Like df, du is a command that will be used frequently. Sometimes, but the server disk is almost full and we need to clean up the large files that we don't need, so we need the du command.

Usage: du [option] file or directory name

Common options are as follows:

-a displays all file sizes

-h is displayed in an easy-to-read manner.

-s displays only totals

-S displays the directory size, but does not include the size of the subdirectory

# display file size # du-h wp-fastest-cache.0.9.0.7.zip 456K wp-fastest-cache.0.9.0.7.zip# displays the directory size, and all files in this directory will be displayed by default. If you only want to display the directory size, you need to add the-s option # du-sh / root114M / root# displays the total file size under the directory, excluding the subdirectory # du-sSh / root84M / root.

Here's a very common scenario: the system disk is almost full and needs to be cleaned up.

First, we use the df command to see which filesystem space is running out. After navigating to the mount point, use the du command, layer by layer directory, to check the directory size using the du command, and navigate to the directory that takes up the most space. Then look at the files that can be deleted in this directory and delete them.

The above is all the contents of how to view the disk and directory status information under Linux. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report