When the root directory of CentOS is full, you can take the following steps to clean it up:
- Check the storage space usage: Run the following command to view the usage of the current directory:
df -h
This command will display the disk usage and guide the next steps based on the usage.
- Clearing log files: Log files typically take up a lot of storage space. You can use the following command to clean up log files:
sudo rm -rf /var/log/*
Please note that this will remove all files in the /var/log directory, so make sure you do not need these log files.
- Delete temporary files: Temporary files may also take up a lot of storage space. You can use the following command to delete temporary files:
sudo rm -rf /tmp/*
This will delete all files under the /tmp directory. Also, please make sure you don’t need these files.
- Check and clean software package cache: CentOS uses yum as a package manager, which caches packages locally. You can clean the yum cache using the following command:
sudo yum clean all
This will clean up all the downloaded packages.
- Check and clean unnecessary packages: Use the following command to list all installed packages:
rpm -qa
Next, remove unnecessary software packages using the following command (replace PACKAGE_NAME with the name of the package you want to delete):
sudo yum remove PACKAGE_NAME
The above are some common cleaning methods that can be adopted based on specific situations. Please make sure to back up important files and data before cleaning, and ensure that no important system files are deleted.