Created
August 11, 2018 14:01
-
-
Save mstaack/b850afc831fd576814c84bd3de134090 to your computer and use it in GitHub Desktop.
Cleanup Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Stop rsyslog to clean up logs | |
| service rsyslog stop | |
| # Cleanup all logs | |
| cat /dev/null > /var/log/audit/audit.log | |
| cat /dev/null > /var/log/wtmp | |
| cat /dev/null > /var/log/lastlog | |
| #cleanup persistent udev rules | |
| rm /etc/udev/rules.d/70-persistent-net.rules | |
| #cleanup /tmp directories | |
| rm -rf /tmp/* | |
| rm -rf /var/tmp/* | |
| #cleanup current ssh keys | |
| rm -f /etc/ssh/ssh_host_* | |
| sed -i -e 's|exit 0||' /etc/rc.local | |
| sed -i -e 's|.*test -f /etc/ssh/ssh_host_dsa_key.*||' /etc/rc.local | |
| bash -c 'echo "test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server" >> /etc/rc.local' | |
| bash -c 'echo "exit 0" >> /etc/rc.local' | |
| # Clear hostname | |
| cat /dev/null > /etc/hostname | |
| # Cleanup apt | |
| apt-get clean | |
| #cleanup shell history | |
| history -w | |
| history -c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment