Introduction to Unix
Unix was first developed in 1969 at Bell Labs, a division of AT&T at the time. Many modern operating systems are derived from Unix.
Files on a Unix system are kept in "directories" instead of "folders", but the file system structure is the same. 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 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
|Copy a file
the original file is unchanged
|cp source-file target-file
|Delete a file||rm filename
Warning: The file is deleted immediately. You will not be prompted to confirm the deletion.
|Create a new directory||mkdir directory-name
|Move a file to a different directory
file is removed from the original directory
|mv source-file path-to-new-folder/target-file
|Delete a directory
(The directory must be empty)
|Move to a different directory||cd path-to-directory
|Get help on a command||man command
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
To get to the input-data directory from $HOME, you would type
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
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
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
You can find many Unix tutorials online. If you cannot find what you need online, you can email email@example.com with questions.