Introduction to Unix

Unix, or one of the modern operating systems derived from it, like Linux, is used on most high performance computing systems.

Unix was first developed in 1969 at Bell Labs, a division of AT&T at the time, to be an operating system for programmers.

Files on a Unix system are kept in “directories” instead of “folders”, but the file system organization is the similar to the structure on a PC or a Mac. Directories are organized in a tree structure, just as folders are on a personal computer. Every directory has one parent directory and can have multiple subdirectories. You can organize your files by creating directories and storing files in them appropriately.

You can read more about how to create and navigate Unix directory structures in the section “Unix directory structures“.

Unix commands

Unix commands have very short names.  The command names were chosen to minimize the amount of typing needed, and were meant to be mnemonic.  They are also case sensitive. So for  example, the command to copy a file is “cp” for copy.  Typing “CP” or “Cp” will give you a “command not found” error.

Common Unix commands

This table shows many of the common tasks you might want to do on a computer, and the Unix command for them. The phrase that each command is derived from is given below the command as a mnemonic device.

When you want to … … type this Unix command
Find out what directory you are currently in pwd
print working directory
See what files are in your current directory ls
list
Copy a file
the original file is unchanged
cp source-file target-file
copy
Delete a file rm filename
remove
Warning: The file is deleted immediately. You will not be prompted to confirm the deletion.
Create a new directory mkdir directory-name
make directory
Move a file to a different directory
file is removed from the original directory
mv source-file path-to-new-folder/target-file
move
Delete a directory
(The directory must be empty)
rmdir directory-name
remove directory
Move to a different directory cd path-to-directory
change directory
Get help on a command man command
manual

Unix directory structures

The top of the directory tree for the entire computing system is called the root and is represented on Unix systems by the ‘/’ symbol.

The root of your personal directory tree, where you can store files, is also called your “home directory”.   Unix provides aliases for your home directory so that it’s easy to move around and get back to it.  Your home directory can be referred to as “$HOME” or using a tilde (~) and your username. For example, joeuser’s home directory is ~joeuser.

To navigate through your directories, you need to know the path to the directory  you want to move to.  Unix uses a “/” character to separate directory names when you are describing a directory path.  Suppose that you have two subdirectories in your home directory, and they are project1 and project2.   The path to these directories would be $HOME/project1 (or  ~username/project1) and $HOME/project2, respectively.

Suppose further that under project1 are subdirectories input-data and results.  Those directories are $HOME/project1/input-data and $HOME/project1/results.

Navigating through Unix directories

To move through a Unix directory tree, use the  “cd” command.  For example, if you are in your home directory and you want to move to the project1 subdirectory, you would type

cd project1

To get to the input-data directory from $HOME, you would type

cd project1/input-data

This path, project1/input-data, is called a relative path because it is relative to wherever you are at the moment.

You can also use an absolute path to move around the directory structure.  Absolute paths contain the entire directory path from the root directory of the computing system.  For example, installed software packages on a PSC system are often stored in subdirectories of the /opt/packages  directory.  To see what packages may be available to use, type

ls /opt/packages

Getting help

The Unix “man” command can give you information about most other commands and software. For example, to see a description and all the options for the “ls” command, type

man ls

If you don’t know the name of the command you need, but you know the subject matter, you can use the “-k” option. Typing “man -k topic” gives a list of all the commands with topic in their names or descriptions. For example, to find information about the FORTRAN compilers, you could type

man -k fortran

More help

You can find many Unix tutorials online.   If you cannot find what you need online, you can email help@psc.edu  with questions.