Operating System - HP-UX
1819931 Members
3071 Online
109607 Solutions
New Discussion юеВ

How to check the disk space of any directory or subdirectory?

 
SOLVED
Go to solution
leereg_5
Frequent Advisor

How to check the disk space of any directory or subdirectory?

As title!


Thanks a lot in advance!
Always UNIX!
7 REPLIES 7
Alexander M. Ermes
Honored Contributor

Re: How to check the disk space of any directory or subdirectory?

Hi there.
Use the du or df command ( du /etc or df /etc).
Last line will be summary line in OS-blocks.
Multiply this with the blocksize and you have the result in bytes or kB.
Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Ravi_8
Honored Contributor
Solution

Re: How to check the disk space of any directory or subdirectory?

Hi,

#df -k gives disk details of all the existing filesystems.
If you want particular directory or directory
for e.g for /var
#df -k /var
for subdirectory /var/yp
#df -k /var/yp
never give up
Ravi_8
Honored Contributor

Re: How to check the disk space of any directory or subdirectory?

Hi,

#df -k gives disk details of all the existing filesystems.
If you want particular directory or subdirectory
for e.g for /var
#df -k /var
for subdirectory /var/yp
#df -k /var/yp
never give up
Thierry Poels_1
Honored Contributor

Re: How to check the disk space of any directory or subdirectory?

hmmmz, df (like bdf) works on filesystem level.
"df /tmp", "df /tmp/subdir1" and "df /tmp/subdir1/subdir2" will return the same output if the subdirectories are on the same mountpoint.

"du -s" on the other hand, compute the space used in the directory and subdirectories (if "-s" is specified) specified.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Radu Swider_1
Occasional Contributor

Re: How to check the disk space of any directory or subdirectory?

du -sk /dir_to_check, for the total occupied space by the dir.
or
du -k /dir_to_check, to display the space occupied by the subdirs and dir.
leereg_5
Frequent Advisor

Re: How to check the disk space of any directory or subdirectory?

Thanks every experts!

Then how to check how much space remained, how much used in a particular sudirectory?like
/home/username/subdir1/subdir2?


Regards!
Always UNIX!
Frank Li
Trusted Contributor

Re: How to check the disk space of any directory or subdirectory?

You can use "du -sk *" command to check the disk space of the directory/subdirectory !

$du -sk /home/user/dir/subdir

you can use * to check all the subdirectory of one directory !

$du -sk /home/user/dir/*

The directory has no concept for free disk space , all dir share the disk space of the file system ,so you just only use "bdf" to get the free disk space of a file system .

Frank.
Hi Friend