gBAR

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 SyntaxDescription
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

Unix Filesystem

 

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 for s012345 is named "/zhome/82/7/12345".

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.

NOTICE

24
01 2017
Please note that the IT support office has been moved to the DTU library. Latex support remains in 308.
02
12 2015
Want to take advantage of the new GitLab service, or perhaps move your existing repos project over? Check out http://www.gbar.dtu.dk/faq/94-gitlab
07
04 2015
ShareLaTex We now offer ShareLatex, an online mulituser system for making LaTex documents. Check out http://gbar.dtu.dk/faq/91-sharelatex and https://www.sharelatex.com/