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 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 |
man command | Display the on-line manual page for command |
The UNIX filesystem
The file system in UNIX uses a tree structure with directories (see picture).
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 s012345 with CWIS 12345 would have their home directory placed on the G-Bar structure.
The directory naming convention is /zhome/XX/Y/<CWIS> This uses a hash of the DTU CWIS number to make sure that there is a distribution of directories under sub directories, and not all get created at the top level.
XX: 00-ff Y: 0-f
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 s012345 is /zhome/82/7/12345, the file "letter.doc" can be referenced in the following two ways:
Absolute
/zhome/82/7/12345/docs/letter.doc
Relative
./docs/letter.doc
Quick access/reference to your home directory
cd ~
or just
cd
will change to your home directory. The tilda (~) can also be used to reference files relative to your home from any location.
ls ~/docs
will show the contents of the "docs" sub directory of your home, from whatever current directory you are in.
Unix Links
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.