[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

List maximum size directories

Posted on 2009-02-10
9
Medium Priority
?
256 Views
Last Modified: 2013-12-06
Hi,

I am new to Linux/Debain

How can I find top 10 maximum size directories

Also, I have to find top 10 in some particular directories

Many thanks
0
Comment
Question by:tia_kamakshi
  • 4
  • 4
9 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 2000 total points
ID: 23599384
Run as root if you want to check sizes of / subdirectories.
for dir in `find / -type d -maxdepth 1`; do du -sk ${dir}; done | sort -nr | head -n 10

You can change "/" (in find command) for some other directory you want to check.
0
 

Author Comment

by:tia_kamakshi
ID: 23599402
I do not have root access. Can I get the list using my username

Thanks for your response
0
 

Author Comment

by:tia_kamakshi
ID: 23599417
Thanks I tried your command

I get the error below

defgmcc@abcd-pbhi5:/$ `find /home/ -type d -maxdepth 1`; do du -sk ${dir}; done | sort -nr | head -n 10
-su: syntax error near unexpected token `do'
defgmcc@abcd-pbhi5:/$

Please guide
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Expert Comment

by:Maciej S
ID: 23599442
Copy and paste my entire command. You missed this:
"for dir in" in front of `find...
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23599453
Without root privileges, you can't check size of subdirectories of / directory (as you may not have enough permission to examine some directories).
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23599513
as Oklit said, you need to root permission

if you know the root password then you can execute

su command to get root access or insert your name in sudoers file to get root access

other then that

have a look at this one

http://www.cyberciti.biz/tips/linux-unix-du-command-examples.html
0
 

Author Closing Comment

by:tia_kamakshi
ID: 31544959
This is great
0
 

Author Comment

by:tia_kamakshi
ID: 23599646
Can you please help me in understanding this

for dir in `find / -type d -maxdepth 1`; do du -sk ${dir}; done | sort -nr | head -n 10

Thanks
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23599700
for dir in `command1`; do command2; done | sort -nr | head -n 10

for every item (named dir here for later reference - it can any string you want) returned by command1, execute command2. Then sort output numerically (-n) with reversed order (-r) and provide just first 10 lines of output (head -n 10).

command1 - find all directories (-type d) in root directory (/) without search for subdirectories (-maxdepth 1)
command2 - perform "du -sk" on every item named dir
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order for businesses to be compliant with certain information security laws in some countries, you need to be able to prove that a user (which user it was becomes important to the business to take action against the user after an event has occurr…
Users are often faced with high disk consumption without really knowing where the largest amount of data resides. Disk Usage Analyzer (aka Baobab) is is a graphical, menu-driven application to analyse disk usage in any Gnome environment and can e…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Screencast - Getting to Know the Pipeline
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question