Home  >  Article  >  How to check disk space in linux

How to check disk space in linux

zbt
zbtOriginal
2023-06-30 17:10:5133020browse

How to check the disk space in Linux: 1. First log in to the Linux service; 2. Open the system control panel, and then enter the system command "df"; 3. Use the command "df -lh" for more details 4. If you use the command "df -a", it will display the usage and remaining status of all hard disks.

How to check disk space in linux

How to check the disk space in Linux?

1. To check the remaining space of the hard disk, you must first log in to the Linux service

How to check disk space in linux

#2. Open the system control panel, and then enter the system command "df", as shown in the figure

How to check disk space in linux

3. Use the command "df -lh" to display the disk usage in more detail

How to check disk space in linux

4. If you use the command "df -a", it will display the usage of all hard disks. and the remaining situation, as shown in the figure

How to check disk space in linux

Reference Technology A

Ubuntu Check the disk space size command df -h The Df command is the unit of disk partition in Linux system To view the file system, you can add parameters to view the remaining disk space information. The command format is: df -hl The display format is: File system capacity Used Available Used % Mount point Filesystem Size Used Avail Use% Mounted on /dev/hda2 45G 19G 24G 44% / /dev/hda1 494

df -h

The Df command is a Linux system that views the file system in units of disk partitions. You can add parameters to view the disk. Remaining space information, command format:

df -hl

The display format is:

File system capacity used, available, used % mount point

Filesystem Size Used Avail Use% Mounted on

/dev/hda2 45G 19G 24G 44% /

/dev/hda1 494M 19M 450M 4% /boot

/dev/ hda6 4.9G 2.2G 2.5G 47% /home

/dev/hda5 9.7G 2.9G 6.4G 31% /opt

none 1009M 0 1009M 0% /dev/shm

/dev/hda3 9.7G 7.2G 2.1G 78% /usr/local

/dev/hdb2 75G 75G 0 100% /

/dev/hdb2 75G 75G 0 100% /

Take the above output as an example, it means:

The second hard disk (b) of the HD hard disk interface, the second partition (2), the capacity is 75G, use 75G, available is 0, so the utilization is 100%, and is mounted on the root partition directory (/).

The following is an explanation of the relevant commands:

df -hl Check the remaining disk space

df -h Check the partition size of each root path

du -sh [directory name] returns the size of the directory

du -sm [folder] returns the total number of M in the folder

For more functions, you can enter the following command to view:

df --help

du --help

Reference Technology B

(1) View file size

View the size of all files in the current folder (Includes subfolders)

du -sh

# du -h

15M ./package

16K ./.fontconfig

4.0K ./.cache

5.1M ./.rpmdb

20M .

View the size of all files in the specified folder (including subfolders)

# du -h ftp

3.8G ftp/sanya/doc

3.8G ftp/sanya

4.0K ftp/testftp/doc

1.4M ftp/testftp

875M ftp/platform/doc/002-video

27M ftp/platform/doc/001-PDF

5.2M ftp/platform /doc/BBFlash

1.2G ftp/platform/doc/003-recording

2.1G ftp/platform/doc

2.1G ftp/platform

4.0K ftp/pmo/doc

20K ftp/pmo

36M ftp/uf/doc/innovate-201207

36M ftp/uf/doc

36M ftp/uf

446M ftp/code/doc

446M ftp/code

6.3G ftp

View the specified file size

# du -h ./package/compat-libstdc -33-3.2.3-69.el6.x86_64.rpm

184K ./package/compat-libstdc -33-3.2.3-69 .el6.x86_64.rpm

View the size of the specified folder

# du -hs ftp

6.3G ftp

Usage: du [option]. .. [file]...

or: du [option]... --files0-from=F

Calculate the disk usage of each file, and take the total usage of the directory.

The parameters that must be used for long options are also required for short options.

-a, --all Print disk usage for all files, not just directories

--apparent-size displays surface usage, not disk usage; although surface usage usually will

Smaller, but sometimes it becomes larger due to "holes" between sparse files, internal fragments, blocks that are not directly referenced, etc.

