On VPS servers, disk space and Inodes (the number of files) are often limited. If your server reaches its capacity, it can cause various issues, potentially leading to malfunction. When disk space or Inodes are exhausted, the server may fail to operate properly. For instance, when a task or application tries to create a temporary file but there's no available space or Inodes, it might get stuck, leading to further complications.
To avoid such problems, it's essential to monitor your disk space and Inodes regularly. While many control panels will alert you when you're running low on disk space, it's a good practice to check these resources periodically yourself.
Checking Disk Space
You can check disk space on your server using the following commands:
1. Check the overall disk space usage:
df -h
2. Check the contents of the current directory, including the space each file/folder occupies:
du -h
3. Check the disk space usage of only the current directory:
du -hs
4. Check the size of a specific directory and its contents:
du –hs /etc
5. Find files larger than 1024 KB:
find / -mount -size +1024k -type f -exec du -Sh {} \; | sort -rh
Checking Inode Usage
To check the usage of Inodes, use the following commands:
1. Check the Inodes in the current directory:
for i in 'ls -1A'; do echo "'find $i | sort -u | wc -l' $i"; done | sort -rn | head -5
2. Check the top 50 directories by Inode usage:
du -a / | sort -n -r | head -n 50
Note: You can run this command in a specific directory by navigating to it first:
cd /etc
du -a / | sort -n -r | head -n 50