How to check the memory being used in Linux?

Asked By 110 points N/A Posted on -
qa-featured

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

SHARE
Best Answer by linuxchunker2
Answered By 0 points N/A #87369

How to check the memory being used in Linux?

qa-featured

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!

Answered By 0 points N/A #87370

How to check the memory being used in Linux?

qa-featured

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

Answered By 110 points N/A #87371

How to check the memory being used in Linux?

qa-featured

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

Answered By 0 points N/A #87372

How to check the memory being used in Linux?

qa-featured

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:

[[email protected] 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:
 
[[email protected] 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

 

Best Answer
Best Answer
Answered By 0 points N/A #87373

How to check the memory being used in Linux?

qa-featured

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

Answered By 110 points N/A #87375

How to check the memory being used in Linux?

qa-featured

Hi linuxchunkers,

Thank you very much guys, you really helped me a lot.

Cheers!

Faisikhan

Login/Register to Answer

Related Questions