By John Dallas on Wednesday, 17 May 2023
Replies 1
Likes 0
Views 1.1K
Votes 0
How do I view the used space on my server's disk?
To verify the actual used and free space on your server's disk, you can run the following command:

df -h


You can determine the usage of specific directories using the du command. In the example below, you would modify the [directory] portion and enter the exact location you'd like to inspect.


sudo du [directory] -h --exclude=/proc --max-depth=3 | sort -hr | head

To view the root directory, you'd simply input / into the command, as below. The * indicates to show all within the directory.


$ sudo du -h /* --exclude=/proc --max-depth=3 | sort -hr | head

To view the srv/users/ directory, the command below should work:


$ sudo du -h /srv/users/* --exclude=/proc --max-depth=3 | sort -hr | head

To explain what's happening in the commands above, you are activating the sudo program to access superuser privileges. du is used to estimate file space usage. The -h flag makes sure that the output is printed in human readable format. Next, you're specifying the directory you'd like to see such as / for root. In this example, we used the --exclude=/proc tact to ignore some unnecessary output.

The --max-depth=3 portion includes three levels deeper into the directory. Next, we're using a pipeline | to sort the output by the -h (human readable output) values and list them in -r reverse. Finally, we use head to include only the first part of the files.
·
1 year ago
·
0 Likes
·
1 Votes
·
0 Comments
·
#6
View Full Post