You are not logged in.

#1 2010-06-03 19:56:04

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Helpful Linux Bash Scripts for I.T. Admins

I was wondering if you guys had any recommendations for helpful / simple Bash scripts that do helpful tasks in regards to Linux system administration? I have never created or used a Bash shell script but know that many of you guys do. I have no programming experience what so ever so decided to ask if you guys do have one or few scripts that are useful in basic administration tasks, could you please post them or at least point someone who is interested in the right direction?

Thank you so much!


./

Offline

#2 2010-06-03 20:42:47

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Helpful Linux Bash Scripts for I.T. Admins

Well, there is this really long thread on this forum about self-made commandline utilities, i suggest to read some in that.

As a small example from me:

rcd() {                                                                                                          
if [[ `whoami` == "root" ]]; then
        /etc/rc.d/"$1" "$2"
elif [[ `whoami` == "ogion" ]]; then
        sudo /etc/rc.d/"$1" "$2"
fi
}

This allows me to do something like "rcd sshd stop" and it will translate that (if i'm root) to "/etc/rc.d/sshd stop". I have that in my shell rc file. (.zshrc in my case, but you could probably also put it in a .bashrc tooo if you use bash)

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#3 2010-06-03 20:47:47

awkwood
Member
From: .au <=> .ca
Registered: 2009-04-23
Posts: 91

Re: Helpful Linux Bash Scripts for I.T. Admins

Well, other than searching the Arch forum and the wiki... especially the self-made utilities thread.

General sysadmin (command line) tips:
  http://serverfault.com/questions/68883/ … s-and-tips
  http://catonmat.net/category/unix-shell

Great, well-commented bash scripts:
  http://www.pbrisbin.com:8080/pages/scripts.html

Offline

#4 2010-06-03 20:57:19

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: Helpful Linux Bash Scripts for I.T. Admins

I'm no sysadmin but one were to use command-line a lot i would give ZSH a shot. A nicely configured zsh shell can be unbelievably comfortable and is certainly a great tool.

As for scripts I always thought of them as little helpers customized for certain situations. For instance easing repetitive tasks, batching some steps and timing/automating little things. For general purpose I'd probably look at available software first.
Maybe tmux for terminal management, ranger for file management, a tiling window manager for efficiency, ssh and other survaillance/maintenance software? Personally, I'd very much like to hear, too, what software/scripts/.. linux systems admins use to keep the work to a minimum wink.


no place like /home
github

Offline

#5 2010-06-03 21:09:08

Cyrusm
Member
From: Bozeman, MT
Registered: 2007-11-15
Posts: 1,053

Re: Helpful Linux Bash Scripts for I.T. Admins

I would say to just take some of the more common tasks that you do, basically anything that involves a few steps, and try to write your own bash scripts for them.  like I've got a ton of quick-n-dirty scripts for stupid stuff like deleting commonly deleted files, backing up files, stripping html tags, etc.

My only advice would be to start small and simple, and then add complexity as necessary.  before long your boss will never know that 90% of your job is taken care of by cron'd bash/zsh/perl/python scripts smile

Last edited by Cyrusm (2010-06-03 21:12:49)


Hofstadter's Law:
           It always takes longer than you expect, even when you take into account Hofstadter's Law.

Offline

Board footer

Powered by FluxBB