Asked By
faisikhan
110 points
N/A
Posted on - 04/22/2011
Hi,Â
My question is related with Linux Operating System. I want to know how to check the memory which is being occupied by all the directories & files in one parent directory. Also, one more thing, how can I check the disk usage or memory usage of files & directories with respect to depth levels.
Any one who can help me in a bit detail about my above asked questions or queries??
Thanks & Regards,
Faisal Rehman
How to check the memory being used in Linux?
Hi Faisikhan,
In order to check the memory occupied by all the directories & files in one parent directory, you can use the below command:
du -all
For example, if you are in a parent directory like /etc, then using the above command will give us the space occupied by each file & directory in KBs & MBs.
Well, there can be possibilities that there are multiple directories and files in a single directory. So, if you want to check the space occupied by each directory in terms of depth levels, you will have to use the below command:
du -ah –max-depth=1
Now, you can increase the depth level like 2,3 etc.
I hope this helps you!
How to check the memory being used in Linux?
Hi Faisikhan,
Yes, the command used for checking the memory space occupied by all the directories and files is:
du -all
But if you want to view a summarized and in a human readable form, then you can use the below command:
du -sh or du -ah
Where h means "Human Readability", with the help of which you can get your answer in exact figures and words.
Regards,
linuxchunker2
How to check the memory being used in Linux?
Hi linuxchunkers,
Thanks for your help. But I did not understand the word "h", what is its importance? And one more thing, how can I check the size of a single file or directory?
Is there also any available solution for that?
Thanks,
Faisi khan
How to check the memory being used in Linux?
Dear Faisikhan,
With the help of "h", we will get the size or memory of the files and directory in readable form, I mean which can be understood by a human being easily. Let me explain you this via an example. You can feel the difference now:
[root@vs1975 apf-9.7-1]# du -all
4 ./install.sh
40 ./README.apf
4 ./importconf
36 ./CHANGELOG
Â
and now while I am using "h" instead of all then:
Â
[root@vs1975 apf-9.7-1]# du -ah
4.0K ./install.sh
40K ./README.apf
4.0K ./importconf
Â
So, while using du -all, an expert of Linux can assume that the size of the files is in Kilo Bytes. But it is a bit difficult task for a person new to this platform. So, he can use "ah" or "h" instead of all, to obtain the exact size of files as from the above example. You can see that the size of the files are in Kilo Bytes.
Â
Regards,
Â
linuxchunker
Â
How to check the memory being used in Linux?
Hi faisikhan,
Yes, Linux chunker is explaining you in a very easy and satisfactory detail, what you must have to consider in your mind. That in order to view the files that a space occupied, use the word ah or sh after to get a very simple, easy and summarized results.
Regards,
linuxchunker
How to check the memory being used in Linux?
Hi linuxchunkers,
Thank you very much guys, you really helped me a lot.
Cheers!
Faisikhan