search
HomeSystem TutorialLINUXHow to check disk space in Linux system How to check computer disk space

php editor Youzi will introduce you how to check the disk space in Linux system. Understanding computer disk space query methods is critical to system management and optimization. Through simple commands and tools, you can easily understand disk usage, free up space in time, and ensure the normal operation of the system. Follow our guide to master the skills of checking disk space and make your Linux system more efficient and stable.

How to operate:

View via df and du commands

df

df View the file system in units of disk partitions, and 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 displays it appropriately according to the size:

linux系统如何查看磁盘空间 电脑磁盘空间的查询方法

Display content parameter description:

  • Filesystem:File system
  • Size:Partition size
  • Used:Used capacity
  • Avail:The capacity that can still be used
  • Use%: Used percentage
  • Mounted on: Mount point

Related commands:

  • df -hl: Check the remaining disk space
  • df -h: Check the partition size of each root path
  • du -sh [Directory name]: Return the directory size Size
  • du -sm [folder]: Return the total number of M in the folder
  • du -h [directory name]: View the size of all files in the specified folder (including subfolders )

du

The original English meaning of

du is disk usage, which means to display the usage of disk space and is used to view the total size of the current directory.

For example, check the size of the current directory:

# du -sh

605M.

Display the space occupied by the specified file:

# du log2012.log

300 log2012.log

Display the space occupied by the test directory in an easy-to-read format:

# du -h test

608K test/test6

308K test/test4

4.0K test/scf/lib

4.0K test/scf/service/deploy/product

4.0K test/scf/service/deploy/info

12K test/scf/service/deploy

16K test/scf/service

4.0K test/scf/doc

4.0K test/scf/bin

32K test/scf

8.0K test/test3

1.3M test

du command is used to view the total size of the current directory:

  • -s: Only the total number of occupied data blocks is given for each Names parameter.
  • -a: Recursively display the number of data blocks occupied by each file in the specified directory and each file in the subdirectory. If neither -s nor -a is specified, only the number of disk blocks occupied by each directory in Names and its subdirectories is displayed.
  • -b: List the disk space usage in bytes (the system defaults to k bytes).
  • -k: List disk space usage in units of 1024 bytes.
  • -c: Add a total at the end (system default setting).
  • -l: Calculate the size of all files. For hard link files, calculate multiple times.
  • -x: Skip directories on different file systems and do not count them.
  • -h: Use K, M, G as units to improve the readability of information.

View hard disk space through graphical interface

For users who are accustomed to using graphical interfaces, there is a more intuitive and convenient method. Simply open a file manager (such as Nautilus or Thunar), select the directory or partition you are interested in, and right-click the mouse to select the "Properties" option in the pop-up menu. In the properties window, you will be able to see details such as the total capacity, used space, and remaining free space of the directory or partition.

linux系统如何查看磁盘空间 电脑磁盘空间的查询方法

Check hard disk space through third-party tools

If you want to get more detailed information about hard disk space, you can also use some third-party tools. For example, GParted is a powerful disk partitioning tool that can not only view the usage of hard disk partitions, but also manage and adjust partitions. In addition to the principles of the Linux operating system, Baobab is an intuitive and easy-to-use disk space analysis tool. It can graphically display the space occupied by each directory in your system, helping you quickly find files or directories that take up too much space.

Precautions:

When checking the hard disk space, please pay attention to the following points:

  • 1. Make sure you have sufficient permissions to perform the corresponding operations;
  • 2. Pay attention to choosing the appropriate viewing method, and choose the command line or graphical interface according to your own needs;
  • 3. Regularly clean up useless files and temporary files to free up more hard disk space;
  • 4. Operate carefully to avoid deleting important files or directories.

Through the introduction of this article, I believe that everyone has mastered the method of checking hard disk space under the Linux operating system. Whether you are a command line master or a graphical interface enthusiast, you can easily get the information you need. Remember, rational use of hard disk space will help improve system performance and work efficiency.

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

Statement
This article is reproduced at:脚本之家. If there is any infringement, please contact admin@php.cn delete
What are the main tasks of a Linux system administrator?What are the main tasks of a Linux system administrator?Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Is it hard to learn Linux?Is it hard to learn Linux?Apr 18, 2025 am 12:23 AM

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

What is the salary of Linux administrator?What is the salary of Linux administrator?Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

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.

Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is Linux actually good for?What is Linux actually good for?Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

See all articles

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

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools