Skip to content

Instantly share code, notes, and snippets.

@smamran
Last active October 24, 2016 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smamran/b8151d4fe3abef09541d to your computer and use it in GitHub Desktop.
Save smamran/b8151d4fe3abef09541d to your computer and use it in GitHub Desktop.
ubuntu commands

Display Total Disk Size

$$ fdisk -l | grep Disk

Displays Size of Folder sorted according to size

$$ sudo du -sh .[!.]* *| sort -nr   (Including Subdirectories)
$$ sudo du -sh * | sort -nr         (Excluding Subdirectories)

Displays the total size of the current directory including all the subdirectories.

$$ du -ch | grep total

Sum of directories (-s) in kilobytes (-k):

$$ du -sk *
152304  directoryOne
1856548 directoryTwo

Sum of directories (-s) in human-readable format (-h : Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte):

$$ du -sh *
149M directoryOne
1.8G directoryTwo

Disk usage of all subdirectories and files including hidden files within the current directory (sorted by filesize) :

 $$ du -sk .[!.]* *| sort -n

Disk usage of all subdirectories and files including hidden files within the current directory (sorted by reverse filesize) :

 $$ du -sk .[!.]* *| sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment