In Linux, you can use du
the command to view the size of a directory. Here are some commonly used du
command options:
-h
: Displays the file size in human readable format.-s
: Shows only the total size, not the size of each subdirectory.-c
: Displays the total size, and displays the total on the last line.-a
: Shows the size of all files and subdirectories in the directory, not just the size of the directory itself.
Here are some example usages:
-
View the size of the current directory:
du -sh
-
Check the size of a specified directory:
du -sh /path/to/directory
-
View the size of all files and subdirectories in a directory:
du -ah /path/to/directory
-
View the total size of a directory, including subdirectories:
du -shc /path/to/directory
Note that du
the command recursively calculates the size of all files and subdirectories in the directory, so it may take some time to complete the operation, especially for large directories.