Please suggest me any particular unnecessary file that I can clean to back everything to normal condition(temporarily). (i.e. any log or archieve or anything ). My var/log has only 40MB and Home directory has 3GB of space(so I believe that's not a problem). Other than that what I can clean up to make space.
[user@host]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_inamivm-lv_root
18G 17G 0 100% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 71M 389M 16% /boot
I am in a debian machine.
UPDATE1:
output of cd /; du -sxh *
6.1M bin
61M boot
156K dev
22M etc
3.3G home
306M lib
18M lib64
16K lost+found
4.0K media
4.0K mnt
408K opt
du: cannot access `proc/18605/task/18605/fd/4': No such file or directory
du: cannot access `proc/18605/task/18605/fdinfo/4': No such file or directory
du: cannot access `proc/18605/fd/4': No such file or directory
du: cannot access `proc/18605/fdinfo/4': No such file or directory
0 proc
208K root
9.7M sbin
0 selinux
4.0K srv
0 sys
8.0K tmp
536M usr
187M var
Update2
Output of ls -la /
dr-xr-xr-x. 22 root root 4096 Aug 7 08:42 .
dr-xr-xr-x. 22 root root 4096 Aug 7 08:42 ..
-rw-r--r--. 1 root root 0 Aug 7 08:42 .autofsck
dr-xr-xr-x. 2 root root 4096 Mar 28 16:53 bin
dr-xr-xr-x. 5 root root 1024 Mar 28 16:54 boot
drwxr-xr-x. 16 root root 3580 Sep 9 03:13 dev
drwxr-xr-x. 69 root root 4096 Aug 23 09:19 etc
drwxr-xr-x. 9 root root 4096 Jun 29 16:10 home
dr-xr-xr-x. 8 root root 4096 Mar 7 2012 lib
dr-xr-xr-x. 9 root root 12288 Mar 28 16:53 lib64
drwx------. 2 root root 16384 Mar 7 2012 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 2 root root 4096 Sep 23 2011 mnt
drwxr-xr-x. 3 root root 4096 Mar 7 2012 opt
dr-xr-xr-x. 355 root root 0 Aug 7 08:42 proc
dr-xr-x---. 5 root root 4096 Aug 17 18:27 root
dr-xr-xr-x. 2 root root 4096 May 2 09:13 sbin
drwxr-xr-x. 7 root root 0 Aug 7 08:42 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x. 13 root root 0 Aug 7 08:42 sys
drwxrwxrwt. 3 root root 4096 Sep 13 03:37 tmp
drwxr-xr-x. 13 root root 4096 Mar 28 17:53 usr
drwxr-xr-x. 18 root root 4096 Mar 7 2012 var
8 Answers 8
daisy's answer to use a graphical tool to visually find large files and directories is probably the best method. However, do note that "graphical tool" does not mean "requires an X server"! The wonderful ncdu
program provides the graphical output in the CLI, and works perfectly on remote servers via SSH:
$ ncdu /
. 43.7GiB [##########] /home
. 5.9GiB [# ] /usr
1.1GiB [ ] /lib
. 1.1GiB [ ] /var
736.9MiB [ ] /opt
. 324.6MiB [ ] /tmp
218.4MiB [ ] /boot
. 63.8MiB [ ] /etc
10.0MiB [ ] /sbin
8.8MiB [ ] /bin
3.3MiB [ ] /lib32
. 1.0MiB [ ] /run
64.0KiB [ ] /build
! 16.0KiB [ ] /lost+found
8.0KiB [ ] /media
8.0KiB [ ] /mnt
8.0KiB [ ] /.config
4.0KiB [ ] /dev
4.0KiB [ ] /lib64
e 4.0KiB [ ] /srv
e 4.0KiB [ ] /selinux
! 4.0KiB [ ] /root
e 4.0KiB [ ] /cdrom
. 0.0 B [ ] /proc
. 0.0 B [ ] /sys
@ 0.0 B [ ] initrd.img.old
@ 0.0 B [ ] initrd.img
@ 0.0 B [ ] vmlinuz.old
Then, after entering /var/
for instance:
. 395.3MiB [##########] /tmp
. 365.0MiB [######### ] /cache
. 297.8MiB [####### ] /lib
16.1MiB [ ] /backups
. 8.0MiB [ ] /log
. 56.0KiB [ ] /spool
40.0KiB [ ] /games
8.0KiB [ ] /www
e 4.0KiB [ ] /opt
e 4.0KiB [ ] /mail
e 4.0KiB [ ] /local
e 4.0KiB [ ] /crash
@ 0.0 B [ ] lock
@ 0.0 B [ ] run
Install easily on Debian or Ubuntu:
$ sudo apt-get install ncdu
Install easily on CentOS as root:
# yum install ncdu
-
1Oh wow, didn't know
ncdu
existed. All this time, I usedu -sh ./* 2> /dev/null | sort -rh
.annahri– annahri2021年12月31日 19:51:08 +00:00Commented Dec 31, 2021 at 19:51
The best way of finding out disk consuming, is using graphical software like baobab
:
Launch it with sudo baobab /
enter image description here
-
Will it work in remote server ?Subhransu Mishra– Subhransu Mishra2012年09月13日 18:26:56 +00:00Commented Sep 13, 2012 at 18:26
-
@Subhransu Sure, if you connect with X forwarding (
ssh -X
orForwardX11 yes
in~/.ssh/config
). However, if it isn't installed you might not have enough space to install it and the requisite directory.Gilles 'SO- stop being evil'– Gilles 'SO- stop being evil'2012年09月13日 23:34:40 +00:00Commented Sep 13, 2012 at 23:34 -
3See my answer below for a graphical tool that does not require an X server and requires very little server space.dotancohen– dotancohen2014年01月20日 12:29:26 +00:00Commented Jan 20, 2014 at 12:29
-
gdmap
(Graphical Disk Map) can also be used on Debian. It shows a treemap for the entire directory/drive at once. Also GUIs shouldn't be run withsudo
.mYnDstrEAm– mYnDstrEAm2024年04月09日 17:49:04 +00:00Commented Apr 9, 2024 at 17:49
Debian offers a utility called cruft
IIRC that lists files that could possibly be uneeded on your system.
-
1
-
After installing
cruft-ng
when running it orcruft
it sayswarning: plocate database is outdated
. Using KDE which uses baloo and don't want to create some large database for long just for that.mYnDstrEAm– mYnDstrEAm2024年04月09日 17:47:29 +00:00Commented Apr 9, 2024 at 17:47
make a new file in /bin
called treesize
chmod +x /bin/treesize
paste this in it.
#/bin/sh
du -k --max-depth=1 | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while (1ドル >= 1024) {
1ドル = 1ドル / 1024;
u += 1
}
1ドル = sprintf("%.1f %s", 1,ドル Units[u]);
print 0ドル;
}
'
Output looks like this.
#treesize
3.0 GB .
1.1 GB ./usr
759.9 MB ./var
353.3 MB ./root
307.1 MB ./opt
270.7 MB ./lib
98.6 MB ./home
60.1 MB ./boot
9.8 MB ./etc
8.3 MB ./bin
8.1 MB ./sbin
268.0 KB ./run
40.0 KB ./tmp
16.0 KB ./lost+found
-
1or this
du -hsx /* | sort -rh | head -n 40
Alejandro– Alejandro2020年02月12日 01:50:12 +00:00Commented Feb 12, 2020 at 1:50 -
@Alejandro: it's not really the same - at all.Seamus– Seamus2024年03月29日 06:59:04 +00:00Commented Mar 29, 2024 at 6:59
-
-
it works on my machineAlejandro– Alejandro2024年04月02日 23:30:27 +00:00Commented Apr 2, 2024 at 23:30
You can check for deleted files with lsof | grep -i deleted
Then you can see if a process is hanging on to an inode that you think was deleted. If so, restart the parent process to release the old (deleted) file.
I've found some very useful commands on this post at Askubuntu.com. Paraphrasing:
- Show top 10 biggest subdirs in the current dir:
du -sk * | sort -nr | head -10
- Use filelight/kDirStat/baobab to see where the disk space is going visually
- Check if you have old kernels for deletion:
ls -lh /boot
- Clean packages:
sudo apt-get autoremove
andsudo apt-get autoclean
- See list of all installed packages, sorted by size:
dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less
- Clean unused language files with translations:
sudo apt-get install localepurge
- Check content of /var/tmp/:
du -sh /var/tmp/
- Check also
man deborphan
- Search for big files:
find / -type f -size +1024k
orfind / -size +50000 -exec ls -lahg {} \;
This will give you the biggest files on your FS and maybe you will find there some files which can be deleted.
find / -xdev -type f -size +100000c -exec ls -la {} \; 2>/dev/null | sort -nk5 | tail -20
If you need longer output, just change number after tail command.
Please post output from:
df -h /
du -shx /
Both commands should show similar used space of your FS.
find . -atime +180 | xargs ls -al | sort -u -n -k5 | numfmt --to=iec --field=5
- find all files in
.
whos access time is over 180 days old - show file size
- sort by 5th column, numerical
- format 5th column to human readable
Useful links about access time:
cd /; du -sxh *
. It will sum up the size of all main directories on your server. Then, we will have a clue. You can also enter this big directory with cd and run du command inside of it to get deeper.cd /; du -sxh *