Check Disk Space Linux Commands

Check Disk Space Linux Commands

how to check disk usage and free space linux commands ubuntu

To check disk usage and free space on Linux, particularly Ubuntu, you can use several commands. The df command is commonly used to display the amount of disk space available on the file systems. For example, running df -h provides a human-readable summary of disk space usage, showing the file system, total size, used space, and available space on disk.

Additionally, the du command is useful for checking disk usage of directories. To get a summary of the size of a specific folder, you can use du -sh ~/$ where ~/$ is the directory you want to check.

For more detailed analysis, tools like ncdu can be used, which allows interactive navigation and sorting of disk usage by size.

If you prefer a graphical interface, Ubuntu provides tools like the "Disk Usage Analyzer" which can be accessed from the applications menu.

These commands and tools help in effectively managing and monitoring disk space on Linux systems.

there are some files that are taking lots of space, is there a command so I can find a problem directory or something, such as list by size of directory with full path

To list the largest directories in Linux along with their full paths, you can use a combination of the dusort, and head commands. The following command estimates the disk usage of directories, sorts them by size in human-readable format, and displays the largest ones:

du -h /path/to/directory | sort -hr | head -n 20

This command will provide an output of the top 20 largest directories starting from the specified path, with sizes presented in a human-readable format (e.g., in KB, MB, GB).

If you want to exclude subdirectories from other file systems (e.g., mounted network drives), you can include the -x option:

du -hx /path/to/directory | sort -hr | head -n 20

This ensures that du does not descend into directories on different file systems.

For a more interactive experience, you can use the ncdu utility, which provides a navigable interface to explore disk usage and identify large directories easily. It can be installed via package managers like apt or brew, depending on your system.

If you prefer working only within the current directory, the following command can be used to list the largest directories locally:

du -shx * | sort -hr | head -10

This command calculates the disk usage of all files and directories in the current directory and displays the largest 10 entries.

Leo AI generated answer. Please verify critical facts.