df -h is a command in Linux that is used to view disk space usage, and its output is displayed in an easy-to-read format. 1. It displays the file system, total capacity, used space, available space, usage percentage and mount points; 2. The usage rate is too high (such as more than 90%) and requires cleaning or expansion; 3. Hidden files, inode fullness or misjudgment of mount points may cause space abnormalities; 4. It can be used to improve the inspection efficiency with commands such as du, grep, sort and watch. Mastering this command will help you discover and solve disk space problems in a timely manner and ensure the stable operation of the system.
Checking disk space is one of the most common tasks in Linux system management. df -h
is a simple but very practical command that can quickly view disk usage of the current system.
What is df -h
?
df
is the abbreviation of disk free, used to report the disk space usage of the file system. After adding the -h
parameter, the output will be displayed in a "human-readable" way (such as K, M, and G to represent the size), which is easier to understand.
Running this command is very simple, just enter:
df -h
You will see an output similar to the following:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 20G 30G 40% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/sdb1 100G 60G 40G 60% /mnt/data
Next, let’s take a look at a few issues and usage tips that you may be concerned about.
How to understand the output result of df -h
?
The output of df -h
usually includes the following fields:
- Filesystem : The file system name, usually the device path or network mount point.
- Size : Total capacity.
- Used : The space has been used.
- Avail : Available space.
- Use% : Use percentage.
- Mounted on : Mounted location.
The focus is on the two fields Use% and Avail . If the usage rate of a certain partition reaches more than 90%, you need to consider cleaning or expanding the capacity.
FAQs and Coping Suggestions
Sometimes you will find that even though you don’t have much data stored, the disk is almost full. This may be caused by the following situations:
- Hidden file footprint : Some programs generate large amounts of logs or cache files in the system, especially the
/var/log
or/tmp
directory. - Inode full : Even if the disk space is still still, if the inode is full, it will also indicate that there is insufficient space. You can use
df -i
to view the usage of inode. - Different mount points : Sometimes you think the data directory is actually mounted with another small partition, and you need to confirm the corresponding mount point of the directory.
When encountering these problems, you can use du -sh /*
or du -sh /掛載點/*
to find out which directory occupies the most space.
Tips: Use it with other commands more efficiently
Although df -h
is intuitive, if you only want to focus on specific information, you can filter the content in combination with other commands:
Only look at the root partition:
df -h | grep "/dev/sda1"
Sort by usage (high to low):
df -h --output=source,size,used,avail,pent,target | sort -k5 -n
Automatically monitor disk changes (refresh once every second):
watch "df -h"
These combinations can help you locate problems faster, especially when you maintain multiple servers.
Basically that's it. By mastering
df -h
and related commands, you can easily grasp the storage status of the system and avoid the problem of service abnormalities due to full disks.The above is the detailed content of How to check available disk space with df -h?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to check computer disk space in Linux system? As an open source operating system, Linux is used by many users. However, the operation method of this system is completely different from Windows. The editor will take you to see how to operate it! Operation method: Use the df and du commands to view dfdf and view the file system in units of disk partitions. You can obtain information such as how much space is occupied by the hard disk and how much space is currently left. For example, we use the df-h command to view disk information. The -h option is to display appropriately according to the size: Display content Parameter description: Filesystem: File system Size: Partition size Used: Used capacity Avail: The capacity that can still be used Us

C drive capacity planning guide In computers, C drive refers to the system disk where the system and programs are installed. It is also an important drive letter for storing system files and personal files. Properly planning the capacity of the C drive is crucial to the computer's running speed and system stability. This article will introduce you to how to reasonably plan the capacity of C drive and provide some practical guidelines and suggestions. 1. The importance of C drive capacity and system running speed: The larger the capacity of C drive, the shorter the time required for the system to perform read and write operations, thereby increasing the computer's running speed. System stability: C inventory

When you open File Explorer and go to This PC, you will see that the disk space usage bar will appear below the drive label. This disk space usage column gives you information about the amount of space available out of the total space on that particular drive. Normally, this is only seen when the default view settings are applied to File Explorer. If you notice that this disk space usage bar is not showing up under the drive label on your Windows 11 PC, read this article to find some fixes that can help you resolve this issue on your computer. Fix 1 – Reset this PC’s folder view 1. Hit the Windows key on your keyboard and enter File Explorer options. In the search results, click File Explorer

Cleaning old Docker log files can free up disk space through the following steps: 1. Find the location of the log file, usually in the /var/lib/docker/containers/ directory; 2. Use the sudotruncate-s0 command to clean the log files of a specific container; 3. Clean up the logs after backup to retain log information; 4. Set the regular cleaning scripts to automatically manage log files; 5. Set the maximum size and retention days of the log files through the configuration file to control log growth.

How to solve the common problem of insufficient disk space in Linux systems. With the popularization of computers and servers, the problem of insufficient disk space has become more and more common in Linux systems. Insufficient disk space may cause system performance to degrade, applications to not run properly, or even system crashes. In order to improve the stability and performance of the system, it is very important to solve the problem of insufficient disk space in a timely manner. This article will introduce some common solutions to help users effectively solve the problem of insufficient disk space. Clean up useless files: First, find and delete

How to deal with the problem of excessive disk space usage in Linux systems Introduction: In the process of using Linux systems, excessive disk space usage is a common problem. When there is insufficient disk space, it will not only affect the normal operation of the system, but may also cause the system to crash. Therefore, it is important to learn how to deal with and solve the problem of excessive disk space usage. This article will introduce some common solutions to help you better manage and optimize disk space. 1. Find files or directories that take up too much space to solve the problem of taking up too much disk space.

Linux system is a widely used operating system that is widely recognized for its stability and security. However, sometimes users may encounter issues with high disk space usage. This article will introduce common problems and solutions to high disk space usage. 1. Log file accumulation Log files are important files in Linux systems that record system events and application running conditions. However, if log files accumulate without limit, they can take up a lot of disk space. The solution to this problem is to regularly clean out outdated log files,

With the widespread use of Linux operating systems in enterprise-level applications, problems with storage device hardware and software have become increasingly prominent. This article will introduce common storage problems under Linux systems and corresponding solutions. 1. Problems caused by hard disk damage File system damage File system damage is one of the most common problems. This is usually caused by bad sectors on the hard disk or other reasons. When the file system is damaged, the data stored on the hard disk cannot be read or written, which will cause the system to fail to start normally. Solution: For damaged
