Ubuntu/Linux: Get disk space with “disk usage” (du, 2023, SSH)

“du” stands for “Disk Usage” and is a console command that displays the disk space used by files and directories. When you run the command in the console, it shows you the size of files and directories in bytes. This is especially useful if you want to determine which files and directories take up the most space on your system.

Syntax description for use in the shell #

A short syntax description for using disk usage (du) over the SSH.

du OPTIONEN DATEIEN

OPTIONS and FILES are optional parameters.

Examples of the console command “du #

Here you can find an overview of frequently used parameters that are used together with disk usage.

# Zeigt den belegten Speicherplatz des Dateisystems:
du -hs

# Zeige den belegten Speicherplatz im aktuellen Verzeichnis
du -hs .

# Zeige den Verbrauch von Speicherplatz durch einen bestimmten Dateityp:
du -hs *.pdf

# Sortiere die Ausgabe nach Größe
du -h * | sort -hr

# Zeige nur die Größe der Dateien und Verzeichnisse im aktuellen Verzeichnis an
du -h * --max-depth=1

# Zeige den verbrauchten Speicherplatz, wenn alle ZIP Dateien ausgeschlossen werden
du --exclude="*.zip*" -hs

# Zeige die größe eines bestimmten Pfades an
du -h /var/www --max-depth=1

Options / parameters #

Short formLong formDescription
-a–allSpecifies the allocation for files and directories, including hidden ones.
-B 100000–block-size=100000Specifies the block size to be used for calculating the memory requirements.
-b–bytesCorresponds to –block-size=1
-c–totalDisplays the total storage space at the end of the list.
-h–human-readableSpecifies the output in a readable format.
-kCorresponds to –block-size=1000
-l–count-linksCounts the sizes several times if they are mates.
-L–dereferenceDissolve all symbolic links
-D–dereference-argsResolves only symbolic links specified on the command line.
-d–max-depth=1Output sum for a directory if it is N or less levels below the command line argument.
-mCorresponds to –block-size=1M
–siCorresponds to -h only with powers of 1000 instead of 1024
-s–summarizeShow only one sum for each argument
-t–treshold=NIgnore entries smaller than N (if positive) or ignore entries larger than N (if negative)
-X–exclude-from=FILEExclude files that match any pattern in FILE.
Hier klicken, um den Beitrag zu bewerten
[Gesamt: 0 Durchschnitt: 0]

Leave A Comment

Title