We are building a generic deployment image and I want to clean/delete all the host-specific details. (This a RHEL8/Oracle 8/Alma 8 system.)
This is what I have so far:
# rm -rf /etc/.etckeeper/* # if you use etckeeper
# rm -rf /etc/hostname /etc/mailname /etc/krb5.keytab
# rm -f /var/lib/dhcpd/*
# rm -rf /var/lib/sss/db/*
# rm -rf /var/tmp/*
# rm -rf /tmp/*
# rm -f /root/.*_history
# rm -f /home/*/.*_history
# rm -f /.bash_history
# rm -f /etc/lvm/archive/*
# rm -f /etc/lvm/backup/*
# rm -f /root/.viminfo
# rm -f /root/.less*
# rm -f /root/.rnd
echo 'root:<newpass>' | chpasswd
find /var/log/ -type f -print0 | xargs -0 truncate -s0
find /var/log/ -type f -name '*[0-9]' -print0 | xargs -0 rm -f
postsuper -d ALL
yum --enablerepo=* clean all
systemctl stop sshd
systemctl stop NetworkManager
rm -f /etc/machine-id
rm -f /etc/ssh/key
rm -f /var/lib/NetworkManager/*
sync
prevent writing .bash_history and poweroff:
poweroff & kill -9 $PPID $$
Is there anything else needed here after a minimal EL install? This is an absolute minimal install, almost nothing is installed except some minor tweaks and cloud packages.