amazon media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

Finding Out File Using Up Disk Space With [du] in GNU/Linux

It is a bit annoying when your disk space gets full, and you have no idea what is eating up the disk space, well, let me introduce you to ducommand, with this command you can get the disk usage of the set of FILEs, recursively for directories.

Using du against directories and subdirectories will help you narrow down what and what is eating up disk space, please note that the more the files and sub-directories that are within your current working directory, the longer it would take to scan through, so, if you can guess the location of what is causing the issue, you might start from there.

To get started, you can run du -h in your working directory, the problem with this is that, it would scan and calculate the disk usage of files recursively, and also show you the size of each and every file recursively.  To consolidate that, you use, du -hsc *

user@server: du -hsc *
139M   file1
25M    movies
2.6G   users
2.8G   total

The -h option gives us a human-readable output (megabytes, gigabytes, and the likes), -s option gives us a summary instead of outputting all the files scanned, the -c shows the total amount of space usage within the current working directory, and lastly, the * prints out the name of the directory, if you are scanning directories and sub-directory, it only shows the size of the directory, and if you are only scanning through files, it would print out the sizes of each file.

Also, it gives you the total disk usage beneath the scanned directory or files.

To scan the home directory, you use the following command:

du -hsc * /home

Note: The du command is only able to scan directories that its calling user has permission to scan. So, you might want to scan using root to get the full sizes.

To find the 5 largest directories in your server, you use the following command:

Note: This would only scan the working directory, so, you might want to navigate into a directory that is worth scanning.

du -hsc * | sort -rh | head -5

Replace 5 with an higher number if you want to find more.

To find the 5 largest directories in a specific path or directory, use the following command:

du -hsc * /home | sort -n -r | head -n 5

I am using home as an example, so, you can change that to whatever directory.

To find the 3 largest files in your server, you use the following command:

find -type f -exec du -Sh {} + | sort -rh | head -n 3

To find the 3 largest files in a specific path, you use the following command (I am assuming /home):

find /home -type f -exec du -Sh {} + | sort -rh | head -n 3

Enjoy!

Related Post(s)

  • How To Access Windows 10 Drive/Folder in VirtualBox

    To access Windows drive or folder in your Guest OS, you first of all, install VirtualBox guest utilities: sudo apt-get install virtualbox-guest-utils You then Add a shared folder by going into: Setti

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll