
Linux Housekeeping Commands
This is a list of commonly used Linux commands for system administrators when performing housekeeping tasks to keep systems clean, optimised, and healthy. Please note that you may have to prefix the commands with sudo where you do not have root privledges.
| apt autoremove | Purpose: Removes unused packages and dependencies that were automatically installed but are no longer needed. | |
| apt clean | Purpose: Clears the local package cache to free disk space. | |
| journalctl --vacuum-time=7d | Purpose: Cleans up old system logs to save space. | |
| find /tmp -type f -atime +10 -delete | Purpose: Deletes temporary files older than 10 days. |
You may also wish to monitor and/or view different system assets. This can be done by using the useful commands below.
| du -sh * | Purpose: Displays disk usage of directories and files to find what’s consuming space. | |
| df -h | Purpose: Checks available disk space in a human-readable format. | |
| free -h | Purpose: Displays system memory (RAM) usage. | |
| top / htop | Purpose: Monitors running processes and resource usage in real time. | |
| systemctl list-units --failed | Purpose: Checks for failed system services that might need attention. |