Learn Enough Unix for Your Resume

On the resume that convinced Wired to hire me, I said that I knew enough about Unix that it didn’t scare me anymore. This wasn’t exactly true. Unix was still a chilling concept for me when I arrived at the San Francisco office armed with a copy of Unix for Dummies. The managing editor steered me to my desk and instead of the Macintosh I was hoping for, there sat a purple SGI machine.

I realized then that I needed to learn a lot about Unix fast. Initially I tried using SGI’s graphical user interface, which mimicked the Macintosh desktop fairly well, but soon realized that it was just too damn slow. So I stole some better Unix books from the engineering staff and found a nice Unix expert to help me. Soon I was cp-ing, mv-ing, and chmod-ing like lightning. Unix still gives me the occasional nightmare, but basically I love it. It’s fast, it makes sense (most of the time), and anyone can figure it out with a little work. Plus, it looks great on a résumé. If you can convince a prospective employer that you have a working knowledge of Unix, you’re one step ahead of everyone else who is too scared even to try figuring it out.

I’ve put together a very basic explanation of Unix to get you started. But first, a warning. Unix is very powerful. The wrong collection of keystrokes can blow away files that you’ll probably never be able to recover, so practice on sample files before you move on to anything important.

Contents

Getting started

Before you can do anything, you need an account. Find someone at your school or workplace whose title is webmaster, server administrator, systems administrator, or Unix god. Be very nice to this person. Bring gifts and libations, and then ask them to set up an account and user directory for you. Promise that you won’t bug them very often with questions, even though this may indeed turn out to be a white lie.

Keep in mind that Unix installations vary widely. If something doesn’t work for you here, it may be that a program wasn’t installed or your account was misconfigured. There’s also a strong possibility that you’re using one of several different kinds of Unix, which means your commands may vary slightly from what you learn here. If you run into trouble, go ask the person who set up your account to help you — but don’t forget to bring a gift.

Once you’ve got your account, go to the bookstore and purchase a few Unix books. My favorite is O’Reilly & Associates’ UNIX in a Nutshell. It’s a fabulous dictionary of commands.

Telnet

To access your account, you’ll need a shell (a program that sends whatever you type to the host computer). The easiest way to go about this is to open a Telnet window. (If you’re sitting at the host computer, you’ll already have a shell.) Accessing files with Telnet is essentially the same as opening the Finder on your Mac or opening the Windows Explorer on a Microsoft machine — except that when you get into the file structure, you won’t find all those sissy color-coded directories.

So open Telnet, and choose Open Connection from the File menu. Fill in the Host/Session Name slot with your host’s address and hit Connect. You’ll be asked to enter the username and password that your nice sysadmin assigned you when your account was set up. You should also have a user directory, which is the first place you’ll end up when you Telnet to your Host. When you log on, you should get something that looks like this:

Although you probably won’t see it when you log on, the actual location of your user directory is

sutro.hotwired.com[~]%pwd
/usr/people/pam

Basic Commands

I’ve put together a few commands to get you started. Most of these commands have several options that make them even more powerful, but I won’t go into those here. You can find them in the Unix Online Manual, which I’ll explain in a minute (or you can use that book you went out and bought).

In this example, I’ve used rm -ir to remove the directory somethingdifferent. Before the directory is removed, I must confirm that I really want it gone. Once I do, somethingdifferent no longer exists. Be very careful with rm, because once files or directories are gone, they’re probably gone forever.

less – less really is more. It does the same thing as more, but it allows you to search through a file (among other things).

exit – allows you to log out of your host

date – prints the current date and time

cal 1997 – prints the 1997 calendar

whoami – prints who is currently logged on to your terminal

mail – brings up a simple mail editor

pwd – tells you where you are; it prints the full pathname of the current directory

Unix online manualIf you want more details about a particular command, you can check out the Unix main page, which is basically just a manual for Unix. For example, if you want to find out more about ls, type

sutro.hotwired.com[~/unixclass]% man ls

And you’ll get:ls(1)

NAME
ls - list contents of directory
SYNOPSIS
ls [-RadLCxmlnogrtucpFbqisf1AM] [names]
DESCRIPTION
For each directory argument, ls lists the contents of the directory; for
each file argument, ls repeats its name and any other information
requested. The output is sorted alphabetically by default.

To quit man, type q.

Permissions

As you travel around your host computer, you’re going to find there are lots of things you can’t do. You won’t have the freedom to move and edit files as you did in your user directory.

Remember ls from our basic commands? One of this command’s options (ls -l) gives you loads of information about files and directories.

Here we have the contents of the directory unixclass, which contains two directories (one and two) and two files (one.html and two.html). The first column of letters determines who can read, write, or execute your files and directories. (I know it just looks like a bunch of letters, but give me a second and I’ll explain.)

The second list (pam, pam, pam, pam) tells who owns the file. In this case, it’s me.

The next column tells which group I was part of when I made these files. To find out what groups you belong to, type groups and your name, like this:

sutro.hotwired.com[~/unixclass]% groups pam
infomgr staff prod edit

The fourth column shows the size of the files.

The fifth is the date and time the file was last modified; the sixth is the name of the file.

What the Heck is rwx?

As I mentioned before, these letters determine who can read, write, or execute your files. They break down like this:

For files:

r = read – you can read the file (more or less it)

w = write – you can write to the file (edit it with vi, Emacs, or Pico)

For every folder and file there are four sets of rwx. In the example above, they are easy to spot because they’re set apart by hyphens. The first set shows your permissions, the second is for a group, the third is for anything else (other), and the fourth is for everyone (all).

Now, to make things a little more complicated, each one is referred to by a single letter:

you = u
group = g
other = o
all = a

To add permissions on a file or directory, you use +, and to remove them, you use -. Let’s try it out. We’ll remove group write privileges for this file:

-rw-rw-r-- 1 pam staff 4233 Dec 5 09:35 one.html

To do this, we must also use the chmod command to change the access mode of the file.

D’oh! Not privileged. Until you become a powerful Unix god, you will see this message many times. But keep at it, and deityhood may be closer than you think.

Text Editors

VI

The most commonly available text editor is [[Tutorial:Vi Tutorial for Beginners|vi] (pronounced vee-eye), which I especially recommend for Mac users. You really only need to know a few commands to get started.

To start vi, simply type vi at the command prompt:

sutro.hotwired.com[~/unixclass]% vi myfile.html

and you’ll be instantly thrown into this crazy-looking environment with a ~ on every line. Don’t be afraid. The annoying thing about vi is that you have to tell it when you’re adding and deleting text. You can’t simply type and delete, you have to use the following commands:

To add text – hit the esc key and the letter i (for insert)

To delete text – hit the esc key and the letter x (for delete)

To delete an entire line – hit the esc key and the letters dd

To save your file – hit the esc key and type :w and then hit return

To save and exit vi – hit the esc key and type :wq and hit return

Emacs

Emacs is the favorite editor of many, but Macintosh users may tell you not to bother because they find it really irritating. PC users will probably offer a different opinion.

PICO

If you’re a beginner, pico is probably your best bet. Simply type in

sutro.hotwired.com[~/unixclass]%pico myfile.html

and you’ll be thrown into the editor. All the commands are listed on the top and bottom of the screen. Be sure to save frequently.

Here’s The Thing With Ad Blockers

We get it: Ads aren’t what you’re here for. But ads help us keep the lights on. So, add us to your ad blocker’s whitelist or pay $1 per week for an ad-free version of WIRED. Either way, you are supporting our journalism. We’d really appreciate it.