Summary of a few Unix Commands

Here are some of the most commonly used Unix commands. The "Option" is an optional symbol that can appear after the command to change how it behaves.

Before some of these commands will work "as advertised" you must make sure you type /export/home4/msimkin/shared/setup every time you log in. This will put you in the GLG410 environment and set things up so they will work right for this class. (If you want to see what it does and how it works, go ahead and take a look at it. It is just another script.)

Although the "$PATH" variable can be used so that you don't have to keep typing /usr/bin/ over and over, that trick won't work with /export/home4/msimkin/shared/setup. That's because /export/home4/msimkin/shared/setup sets your "$PATH", so you can't take advantage of it before it has been set! Unfortunately, then, you have to type the whole big long pathname.

Command Option Discussion
awk   Get data out of a file where the columns are separated by delimiters. See How to Make a 3D Drawing using HoloDraw for some examples.
cat   This is one of the simplest Unix programs. It merely reads input (from a file, or from another command, or from your keyboard) and writes the input to output (to a file, or to another command, or to your screen).
cd   Change Directory -- move to some other directory and make that my current working directory.
cd .. The symbol ".." is an abbreviation for whatever directory is "above" the one you are currently in. So if you are in directory /a/b/c the command cd .. would move you to /a/b.
cd ./x The symbol "." is an abbreviation for whatever directory you are currently using. So "./x" would say "start from where I am now and go down into the directory x". If you are currently in /a/b you would end up in /a/b/x (assuming that directory exists and you have permission to go there).
cd "$START" Change Directory to the directory set up specifically for this GLG410 class. This works because the name of your GLG410 directory is stored in the "$START" variable.
chmod 755 ./somefilename Makes "./somefilename" into a Unix program.
cut -c5-10,20-22 Output characters 5 through 10 and 20 through 22 of each line of input. Notice that there are no spaces in the option; everything is run together.
echo   Another very simple command, it just echos to output whatever words it sees following it in your command.
head -15 Reads the first 15 lines of input and copies them to output, then stops.
ls   List what files and directories I have in my current directory.
ls -l Show me more details about the files in my current directory.
mv ./oldname ./newname Rename the file "./oldname" so that henceforth it will be called "./newname". Like other Unix commands this will not usually ask "are you sure?" If there's already another file called "./newname" it will be wiped out to make room for "./oldname" which will now be called "./newname".
pwd   Print Working Directory -- show me what directory I am currently in. Same as echo "$PWD".
rm ./somefile Permanently and irrevocably delete (erase) the entire file "./somefile". Be very careful because there is no "undo" or "Recycle Bin" where you can go get it back again. Unix assumes you know what you're doing and if you say you want to delete a file, it's gone!
sort   Read input (from any other command, or from a file), sort it, and output the sorted data.
tail -5 Reads all of the input, but only outputs the last 5 lines.
tail +3 Read input, but don't start copying input to output until you get to line 3.
uniq -c Count how many times the same data appears over and over. For example if your data had 10 consecutive students from Arizona, it would show "10 Arizona" instead of showing the word Arizona 10 times in a row. If you sort your data first and then pipe it to uniq -c, this is useful to see what is the most common value in your data set.
wc -l Reads input, counts lines, and outputs how many lines it saw.
/usr/bin/passwd Change your login password. It is a good idea to spell out the entire /usr/bin/ explicitly, to make sure you are running the "real" passwd and not someone else's script that happens to be named "passwd".

Written by Marvin Simkin
Filename commands.html
Last updated October 20, 2004
Arizona State University Valid HTML 4.01!
Freedom to Choose ANY Browser