du - the disk usage linux command

du stands for disk usage. This simple linux command provides a summary of harddisk or storage space disk usage. It has many parameter arguments that can provide results in many screen format. du command can also summarize files and directories in a recursive manner.

Here are several usage of to use the du (disk usage) command.
# cd /home/vertito
To list the files and directories from there
# ls -la
-rw-r--r-- 1 root root 29 2007-08-11 11:57 file.txt
drwxr-xr-x 2 root root 4096 2007-08-11 11:57 folder1
Show summary in bytes
# du -b
4096 ./folder1
8221 .
# du -a
4 ./file.txt
4 ./folder1
12 .
Now, let us get a more human readable results
# du -ah
4.0K ./file.txt
4.0K ./folder1
12K .
The above shows that my file.txt has about 4K of filesize rounded to nearest power of 1024K including . an ..

Now, let us it in bytes
# du -ab
29 ./file.txt
4096 ./folder1
8221 .
The above is the same results you get from issuing ls -la command. 8221 is . and ..

Now let us do it once again in human readable form
# du -abh
29 ./file.txt
4.0K ./folder1
8.1K .
You can also exclude file glob pattern or shell expression for files like so
# du -abh --exclude='file.txt'
# du -abh --exclude='*.txt'
4.0K ./folder1
8.0K .
Recursive directory disk usage summary can also be achieved by doing the default usage without any parameters
# cd /home
# du
You can also limit the recursive search dept like so
# du --max-depth=2
which search on the 2nd level of directory only and ignores any folder found above the 2nd level folders.

Getting the summarized return in a human readable form
# du -sh
Alternatively if you wish to get the last time modification
# du -ah --time
4.0K 2007-08-11 11:57 ./file.txt
4.0K 2007-08-11 11:57 ./folder1
12K 2007-08-11 11:57 .

If you are using mbox type of mail storage handling, these commands can be handy checking and reporting partition and/or folder disk usage when incorporated inside a shell scripts. Furthermore, you can create and generate your TOP 10 users with largest mails on monthly or weekly basis that could give you more detailed email report and alerts from it..

At regular interval and again using a script, you can also watch and monitor folder/partition usage changes and alerts you for certain specified thresholds like for /home or /var/ftp or /tmp.



document storage said...

The du command scripts are the fundamental in linux navigation. It is the easiest and promptest way to know memory status.

Unknown said...

A nice article on Linux du command to supplement the given information.


Austere said...

Interesting information. Thanks for sharing.

Best Mobility Services | Austere Technologies

madin said...

Butikken har løst problemer for mig, tjenesten er meget tålmodig,køb moncler boern det er en perfekt shopping oplevelse. Da jeg modtog Moncler tøj, troede jeg,køb moncler herrer jakke det var en god kopi af Moncler dunjakke. Jeg kan lide denne online butik, denne Moncler kjole er enkel og generøs. Meget tilfreds med dette køb.

Aditi Ray said...

Check out the best
sofa bed
shoe rack nz
bedroom furniture nz

csyan said...

I have been paying attention to replica watches.fake iwc watches After receiving the goods, I was very surprised, the leather strap is comfortable, the watch is light weight, high quality and the price is good.replica iwc portofino watches If you are looking for a watch that suits your everyday wear, this replica watch is definitely the perfect outfit. I will buy again!

Post a Comment

Popular Posts