List maximum size directories


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
Who is Participating?
Maciej SConnect With a Mentor sysadminCommented:
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.
tia_kamakshiAuthor Commented:
I do not have root access. Can I get the list using my username

Thanks for your response
tia_kamakshiAuthor Commented:
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'

Please guide
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Maciej SsysadminCommented:
Copy and paste my entire command. You missed this:
"for dir in" in front of `find...
Maciej SsysadminCommented:
Without root privileges, you can't check size of subdirectories of / directory (as you may not have enough permission to examine some directories).
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
tia_kamakshiAuthor Commented:
This is great
tia_kamakshiAuthor Commented:
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

Maciej SsysadminCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.