Welcome to the Maths Linux systems!

animated penguin doing somersaults

If you are new to Linux, page will tell you all you need to know about the Linux systems in the open access rooms of the Maths department. There's not much locally-written documentation here yet as we've been too busy building all the systems but these pages will be added to as rapidly as possible.

Using Linux for the first time may come as a bit of a shock for those of you who are used to the ubiquitous Windows way of doing things and some of you may already have had brief encounters with Unix that have left you perhaps bewildered and distinctly unimpressed. We sincerely hope that your experiences with Linux at Imperial College will be both exciting and pleasurable - the systems are modern and use the latest graphical interfaces and you can actually use them to the full without knowing a single Linux or Unix command.

Help is always at hand from Andy Thomas ,Huxley room 6m46.

About paths and directories

You probably wondered why the ./ was prepended to your myprogram command? This is because you will almost certainly be writing, compiling and running programs from within your home directory and your own home directory and its subdirectories almost certainly are not in your current default execution path. Your default path is a list of directories and subdirectories that Linux will search in turn for a command that you have given. For example, you have probably used the command 'ls' to see what is in a subdirectory - the ls command actually lives in /bin or /usr/bin but because both /bin and /usr/bin are already in your default path, Linux knows to look in both of these directories first for the ls command. This saves you both from having to know exactly where the ls command lives (is it /bin, or /usr/bin?) and more importantly. from having to type /bin/ls or /usr/bin/ls every time you want to use ls.

To find out what your present default path is, type:

echo $PATH

if you are using the bash shell which is now the default for College Linux accounts. If you are using the C or tcsh shells (which used to be the default in Mathematics until about 2007), environment variables are in lower-case so you'll need to type:

echo $path


But since your home directory and its subdirectories aren't normally in your path, you need to tell Linux where to start looking for, say, your program called myprogram. If your present working directory (that is, the directory you have last changed into) happens to contain myprogram, putting a ./ immediately in front of myprogram tells Linux to look in the current directory for myprogram and then execute it; ./ literally means execute myprogram from this directory.

To find out what your present (or current) working directory is, typing:


will tell you which directory you are currently 'in'.

You can run programs in a different directory from the one you are currently in in two ways; you can either give the full absolute path to the directory where your program resides or you can use a relative path - that is, relative to the one you are currently in. Assuming your username is jbloggs, your home directory is /home/ma/j/jbloggs, the program you have just compiled is in a subdirectory of this called my_project and your current directory is /home/ma/j/jbloggs/tests:

  1. you can give the full path: /home/ma/j/jbloggs/my_project/myprogram

  2. or you can give a path relative to the one you are in: ../my_project/myprogram

If you are using the full path, you can save yourself quite a bit of typing by using the handy environment variable $HOME or $home which is preset for you by the shell and represents your own home directory, in this example /home/ma/j/jbloggs. (Note that $HOME will also work even when you are using the C or tcsh shells as it's such a commonly used variable that the C/tcsh shells assign both upper & lower case variables for you). So instead of typing the long command shown in the example above, you can instead type:

you can give the full path: $HOME/my_project/myprogram

If you are unsure of your home directory, typing:

echo $HOME

will display your own home directory. An even shorter alternative to using the $HOME variable is ~/ and the example of the full path to your program called myprogram shown above becomes simply:


Being nice to other users

As these are multi-user machines, meaning one or more other users can use the system at the same time as you, it goes without saying that you should try and be nice to others on the same system (or systems) and be aware of their needs. If you are the only user on the system, then it is quite acceptable to start your job so that it can take advantage of all the resources available to it - your program or computation will run at the fastest speed possible and complete quickly. But if you are aware that others are already running jobs on the system then it is considered good etiquette to run your programs or jobs in such a way that you don't hog all of the machine's resources!

To do this, you can literally change the 'niceness' of the program you are running - either when you start the program or you can adjust it laster after it has started. All UNIX and Linux programs have a 'niceness' rating, a number of between -20 and +19 (in Linux) or 0 and 39 (in UNIX); a very 'nice' Linux program will be running at a niceness of 19 (nice, quiet and undemanding) whereas a greedy, resource-hungry program will be running at a very low level of niceness of perhaps -20. By default, the niceness of most programs you start on a Linux computer is zero but you can make it nicer by typing:

nice -n myprogram &

where n is the niceness you want the program to run as. A niceness of 19 is suggested if the system is busy:

nice -19 myprogram &

Attempts by yourself to make your program run nastier - that is, less nice than default with a negative niceness - will fail as negative niceness numbers are reserved for the system administrator's use only. [Moral: always get to be on friendly terms with the sys admin of any UNIX/Linux system and he will nice up your jobs in ways you cannot :-)]

Once you have started your program and it is going to run for a long time, keep an eye on it and on what other users are doing on the same system. To find out how nice your job/program is, you can type:

ps -eo ni,args | grep myprogram | grep -v grep

and you will see something like:

7 myprogram

Here, myprogram is running with a niceness of 7.

If your job is not 'niced' (that is, running at the default Linux niceness of zero) and there are others running jobs niced to 10, 15 or 19, then it's good manners to 'renice' your job, which allows you to increase (but not decrease!) the niceness of your job while it is running. To do this, you first need to know the PID (or Process ID) of your program as the renice command works with PIDs rather than program names; since you know the name of the program (eg myprogram), you finds its PID on any Linux system by typing:

ps ax | grep myprogram | grep -v grep

and you will see something like:

3623 pts/49 S 0:17 myprogram

The number 3623 in the resultant output is the PID of myprogram. Now you can renice your program to, say, 15 with the command:

renice 15 -p 3623

Note that once you have reniced your program to a higher niceness, you cannot change it back to a less nice value. Nor can you renice anyone else's jobs!

Who else is using the same computer as me?

If you're curious to know who else is using the same system, or if you need to know how many others are running jobs so that you can be nice to them, simply type:


which will give you a simplified report on who is logged in, when they logged in and what computer they are logged in from. If you want more information, an even shorter command will give you a more verbose answer including the length of time the system has been running, how much system resources have been used by each user and the load average:


Other uesful commands are uptime which will tell you how long the system has been running for and the current load average and top which will give you a real-time listing of the current top 16 processes, refreshed every 3 seconds. top has a lot of options - both as parameters typed after the command and interactively when it is already running. Typing man top will tell you all about these but one of the more interesting interactive commands you can give most versions of top on a multi-processor Linux machine is to press the numeric 1 key on the main keyboard (not the 1 key on the numeric keypad as this won't work); by default, top starts up aggregating the processor cores on a system as a single CPU but pressing 1 will toggle a split display where the activity on each CPU core is shown individually. Pressing 1 again will return to the normal display.

Andy Thomas

Research Computing Manager,
Department of Mathematics

last updated: 10.5.2021