As a linux beginner, I tried to do stuff from the console as often as possible but for most of the time I ended up relying on the GUI. Filesize was one of those things. I don't know why I never searched for it but I came to know about du while looking at one of my seniors work on his system.
Du probably stands for "disk usage". You will usually need these two options - 'h' and 's'. e.g. If you want find out the size of a file, say a movie, then run the following command.
[shredder12]$ du movie.avi
718016 movie.avi
The output is in KiBs and is not readable for all of us. By using -h option, you can convert the output into human readable formats.
[shredder12]$ du -h movie.avi
702M movie.avi
Now, when you are dealing with directories, using du will recursively throw the output of all the directories, which might not be what you are looking for. In such cases, we use "-s", this summarizes the output to the total disk usage of the directory concerned.
Here is an example without "-s"
[shredder12]$ du -h movie/
4.0K movie/sub/en
4.0k movie/sub/fr
12k movie/sub
702M movie/
Now, with "-s"
[shredder12]$ du -sh movie/
702M movie/
Post new comment