Add du cheat sheet and one exhaustive example

pull/161/head
terminalforlife 3 years ago
parent dd2654b767
commit 9a4d45c300

@ -0,0 +1,22 @@
# du
# Estimate file space usage
# With 'root' privileges, use du(1), sort(1), and head(1) to display a list of
# the top 20 space-consuming files in whichever storage medium '/' is mounted.
#
# Here, du(1) is using the `-x` flag to keep to the one filesystem, which is
# important for getting accurate results on the filesystem on which you
# might, for example, be needing to free space.
#
# In order to sort the human-readable file sizes, sort(1) is using the `-h`
# flag, the `-k` flag to specify the column to sort (first), and its using
# the `-r` flag to reverse the sorting, so we see the highest size first.
#
# To then show the top-20 lines, we use head(1) and specify the number of lines
# via the `-n` flag. The default number of lines displayed by head(1) and
# tail(1) is 10.
#
# Root privileges are gained for this task by using sudo(8) on bash(1) in order
# to have a new root-owned BASH session, which then executes the commands
# proceeding the `-c` flag.
sudo bash -c 'du -xh / | sort -rhk 1 | head -n 20'
Loading…
Cancel
Save