How can I check hard disk usage in Linux ?

via SSH/terminal, run the following command:
# df -h

This will output the usage of each partition in the server. To list the size of a specific directory, run the following command:
# du -sh /www/

If you want to list all the sub directory sizes under /www, run the following command:
# du -sh /www/*

The output of the ‘df‘ command will show you overall disk usage. To find out how much space a directory is used, use the ‘du -s ‘ command.

if you want to get how much space is used by each sub directory under www you can do something like:

find . -maxdepth 1 -type d | xargs du -h -s

To list directories and their total sizes

du -sh *
du usage

if you want to sort the folders by size. Helpful when looking to clear space..
du -sh * | sort -n

Usage: du [-aHLdclsxhmk] [FILE]…

Summarize disk space used for each FILE and/or directory.

Options:
-a Show sizes of files in addition to directories
-H Follow symbolic links that are FILE command line args
-L Follow all symbolic links encountered
-d N Limit output to directories (and files with -a) of depth < N
-c Output a grand total
-l Count sizes many times if hard linked
-s Display only a total for each argument
-x Skip directories on different file systems
-h Print sizes in human readable format (e.g., 1K 243M 2G )
-m Print sizes in megabytes
-k Print sizes in kilobytes(default)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 356 other followers

%d bloggers like this: