Unix Orienteering

There are three vital things to know when you're working on a Unix system:

  1. Who am I?
  2. Where am I?
  3. What am I?

Who am I?

When you log into a Unix machine, you provide a username and password. Many people have accounts on different machines, and others have multiple accounts on the same machine. Each account may have a different home directory and a different set of access privileges. If you forget who are you, you may get confused.

To learn the system's idea of who you are, type the command whoami. This will output the username you logged in under:

(~) 55% whoami
lstein
(~) 56% 

Where am I?

The Unix file system consists of a series of nested directories all descended from a top-level directory known as the "root". You can refer to files and directories using the full pathname, starting at the root and working downwards. For example, the file INBOX in my home directory is rightly named: /home/lstein/INBOX.

You can also refer to files and directories using shorter relative path names. At any time, you are in a "current directory", also known as a "working directory." If you use a path that doesn't begin with a "/", it's interpreted as a partial path relative to the current working directory. INBOX is a file named "INBOX" in the current working directory. Mail/bills is a different file named "bills" that's located in a subdirectory of the current working directory.

It's important to know what the current working directory is, because nnnnyou and Unix may not always think alike in this regard (but Unix always wins). To learn this, type the pwd ("print working directory") command:

(~) 56% pwd
/home/lstein

If your system administrator was considerate, he may have configured your shell to include the name of the working directory in the command-line prompt.

What am I?

It sounds unlikely, but Unix makes it so easy to log in to remote machines that you can easily forget what machine you're working on. To find out, ask the machine to identify itself with the hostname command:

(~) 57% hostname
formaggio

The uname -a command gives you even more information about the machine:

(~) 57% uname -a
Linux formaggio 2.2.10 #7 Sun Aug 1 17:45:34 EDT 1999 i586 unknown
<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Thu Oct 9 20:34:16 EDT 2003