Use these 7 Linux commands to keep your system tidy and fast
Use these 7 Linux commands to keep your system tidy and fast
Is your Linux system slowing you down? Regular maintenance checks can help identify issues and keep your system running optimally. Below are seven simple commands you can use to monitor disk space, manage resources, and remove unnecessary files. Use them regularly to keep performance up without extra fuss.
1) Check disk space with df -h
df -h shows you how much space is free and used on each filesystem in a human-readable format. This helps you spot disks that are getting full and might slow down operations.
Tip: Run df -h to quickly see where space is occupied. If a filesystem is nearly full, consider cleaning up large files or moving data to another drive.
2) Inspect directory usage with du -h --max-depth=1
du -h --max-depth=1 provides a quick breakdown of which directories are consuming the most space. This is useful for identifying big folders that can be archived or deleted.
Tip: Combine with sort to find the largest folders: du -h --max-depth=1 | sort -hr | head -n 10
3) Monitor active processes with top or htop
top (and the more visual htop) shows CPU, memory, and process information in real time. It helps you identify processes that are using excessive resources and may need to be restarted or terminated.
Tip: In top, press M to sort by memory usage. In htop, you can easily kill misbehaving processes with a keystroke.
4) Examine running processes with ps
ps aux --sort=-%mem | head -n 10 lists the top memory-hungry processes. This is useful for spotting rogue apps or runaway services.
Tip: Use ps -eo pid,comm,%mem --sort=-%mem | head to tailor the output to your needs.
5) Clean up system logs with journalctl --vacuum-time
Journal logs can grow large over time. The command journalctl --vacuum-time=2d removes logs older than a specified time, helping to reclaim disk space.
Tip: Schedule periodic log pruning via a cron job or systemd timer to keep logs under control without losing essential data.
6) Check for available updates to keep performance and security up to date
On Debian-based systems, you can quickly see upgradable packages with apt list --upgradable. Regular updates often bring performance improvements and security fixes.
Tip: Before upgrading, you can review what will be updated with apt list --upgradable and then run sudo apt upgrade to apply changes.
7) Remove unused packages and clean cache
To reclaim space, remove unused packages and clean cached package files. On Debian-based systems, you can use sudo apt-get autoremove -y to remove orphaned packages and sudo apt-get clean to clear downloaded package files.
Tip: After cleaning, re-check disk space with df -h to confirm gains. Be cautious not to remove essential packages on customized systems.
Regularly running these commands helps keep your Linux system tidy, responsive, and free from unnecessary clutter. Adapt the commands to your distribution and usage, and consider adding a short maintenance routine to your weekly schedule.
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें