#!/bin/bash # turnoff.sh - by dual # Iterates through and disables services on a RHEL box # Make sure we're root if [ $UID != '0' ]; then echo ">>> $0 must run as root... exiting" exit fi # Make sure we're on RHEL if [ ! -f /etc/redhat-release ]; then echo ">>> $0 currently written for RHEL-based distros... exiting" exit fi # Print header echo "turnoff.sh -" echo # Iterate through enabled services for i in $(chkconfig --list | grep ":on" | sort | awk '{print $1}'); do read -p ">>> Do you want to disable _ $i _ in every runlevel (y or n)? " ANS # Turn off service if [ $ANS = "y" ]; then echo ">>> Disabling $i" echo chkconfig $i off # Leave service alone else echo ">>> Leaving $i" echo fi done # Closing message echo ">>> Done!"