Skip to content
  • Stuff
  • Travel
  • Beverages
  • Support Antipaucity
  • Projects
  • About

antipaucity

fighting the lack of good ideas

shell scripting

Posted on 15 October 200915 October 2009 By antipaucity 5 Comments on shell scripting

I’ve been playing around with bash scripting quite a bit recently in relation to my current job.

Came up with one that’s really useful (imho) around chkconfig:

# mass set all services known to chkconfig to be `on` or `off` at given level
# written by warren myers - warren@warrenmyers.com
# 28 sep 2009

echo "USAGE:"
echo " $0 <level> [on|off]"
echo

# list all services, just the name, skip blank lines, do in order
SERVICES=`chkconfig --list | cut -f 1 | grep -v ^$ | grep -v ':' | sort`

for SERVICE in $SERVICES
do
  chkconfig --level $1 $SERVICE $2
  echo "$SERVICE has been altered for $1 to state $2"
done

Yes – there’s an evil you could perform:

for CS in `chkconfig --list | cut -f 1 | grep -v ^$ | grep -v ':'`
do
  chkconfig --level 12345 $CS off
done

So, if you wanted to stop all services from coming on at startup, you could – and not know you did it until you rebooted.

code

Post navigation

Previous Post: chips
Next Post: end6 must die

More Related Articles

wordpress plugins code
dorss code
sending email in python with gmail code
what is the “new” python? code
the deadly sins of programming – again? code
gold medallion code
October 2009
S M T W T F S
 123
45678910
11121314151617
18192021222324
25262728293031
« Sep   Nov »
RSS Error: WP HTTP Error: cURL error 7: Failed to connect to paragraph.cf port 443 after 122 ms: Could not connect to server

Books

  • Debugging and Supporting Software Systems
  • Storage Series

External

  • Backblaze
  • Cirkul
  • Digital Ocean
  • Fundrise
  • Great Big Purple Sign
  • Password Generator
  • PayPal
  • Tech News Channel on Telegram
  • Vultr
  • Wish List

Other Blogs

  • Abiding in Hesed
  • Chris Agocs
  • Eric Hydrick
  • Jay Loden
  • Paragraph
  • skh:tec
  • Tech News Channel on Telegram
  • Veritas Equitas

Profiles

  • LinkedIn
  • Server Fault
  • Stack Overflow
  • Super User
  • Telegram
  • Twitter

Resume

  • LinkedIn
  • Resume (PDF)

Services

  • Datente
  • IP check
  • Password Generator
  • Tech News Channel on Telegram

Support

  • Backblaze
  • Built Bar
  • Cirkul
  • Digital Ocean
  • Donations
  • Fundrise
  • PayPal
  • Robinhood
  • Vultr
  • Wish List

35-questions 48laws adoption automation blog blogging books business career centos cloud community documentation email encryption facebook google history how-to hpsa ifttt linux money networking politics prediction proxy review scifi security social social-media splunk ssl startup storage sun-tzu tutorial twitter virtualization vmware wordpress work writing zombie

Copyright © 2025 antipaucity.

Powered by PressBook Green WordPress theme