Best way to learn UNIX and shell Programming

Guys,

What do you think is the best way to learn UNIX and shell scripting?

** I keep on searching tutorials online, where I loose most of my time :frowning:

Let me know the way you learnt the UNIX concepts, your replies might help me learn more.

Thanks a ton:b:

Disclaimer: I am not a professional UNIX guy - I work in a completely different field.

From my perspective, the number one most helpful thing you can do is to be constantly coding. This is particularly helpful if you have a need (or at least desire) some particular behaviour in your system. For example, I had a buggy program, and sometimes would need to kill several instances of it. It was a pain to do a `ps -A` every time, and manually kill each instance of the process. So I made a one-line script that would do a ps -A, grep for the name of the particular process, parse and grab the pid from the first field, and then do a kill on those numbers. Over time, I polished and extended the script, adding functionality, and making the output a little more informative/easier to read.

Now there a few things to note here:

  1. At the time, I did not know of pkill and friends, so I was basically reinventing the wheel. As I look back, that was OK, because I learned something while doing it. In fact, it is a decent way to learn. You basically take a known utility that you normally use, eg., pkill, or whatever, and re-implement it yourself. At first, your new program likely won't have all of the functionality of the full blown version on your system, but you can add that over time. This concept is also helpful in other areas, such as C programming. It is very instructive, for example, to make your own versions of the string library functions. Not for actual use necessarily, but for learning. (It is hard to beat the system versions, in terms of outright speed. If you already know enough to improve on the standard library, then my points here are basically moot.)
  2. If the process of learning how to shell program seems to be coming slowly, remember to be patient with yourself, and stick with it. Everybody's situation is different. For my part, I am a slow learner (it seems), and I have been hacking away for years and am not nearly as far as others have gotten in the same time. If I was doing this for a living, I know I would be farther along, because a), I would be immersed in it, and b) I would (ostensibly) have other professionals to guide me when I was doing something that was not quite right. This is true of mostly any profession I think. There is a huge learning curve with this sort of thing - lots of nooks and crannies. Be patient!

So that is my two cents worth. Write lots of code. It would be preferable to be writing some useful little stuff which improves some particular situation of your own (as opposed to toy exercises, which initially can be somewhat helpful, but are ultimately limited in value). If you are like me, you likely want to grab an O'Reilly book on scripting, or something like that as well. Ask lots of questions as well.

(a) Spend some bucks to buy a good book on Unix/Linux. Check out the reviews, the "Look Inside" feature, the "Listmania" lists at amazon.com. Or go to your neighborhood bookstore and browse through the books to get an idea of the one that suits you.

But, more importantly:

(b) Install a Unix/Linux system on your computer yourself, and practice, practice, practice. Write as many scripts as you can. Test things by yourself before believing anything.

It's like learning how to ride a bicycle or swim. A book can only give you the directions, but when the time comes, it won't write your Production code for you.

tyler_durden