How to check disk space in Linux command line
Sep 21, 2025 am 04:46 AMTo check disk space on Linux, use df -h for an overview of storage, du -sh to find directory sizes, lsblk to list block devices, or install ncdu for an interactive analysis. These tools help monitor and manage disk usage efficiently.
If you need to check disk space usage on a Linux system, the command line offers several straightforward tools. Here's how to do it:
The operating environment of this tutorial: Dell XPS 13, Ubuntu 22.04
1. Use the df Command
The df command displays the amount of disk space used and available on mounted filesystems. It provides a high-level overview of storage across all mounted partitions.
- Type df -h to view disk space in human-readable format (KB, MB, GB).
- Add the -T flag (df -hT) to show the filesystem type (e.g., ext4, xfs).
- To display information for a specific mount point, run df -h /path/to/directory.
2. Use the du Command
The du command estimates file and directory space usage. It is useful for identifying which directories are consuming the most space.
- Run du -sh /path/to/directory to get the total size of a specific directory.
- Use du -h --max-depth=1 /home to list the sizes of immediate subdirectories within /home.
- Add the --exclude option to skip certain file types, such as du -sh --exclude="*.log" /var.
3. Check Disk Usage with lsblk
The lsblk command lists block devices, showing disks and their partitions in a tree-like format, including size and mount points.
- Enter lsblk to view all block devices and their hierarchy.
- For byte-sized output, use lsblk -b.
- To include filesystem labels, run lsblk -f.
4. Use the ncdu Interactive Tool
ncdu is a curses-based version of du that provides an interactive interface for browsing disk usage and is especially helpful on remote servers.
- Install it using your package manager: sudo apt install ncdu on Debian/Ubuntu systems.
- Analyze a directory with ncdu /path/to/directory.
- Navigate using arrow keys, press d to delete files, or q to quit.
The above is the detailed content of How to check disk space in Linux command line. 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.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

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)

The official download portal of Aisi Assistant is located on the official website https://www.i4.cn/, and provides computer and mobile downloads, supporting device management, application installation, mode switching, screen projection and file management functions.

The latest news on September 18th, Huawei HarmonyOS6 has launched multiple rounds of preview version push for developers, and has recently opened the experience qualification to some users who have tried it out for the first time. According to user feedback, the current system name no longer displays the "NEXT" suffix, and it is officially renamed to HarmonyOS6.0. Huawei initially proposed the name HarmonyOSNEXT for the first time at the developer conference in August 2023, aiming to mark the Hongmeng system entering a new stage of development and realizing true native self-development. HarmonyOSNEXT's most core breakthrough is to completely adopt the underlying system architecture developed independently, completely remove the Linux kernel and Android AOSP code, and only run applications based on the HarmonyOS kernel.

TorunWindowsprogramsonLinux,trythesemethods:1.UseWinetodirectlyrun.exefiles.2.InstallPlayOnLinuxforeasierWinemanagement.3.SetupaWindowsvirtualmachinewithVirtualBox.4.UseLutristoinstallandrunWindowsgamesseamlessly.

Tolocateaprogram'sinstallationpathonLinux,use:1.whichprogram_nameforquickPATH-basedlookup.2.whereisprogram_nametofindbinaries,manpages,andsources.3.locatewithupdatedbandgrepforfastfilesearches.4.find/-typef-executable-name"program_name"fort

UseGUItoolslikeStartupApplicationsinGNOME,AutostartinKDE,orSessionandStartupinXfcetomanageloginprograms.2.Manuallyaddstartupentriesvia.desktopfilesin~/.config/autostart/followingXDGstandards.3.Forsystem-levelservices,usesystemctlenable/disabletocontr

TotakescreenshotsonLinux:1.UsePrtScnkeyforfullscreen,Alt PrtScnforactivewindow.2.UseGNOMEScreenshottoolformoreoptions.3.Usegnome-screenshotcommandinterminal.4.Installandusescrotforlightweightcommand-linecapturing.

ToinstallVSCodeonLinux,usetheofficialAPTrepositoryforautomaticupdates,Snapforcross-distributioncompatibility,oramanualtarballforfullcontrol.Choosebasedonyoursystemandneeds.

TocheckdiskspaceonLinux,usedf-hforanoverviewofstorage,du-shtofinddirectorysizes,lsblktolistblockdevices,orinstallncduforaninteractiveanalysis.Thesetoolshelpmonitorandmanagediskusageefficiently.
