GNU/Linux basics

What is GNU/Linux?

GNU/Linux (or just Linux) is a Free implementation of the powerful Unix Operating System. Both the OS and many of its applications are freely available as source code. This means everyone is free to modify and further develop the OS (thousands of programmers have done so) , it is very much a collaborative effort. The version we will be using is Scientific Linux, which is based on Red Hat Enterprise Linux.

Linux has been widely adapted for scientific computing. In particular it has been widely used in large clusters of computers (our cluster for example). The combination of free software and cheap commodity hardware allows us to obtain supercomputing class performance at a fraction of the previous cost.

Logging On

The easiest way to log on is from another Linux machine using ssh, although you can use windows together with an 'ssh' client program ( e.g. the popular putty program [http://mobaxterm.mobatek.net/, [http://www.chiark.greenend.org.uk/~sgtatham/putty/]]).

To log on to our cluster you should use ssh fe0[7/8/9].esc.qmul.ac.uk, you should never have to log into any other front end (fe) server. You may on occasion log on to a compute node (cnXXX) from a fe node to follow the progress of your job, but this is an exceptional procedure to help debugging.

The Linux Filesystem

On Linux (Unix) all files are arranged in a tree-like structure. The root of this tree is a special directory called /. All files are in this directory or its sub-directories ("folders") . /bin ,/home and /lib are sub directories of /.

Your home directory is kept (for historical reasons) in /home/hep/<username>. Other important directories you may interact with are: /data/scratch/tmp, used for the temporary out of a running jobs (only visable on the machine the job is running on); /opt/share/<?>, which is used for any specialist software you might have requested to have installed (visible system wide); and /mnt/lustre_0/<?> which is used for long term storage of large data samples, use of this space has to be requested.

Useful Commands

Linux has hundreds of shell commands, here we mention a few of the most common and more useful ones.

For security reasons, the first thing you should do is change your password. You can do this using the passwd command. The passwd command checks your choice for a new password and rejects any considered too easy to guess.

To show (list) all files (including sub-directories) in a directory use the ls command:

[sim@fe09 ~]$ ls examples/
hello.cpp hello.o  Makefile.hello 

ls like most shell commands a number of command line options . You can get information about these using the --help switch this (or sometimes -h ) works for many commands.

[sim@fe09 ~]$ ls --help
...

So, for example, a more detailed directory listing can be obtained with:

[sim@fe09 ~]$ ls -al examples/
total 20
drwxr-xr-x    2 sim      student      4096 Jan  8 17:45 .
drwx------    5 sim      student      4096 Jan  8 17:42 ..
-rw-r--r--    1 sim      student        99 Jan  8 17:45 hello.cpp
-rw-r--r--    1 sim      student      1296 Jan  8 17:45 hello.o
-rw-r--r--    1 sim      student        90 Jan  8 17:45 Makefile.hello

(. and .. refer to the directory itself and its parent directory)

Another source of information is the man (short for manual) command eg:

[sim@fe09 ~]$ man ls
...

To search man pages use the -k option eg:

[sim@fe09 ~]$ man -k directory

To create a new directory (folder) use the mkdir command:

[sim@de09 ~]$ mkdir myprogs

will create a new directory called myprogs. To remove (delete) a directory use rmdir. To change your working directory use the cd command:

[sim@fe09 ~]$ cd myprogs

will change to the subdirectory myprogs (if it exists). This is a relative path. Similarly for the sim user, both

[sim@fe09 ~]$ cd ~/myprogs
[sim@fe09 ~]$ cd /home/sim/myprogs 

will change to /home/sim/myprogs (if it exists). This is an absolute path. To copy a file use the cp command. e.g.

[sim@fe09 ~]$ cp ~sim/examples/hello.cpp ~/myprogs/hello.cpp

Copies the hello.cpp example program to a the subdirectory. If the second argument is a directory name the existing file name is kept. So

[sim@fe09 ~]$ cp ~sim/examples/hello.cpp .

Will copy hello.cpp to your current working directory (assuming you have permission). To move (rename) a file use the mv command:

[sim@fe09 ~]$ mv hello.cpp newhello.cpp

To remove (delete) a file use the rm command:

[sim@fe09 ~]$ rm newhello.cpp

(Use with care!). To list the contents of a text file use the less command:

[sim@fe09 ~]$ less hello.cpp

To copy files from use scp

[sim@fe09 ~]$ scp sim@source.external.ac.uk:~/myfile ./
[sim@fe09 ~]$ scp ~/myfiletoo sim@source.external.ac.uk:~/

This will copy a file from an external machine to your home directory on the cluster or vise versa for user sim.

Edit and create files

To edit a exiting file or create a new file you can use a text editor, options are: vi (if you are mad), emacs (if you are an expert) or nano (if you like things simple). These programs are not operated with a mouse but require you to know the key commands. For nano (my choice) use nano -w <filename>, to save a file an exit, ^x (^x means press the control key together with x), confirm, check the file name and press return. To save a file without exiting, ^o, and confirm.

GNU/Linux basics (last edited 2015-10-14 12:59:56 by apw043)