1+ #! /bin/bash -x
2+
3+ # This file is free software; you can redistribute it and/or modify
4+ # it under the terms of the GNU General Public License as published by
5+ # the Free Software Foundation, either version 3 of the License, or
6+ # (at your option) any later version.
7+
8+ # This script is distributed in the hope that it will be useful,
9+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ # GNU General Public License for more details.
12+
13+ # You should have received a copy of the GNU General Public License
14+ # along with this script. If not, see <http://www.gnu.org/licenses/>.
15+
16+ # This script performs various system maintenance tasks to clean up logs, remove unnecessary packages, and update the system.
17+ # It is based on the Ubuntu distribution and is intended for command line use.
18+
19+ # Check disk usage of journal logs
20+ journalctl --disk-usage
21+
22+ # Rotate journal logs
23+ sudo journalctl --rotate
24+
25+ # Retain logs from the past 2 days only
26+ sudo journalctl --vacuum-time=2days
27+
28+ # Limit the space the log takes up to 100MB
29+ sudo journalctl --vacuum-size=100M
30+
31+ # Reload the systemd daemon
32+ sudo systemctl daemon-reload
33+
34+ # Display disk usage in human-readable format
35+ df -h
36+
37+ # Remove packages that are no longer needed
38+ sudo apt-get autoremove
39+
40+ # Clean the apt-get cache
41+ sudo apt-get clean
42+
43+ # Purge old kernels that are no longer in use
44+ sudo apt-get autoremove --purge
45+
46+ # Delete all .deb files from /var/cache/apt/archives
47+ sudo apt-get autoclean
48+
49+ # Update the package list
50+ sudo apt-get update
51+
52+ # Upgrade all packages to the latest versions
53+ sudo apt-get upgrade
54+
55+ # Note: You can use 'sudo apt-mark hold <package name>' to prevent a specific package from being upgraded.
56+
57+ # Reboot the system to apply all changes
58+ sudo reboot
0 commit comments