Hello,
How to find detailed disk usage of a /directory in Linux server in command line?
Disk usage check in detail
Moderator: Staff
cPanel Server Management
@ 30$ Onwards
@ 30$ Onwards
Re: Disk usage check in detail
Hi,
You can use following command to check the disk usage of a directory in detail.
#du -sch /directory/*
It will show the disk usage of the files and sub directories under this directory.
--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
You can use following command to check the disk usage of a directory in detail.
#du -sch /directory/*
It will show the disk usage of the files and sub directories under this directory.
--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
Last edited by Joan N on Sun Jun 03, 2018 4:40 pm, edited 1 time in total.
Re: Disk usage check in detail
Hello Joan,
Thank you for the quick reply. I have tried to check the disk usage of the entire server using below command.
#du -sch /*
But I got stuck at /home directory. Since /home is mounted to different drive I already know its disk usage. So please let me know how to skip /home and get the disk usage of all other files and folders under / .
Thank you for the quick reply. I have tried to check the disk usage of the entire server using below command.
#du -sch /*
But I got stuck at /home directory. Since /home is mounted to different drive I already know its disk usage. So please let me know how to skip /home and get the disk usage of all other files and folders under / .
Re: Disk usage check in detail
Hello,
You can use following command to exclude a particular directory while using #du -sch
#du -sch /* --exclude=home
--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
You can use following command to exclude a particular directory while using #du -sch
#du -sch /* --exclude=home
--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
Re: Disk usage check in detail
Hi,
I am also facing some disk issues with my server installed with cPanel. This time I can see that my /tmp partition reached 100%. How can I resolve this? All the services are down at the moment.
root@my.hostingserver.com:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 25G 3.2G 89% /
tmpfs 3.8G 3.8G 0 100% /tmp
But there is nothing in /tmp at all
root@my.hostingserver.com:~# ls -Sahl /tmp |more
total 10K
dr-xr-xr-x. 25 root root 4.0K Mar 16 04:29 ..
drwxrwxrwt. 3 root root 3.0K Mar 16 03:32 .
drwx------. 2 root root 1.0K Mar 16 04:28 mc-root
I am also facing some disk issues with my server installed with cPanel. This time I can see that my /tmp partition reached 100%. How can I resolve this? All the services are down at the moment.
root@my.hostingserver.com:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 25G 3.2G 89% /
tmpfs 3.8G 3.8G 0 100% /tmp
But there is nothing in /tmp at all
root@my.hostingserver.com:~# ls -Sahl /tmp |more
total 10K
dr-xr-xr-x. 25 root root 4.0K Mar 16 04:29 ..
drwxrwxrwt. 3 root root 3.0K Mar 16 03:32 .
drwx------. 2 root root 1.0K Mar 16 04:28 mc-root
Re: Disk usage check in detail
Hello,
You should use lsof /tmp to see if there any currently opened file. If you delete a file, while a software still have a lock on it, you won't see it anymore, but it will still have hd space assigned to it. After checking 'lsof', stopping the relevant process should free the space.
Also you can do 'tmpwatch' to clear the tmp partition. To setup /tmp to auto clean using tmpwatch
open SSH to your server, if SSH will not connect due to disk space full in tmp, reboot your server in then try again.
Once connected run the following command
once tmpwatch is installed run command
this will delete all files over 12 hours old
next, we will configure your server to do this automatically.
from SSH type:
go to the very bottom, paste it and save the file. So you can avoid such downtime issues.
You should use lsof /tmp to see if there any currently opened file. If you delete a file, while a software still have a lock on it, you won't see it anymore, but it will still have hd space assigned to it. After checking 'lsof', stopping the relevant process should free the space.
Also you can do 'tmpwatch' to clear the tmp partition. To setup /tmp to auto clean using tmpwatch
open SSH to your server, if SSH will not connect due to disk space full in tmp, reboot your server in then try again.
Once connected run the following command
Code: Select all
yum install tmpwatch -y
Code: Select all
/usr/sbin/tmpwatch -am 12 /tmp
next, we will configure your server to do this automatically.
from SSH type:
Code: Select all
crontab -e
Code: Select all
0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp
Aaron N
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree