UNIX Commands
Contents |
Introduction to UNIX commands
The Shell
What is the shell? In practice, the shell is what you get when you click on terminal button in the mouse menu on the desktop. The shell is a very powerful tool, if you know how to use it. If you are a Windows user, you might be familiar with it's shell; MS-DOS. In the G-Bar, there are several different shells, the default is BASH. The default can be changed by adding the following line to your ~/.login file:
setenv SHELL /usr/bin/tcsh
The concept of a shell is that you type a command, hit 'Enter' and the shell executes your command. If, for example, you type xmaple, a Maple session will appear. If you get used to some basic commands, you will be able to do many things more quickly than with the graphical tools.
List of basic commands
| Command Syntax | Description |
|---|---|
| ls | List the names of the files in the current directory |
| ls directory | List the names of the files in directory |
| ll | List the names of the files in the current directory along with the permissions, date, time and size. |
| ll directory | List the names of the files in directory along with the permissions, date, time and size. |
| ll -R | List the names of the files in the current directory and all subdirectories along with the permissions, date, time and size. |
| ll -rt | List the names of the files in the current directory ordered by date and time along with the permissions, date, time and size. |
| cat file | Shows the content of file |
| cd directory | Changes current directory to directory. |
| cp source destination | Copies the file(s) and/or dir(s) source to destination, which can be either another file or a directory. |
| cp -R source destination | Copies the file(s) and/or dir(s) source and all subdirectories to destination, which can be either another file or a directory. |
| mv source destination | Moves the file or dir source to destination, which can be either another file or a directory. |
| mv source destination | Renames the file or dir source to destination |
| less source | Shows the contents of the file source. |
| more source | Shows the contents of the file source. |
| mkdir directory | Creates a new directory called directory. |
| rmdir directory | Deletes the directory called directory. The directory must be empty. |
| rm file | Deletes the file called file. |
| rm -R directory | Deletes the directory called directory and all the files and subdirectories within it. |
| pwd | Shows the current path. |
| diff file1 file2 | Compares file1 to file2 and displays the differences. |
| xkill | Terminates the program that you click on with the mouse. |
| which command | Displays the path to command or the alias . |
Make jobs run after you have logged out
nohup command < /dev/null 2> /dev/null & The nohup command makes sure that the command doesn't die on exit. The "< /dev/null" redirects standard in (STDIN) to /dev/null which is basically nothing. "2> /dev/null" redirects standard error (STDERR) to /dev/null which in this case is like a trashcan. The output of the command will be written in a file called nohup.out.
The UNIX filesystem
The file system in UNIX uses a tree structure with directories (see picture). This is the same principle, as picked DOS and Windows picked up later.
Every folder can contain files or subfolders, which again is able to contain files and folders. The structure can be visualized as seen on the following illustration, which shows how the user s001234 could have his or her home directory placed in the global G-Bar structure. This examples shows that the user physically has a home directory on the server bohr in the G-Bar.
Note that unlike Windows, UNIX has no concept of drive letters (C:, D:, and so on). Instead, all files are organized into one big tree structure, no matter if they are located on a hard drive, a CD-ROM, or a floppy disk. To separate the directories in a file path, the slash ( / ) character is used, rather than the backslash ( \ ) as in Windows. The top level directory (or root directory) of the entire file system is simply called "/". Thus, the home directory illustrated in the picture is named "/gbar/bohr/home1/s00/s001234".
When working with a terminal, the directory in which you are currently "located" is called the working directory (e.g. when you run the "ls" command, the files shown are the ones in the working directory). When you start a new terminal, the working directory is your home directory.
A filename that begins with "/", is an absolute filename, that is, a full path to the file all the way from the root of the file system.
A filename that does not begin with "/", on the other hand, is relative. This means that it is relative to the working directory.
For instance, if the working directory of the user in the picture is the home directory ("/gbar/bohr/home1/s00/s001234"), the file "gml.brev" can be named in the following two ways:
- "/gbar/bohr/home1/s00/s001234/dok2/gml.brev" (absolute)
or
- "dok2/gml.brev" (relative)
Unix Links
The operating system of the servers in G-Bar is the UNIX-variant Solaris by SUN Microsystems. The G-Bar introduction guide describes how to navigate in the UNIX filesystem. To get familiar with the UNIX system you could take a look at the links below.
- UNIX Tutorial for Beginners
- Ohio State University - Introduction to UNIX HTML , PDF , PS or Compressed PS
- University of Rochester - Introduction to UNIX (advanced)
- Getting Started with Bash :: A Bash Tutorial


