LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-25-2013, 03:31 PM   #1
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Rep: Reputation: Disabled
Question Get Size of Folder With every subfolder in once


Hello,

I would like to know how to get the BIGGEST folder of the whole. The thing is every commands I tested only check the folder itself but not all the folder tree with every sub folders.

The command that I tried to do is telling me that '/' is full at 95% with 35GB when I do have 2TB...

Thanks for your help.
 
Old 10-25-2013, 03:35 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,327

Rep: Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881Reputation: 3881
Quote:
Originally Posted by Ra'Jiska View Post
Hello,
I would like to know how to get the BIGGEST folder of the whole. The thing is every commands I tested only check the folder itself but not all the folder tree with every sub folders.

The command that I tried to do is telling me that '/' is full at 95% with 35GB when I do have 2TB...
You don't tell us what the commands that you've run are, version/distro of Linux, or what your goals are. Running:
Code:
du -hsx * | sort -rh | head -1
..gives you the folder that's using the most space. Read the man pages on du
 
Old 10-25-2013, 03:39 PM   #3
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Original Poster
Rep: Reputation: Disabled
Thanks for your help.
I'm using Ubuntu 12.04.

But the thing is, the comand you gave me doesn't seem to get the grand total of a folder.
It says that my '/home' directory takes 2% of 2TB, and my '/' directory takes 95% of 2TB, the comand you gave me threw me back 'home' with 29GB.

UPDATE: Here is a command I used to get the % used:

root@localhost:/# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/root 20G 18G 927M 96% /
root@localhost:/# df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/md3 1.8T 30G 1.7T 2% /home

What the fuck is going on ? Why 20GB on '/' ? How is that even possible ?
The last time I was at 99% used and there was 600GB of logs in '/var/log/apache2' that's not possible...
Thanks.

Last edited by Ra'Jiska; 10-25-2013 at 03:57 PM.
 
Old 10-25-2013, 04:35 PM   #4
dt64
Member
 
Registered: Sep 2012
Distribution: RHEL5/6, CentOS5/6
Posts: 216

Rep: Reputation: 38
the command
Code:
du -hsx
gives you the space that's used by the diretories and files in them including all subdirectories.
To simplify the output you could do
Code:
du -hsx --max-depth=1
which would give you only the totals of all subdirectories.

Maybe you want to play around with the
Code:
 --apparent-size
switch as well.

In you example 'du' will report the total for '/' including all subdirectories. If you don't want that you need to adjust the parameters of 'du'.

Why shouldn't it be possible to have 600GB worth of logs?
Do you run logrotate or any other housekeeping tools?

The detail you missed out in your post is how you partitions are set up. it looks like you have a 20GB partition for root and a 1,8TB partition for /home. What other partitions do you have set up?
To answer that question use 'fdisk -lu' and 'lvdisplay'/'vgdisplay' if applicable.

btw: Which flavour of Linux are you running?
 
Old 10-25-2013, 04:40 PM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,668
Blog Entries: 10

Rep: Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077
Quote:
Originally Posted by Ra'Jiska View Post
What the fuck is going on ? Why 20GB on '/' ? How is that even possible ?
Why you have to use vulgarity?
And why are you asking us when you allocated 20G to / ?

Did you even try
Code:
du -sh /var/log/apache2
Stick this in your path and use it:
Code:
#!/bin/bash
/usr/bin/du -sk ./* | /usr/bin/sort -n | /usr/bin/awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }
save it is smoke.sh
make it executable.
switch to a suspect directory and type
Code:
/path/to/pipe/smoke.sh <enter>
output:
Code:
0K	./btmp
0K	./btmp.1
0K	./debug.4
0K	./spooler
0K	./spooler.1
0K	./spooler.2
0K	./spooler.3
0K	./spooler.4
4K	./cron
4K	./cron.1
4K	./cron.2
4K	./cron.3
4K	./cron.4
4K	./debug.3
4K	./iptraf
4K	./maillog
4K	./maillog.2
4K	./maillog.3
4K	./nfsd
4K	./pm-powersave.log
4K	./rundeck.log
4K	./samba
4K	./secure.4
4K	./syslog.3
4K	./syslog.4
4K	./uucp
4K	./vbox-uninstall.log
8K	./secure
8K	./secure.2
12K	./faillog
12K	./lastlog
12K	./secure.1
12K	./vmware-installer
16K	./hp
16K	./syslog.1
16K	./syslog.2
24K	./Xorg.0.log
24K	./Xorg.0.log.old
24K	./syslog
28K	./messages.3
28K	./messages.4
32K	./secure.3
36K	./debug.1
36K	./debug.2
60K	./maillog.4
64K	./dmesg
68K	./debug
72K	./ConsoleKit
72K	./cups
72K	./nvidia-installer.log
84K	./messages.2
88K	./setup
92K	./messages.1
100K	./httpd
144K	./messages
172K	./vbox-install.log
256K	./wtmp
316K	./kdm.log
508K	./maillog.1
516K	./removed_scripts
2M	./wtmp.1
6.1M	./scripts
7.3M	./sbopkg
8.9M	./removed_packages
22.3M	./packages
28M	./sa
Total: 73M
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
search php code in folder and subfolder afradata Linux - Newbie 1 12-22-2012 05:00 AM
Makefiles, building source from another folder with obj files > subfolder of current? Funkster Programming 1 11-11-2011 07:29 AM
[SOLVED] Delete a subfolder ABC from main Project Folder adarshmca Linux - Newbie 4 08-01-2011 12:52 AM
Show folder and only one subfolder using ls in command line Drigo Linux - Newbie 4 07-14-2011 01:56 PM
how to run a script on subfolder file in a folder saggi_sam Linux - Newbie 5 07-13-2005 06:04 AM


All times are GMT -5. The time now is 09:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration