Disk Space

maxwell.2k19

New Member
Credits
19
Hi All
1. I am new to RHEL and i am learning, on one of my server i have disk space alert. how do i check what files are occupying space.

Server01:~ # df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 60G 58.1G 1.1G 97% /

Server01:~ # cd /dev/sda2
-bash: cd: /dev/sda2: Not a directory

2. what does the below syntax do
find / -xdev -type f -size +100M | xargs du -sh | sort -hr | head -30
 


f33dm3bits

Gold Member
Gold Supporter
Credits
2,679
Hi All
1. I am new to RHEL and i am learning, on one of my server i have disk space alert. how do i check what files are occupying space.

Server01:~ # df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 60G 58.1G 1.1G 97% /

Server01:~ # cd /dev/sda2
-bash: cd: /dev/sda2: Not a directory

2. what does the below syntax do
find / -xdev -type f -size +100M | xargs du -sh | sort -hr | head -30
sda is your disk, 1 is the partition. So the output from df -h is saying you have /dev/sda1 mounted on /

You can check "man find" to see what the options mean but I'll try to explain.
find is used for search for files and directores:
Code:
find / -xdev -type f -size +100M | xargs du -sh | sort -hr | head -30
-xdev tells it not to not go into other directories that are located on a different filesystem. Since you have everything installed on one fileystem you can leave this option out.
-type what type of file is it: directory(d) or regular file(f)
- size +100M: search for anything bigger than 100M
The output you get from the first part is then piped (|) and used as input by xargs and executed with du -sh the output of that is then piped and used as input for the sort -hr(human readable format and reversed)command, and finally piped and used as input for the head command to only show you the first 30 lines of the output of that.
I would just search for anything bigger than 2G to start with:
Code:
find / -type f -size +2G | xargs du -sh | sort -hr | head -30
Als you can look at the commands and their options:
Code:
man find
man xargs
man du
man sort
man head
 
Last edited:


Members online


Latest posts

Top