-B, --block-size=size blocks using the specified number of bytes

-b, --bytes equal to --apparent-size --block-size=1

-c, --total Display total information

-D, --dereference-args Dereference symbolic links listed on the command line

--files0-from=F Calculation The file name ending with NUL in file F corresponds to the disk space occupied

If the value of F is "-", the file name is read from the standard input

-H equals --dereference- args (-D)

-h, --human-readable Display the size in a more readable way (for example: 1K 234M 2G)

--si Similar to -h, but use 1000 as the base when calculating Non-1024

-k equals --block-size=1K

-l, --count-links If it is a hard link, calculate its size multiple times

- m equals --block-size=1M

-L, --dereference find the true destination indicated by any symlink

-P, --no-dereference do not follow any symlink (Default)

-0, --null Treat each empty line as 0 bytes instead of newline characters

-S, --separate-dirs Do not include subdirectory occupancy

-s, --summarize Only calculate the total usage of each parameter in the command line separately

-x, --one-file-system Skip being on a different file system Directory

-X, --exclude-from=file excludes files matching the pattern described in the specified file

--exclude=PATTERN excludes files matching the pattern described in PATTERN

--max-depth=N Display the total directory (used with --all to calculate files)

When N is the specified value, the calculated depth is N;

- -max-depth=0 is equivalent to --summarize

--time displays the last modification time of all files in the directory or subdirectories of the directory

--time=WORD displays the WORD time instead of Modification time:

atime, access, use, ctime or status

--time-style=The style displays the time according to the specified style (the style interpretation rules are the same as the "date" command):

full-iso, long-iso, iso, FORMAT

--help Display this help message and exit

--version Display version information and exit

[ Size] can be the following units (integers can be added before the unit):

kB 1000, K 1024, MB 1000000, M 1048576, and G, T, P, E, Z, Y.

Please report du errors to

GNU coreutils project homepage:

GNU software general help:

Please report du translation errors to

(2)Ubuntu check disk space size command

df -h The Df command is a Linux system that checks the file system in units of disk partitions. You can add parameters to check the remaining disk space information. The command format is: df -hl display format is: file system capacity Used Available Used% Mount Point Filesystem Size Used Avail Use% Mounted on /dev/hda2 45G 19G 24G 44% / /dev/hda1 494

df -h

#Df command is a Linux system to view the file system in units of disk partitions. You can add parameters to view the remaining disk space information. The command format is:

df -hl

The display format is:

File system capacity used, available, used% mount point

Filesystem Size Used Avail Use% Mounted on

/dev/hda2 45G 19G 24G 44% /

/dev/hda1 494M 19M 450M 4% /boot

/dev/hda6 4.9G 2.2G 2.5G 47% /home

/dev/hda5 9.7G 2.9G 6.4G 31% /opt

none 1009M 0 1009M 0% /dev/shm

/dev/hda3 9.7G 7.2G 2.1G 78% /usr/local

/dev/hdb2 75G 75G 0 100% /

/dev/hdb2 75G 75G 0 100% /

Taking the above output as an example, it means:

The second hard disk (b) of the HD hard disk interface, the second partition (2), the capacity is 75G, 75G is used, and the available value is 0. Therefore, the utilization is 100% and it is mounted on the root partition directory (/).

The following is an explanation of the relevant commands:

df -hl Check the remaining disk space

df -h Check the partition size of each root path

du -sh [directory name] returns the size of the directory

du -sm [folder] returns the total number of M in the folder

For more functions, you can enter the following command to view:

df --help

du --help

(Editor in charge: admin)

(3) Delete the log file

Looking at it today, There is nothing on the company's Linux server, but 50% of it has been used. When I checked, it turned out that the log file was too large, so I deleted it manually.

This is faster

sudo / dev/null > /var/log/**.log

The following is recommended

sudo find /var/log/ -type f -mtime 30 -exec rm -f \ ;

Delete old files older than 30 days

The above is the detailed content of How to check disk space in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn