Home Common Problem How to check disk space in linux

How to check disk space in linux

Jun 30, 2023 pm 05:10 PM
linux

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 of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)