Tuesday, July 21, 2009

Learning Unix

I was recently given the task of learning Unix on my Mac. Recently, in this case means last week. I make no claims of being a Unix expert, but I am making some good headway. So, I thought I'd compile a post that tells others in a similar situation what resources I found helpful. If you have other suggestions, please add them in the comments.

Read:

Hayne, Cameron. "Unix FAQ (for OS X)", Hayne of Tintagel.

It's fairly long, but it provides a great overview of what you're trying to learn. There is plenty of opportunity to practice while reading through the various sections.

As you read, keep the following reference chart handy:

"An A-Z Index of the Apple OS X command line". This basically tells you what all the commands do and shows you the syntax required to use them.

Next, try the following questions, compiled by Bill Turkel to keep me occupied while he did more important work:

  • Open a terminal.

  • What directory are you in?

  • What files are in the directory?

  • Can you list the files in the directory in different ways?

  • How do you go to a different directory?

  • What files are in that directory?

  • How do you see only a few of the files at a time? Say ones that begin with the letter 'a'?

  • How do you see only the .html files?

  • How do you copy a file?

  • How do you move a file to a new filename? Is that the same as renaming it?

  • How do you make a new directory?

  • How do you get rid of a directory?

  • How do you list the contents of a .txt or .html file to the screen?

  • How do you break a text file into screen-sized chunks if it is too big to display on the screen?

  • How do you show the first part of a text file to the screen?

  • How do you show the last part of a text file to the screen?

  • How do you find a file in a different directory if you know (part of) its name?


You should be able to use the reference list posted above to solve all these problems. If you're totally stuck, leave a note in the comments.

Then you can move on to some more Turkel questions. Characters in quotes are commands to type into your Unix terminal. Don't include the quotation marks:

  • What do the "uname", "hostname" and "set" commands do? (minus quotes)

  • Try "ls -l" and "ls -1". Read "man ls"

  • Practice using "touch". Read "man touch"

  • Practice using "grep".

  • Make sure you read about . .. ~ and / .

  • Read "man less"

  • Read about pipes and redirection (|, <, >, >>), sed, split, chmod, curl and lynx



Once you're done that, you can try out some of the free quizzes on the bdv-unix-skills website.

Hope that helps, and since I'm still learning too, more advice is most welcome!

1 comment:

benmoreassynt said...

My tip would be that I find Unix much easier on Linux than Mac. Mac is a bit quirky in where it puts things, and lacks an easy to use implementation of the awesomeness of apt-get. That leaves you in the sometimes nightmarish world of 'how the heck do I install stuff in unix' when you decide you could really do with an odd version of graphicsmagick to do image manipulation on your website.

The other thing is there's much less web support in terms of gazillions of websites telling you how to do stuff than I find there is for Linux.

But have fun! And remember, Less is More. Once you get that joke, you're set.