I'm looking for some common problems in unix system administration and ways that shell scripting can solve them. Completely for self-educational purposes. Also I'd like to know how would you go about learning shell scripting.
closed as off-topic by muru, mosvy, Jeff Schaller♦ Jun 4 at 22:49
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – mosvy, Jeff Schaller
Any time you EVER find yourself doing something multiple times, script it. Think as lazy as you possibly can. Computers were built to do all of that menial crap. Any thing that smells like busy work needs a shell script.
Personally, I learned by rummaging around in Slackware for a couple of years. See what happens when you strip your system back as much as possible. Learn to be comfortable with text. While everybody else is ooing and awing over NetworkManager, learn how simple it is to make your own damn NetworkManager. Sure, it might not have as many use cases, but you can get something up and running, dynamically connecting via ethernet and wireless on-demand pretty simply enough.
I would like to re-recommend the three books that I suggested in another thread, these are in my opinion the best books to get into the spirit of Unix:
- The Unix Programming Environment from Kernighan and Pike
- Unix for the Impatient
- O'Reilly's Unix Power Tools.
The first one is old, very old, but it is concise, a short read and will give you the shell chops that you need (regular expressions, sed, pipelines).
The second one is incredibly entertaining.
The third one is a collection of "best of" tricks from the Unix masters in the 90's (That is when I read it). The book keeps getting re-edited, so I am sure it contains many new nuggets.
There is a wealth of great information in the Advanced Bash-Scripting Guide, and it's frequently updated to stay current.
How to learn it: Fall in love with the command-line. Use it regularly and pull up man pages often. Frequently, even. When I was first learning scripting, I couldn't count how many times I typed
man bash. I also couldn't count how many times I pulled up the man page for another command.
I learned it by writing a monitoring tool. It would connect to a bunch of machines via ssh and collect data like uptime, load, number of active connections, memory utilization and stuff like that. On my local machine it would show me that data as a text table.
I second Miguel's recommendation of 'The Unix Programming Environment'. Its really old but its how I learned almost everything I know about the shell and because its so old you can get it for just a few bucks on amazon: http://is.gd/eiSn6
Find a book or a manual and treat your chosen shell like a programming language, because it is. (Well, maybe not csh...)
For starters, learn how to figure out if you're in a Bash shell, Bourne shell, csh, zsh, or whatever. Some of these are similar to eachother like C and C++ -- deceptively different -- so knowing which one you're fighting with will help you find examples and manuals that actually will help in a given situation.