Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
System
Introduction
The first part introduces the local services. Even if you know
Unix you should read this section.
The second part introduces Unix. We hope there is enough
there to keep you afloat until you can attend the Universitys
Introduction to Unix course.
The third part is a glossary of Unix terms. It will include some
extra commands not covered in part 2.
We have aimed to make all examples in this booklet work accurately
for new users. Old users may have slightly different setups but
should still find much of this booklet useful.
Your login-name on the Maths Linux system is your CRSid. Your
CRSid is generated from your initials and used by various systems
within the University e.g. Email (Hermes), Web authentication
(Raven).
This booklet uses crsid in place of your login-name in many of the
examples.
CRSid = Common Registration Service identifier.
Virus Checker
Please make sure any computers you use other than the department
computers have up-to-date virus checkers on them. The University
has a license for some products which you can use free of charge.
http://www.ucs.cam.ac.uk/support/anti-virus/
If your computer has a virus and is attempting to spread it to
other computers, we will have to disconnect it until the problem is
resolved.
Linux Computers
Windows Computers
Each pavilion has at least one public scanner and a number of public
printers. In general you have access to all of these. The webpage
below provides the locations and instructions for use of these.
http://www.maths.cam.ac.uk/computing/printing/
When a printer is flashing its orange maintenance light, the small
LCD display should tell you why. It may be out of paper, it may
have a paper jam (try to remove the jammed paper yourself, being
careful not to tear it) or it may be out of toner. Please change the
toner yourself if you feel confident to. Some pavilion secretaries
keep a supply of toners close by, and DAMTP toners are kept in
room BL.05 (basement of pavilion B). Old toners should be placed
in any of the black toner recycling bins and unwanted output in the
blue paper recycling bins.
If you are unable to resolve a printer issue yourself, please email
help@maths giving the name and location of the printer. If a printer
is out of toner and you cannot find a replacement cartridge please
speak to a secretary.
There are two poster printers. Please carefully check any conference
posters for errors before printing the final version on the poster
printer.
http://www.maths.cam.ac.uk/computing/printing/
poster.html
If a printer isnt working the best thing to do is remove your job from
the printer queue (use the lprm command) and send it to a different
printer.
If a PDF file wont print, try using a different PDF viewer.
To save paper, think before you print, print double-sided where
possible, and consider printing more than one page per side of A4.
Please use black and white printers where possible because the
colour printers cost three times more to print the same black and
white page.
Be careful to use the correct media for overheads/transparencies as
the wrong ones can melt inside the unit, make it unusable for several
days, and cost both time and money to remove.
We do not charge for printing, instead we expect responsible usage.
http://www.maths.cam.ac.uk/computing/printing/
cant_print.html
http://www.maths.cam.ac.uk/computing/printing/
rules.html
Remote Access
Whichever departmental Linux computer you log into you will see
the same files (home directory) and the same environment. If your
office is moved, there is no need to move your computer.
To connect to a departmental Linux computer from any Windows
machine, use Winex which will give you the same graphical
environment as when sitting at the Linux computer.
http://www.maths.cam.ac.uk/computing/win7/winex.
html
The Linux computers shut themselves down when idle and unused
to save energy, but ssh.maths.cam.ac.uk is always switched on.
We have further information on this topic at
http://www.maths.cam.ac.uk/computing/remoteaccess/general.
html
If you are using a laptop and want to see your department home
directory from it see:
https://www.maths.cam.ac.uk/computing/laptops/
homedir.html
10
Your home directory (where you store files by default) has a quota
and is backed up regularly. If you delete or overwrite a file you
wanted please refer to
http://www.maths.cam.ac.uk/computing/files/
backups/deletedfile.html
Up in the top right hand side of your desktop is a quota icon. If you
hover your mouse over the square with a percent in it, you will see
how much quota you have and how much you are using. The quota
command will give you the same information from the command
line.
Keep an eye on the files you download and create. By default
these are placed in the Downloads or Desktop subdirectory of your
home directory, and their disk usage soon mounts up. Items in your
Wastebasket or Recycle Bin also count towards your quota. You
need to empty the Wastebasket or Recycle Bin to completely remove
them.
http://www.maths.cam.ac.uk/computing/files/quota.
html
11
You have access to additional file space in the store spaces. These
have no quotas and only limited backup (two weeks of). Like your
home directory, the store spaces are accessible from any department
Linux computer.
We also have scratch spaces which are the hard disks of different
computers and are accessible only from the computer itself. These
are wiped when a computer is reinstalled. They are useful if you
want to write a file directly instead of across the network.
For how to use store and scratch space see:
http://www.maths.cam.ac.uk/computing/files/scratch.html
12
13
14
Email Lists
15
Computing News
16
Software
The UCS also sells software, but generally not for personal use so it
is best to ask us to order any software you need.
17
Scientific Computing
http://www.maths.cam.ac.uk/computing/hpc_sci/
http://www.maths.cam.ac.uk/computing/mpi.html
You can search for Scientific Computingtraining courses at
http://www.training.cam.ac.uk
18
19
Privacy
All files you create on the department system are by default private
(readable only by you) and your email is also private.
If you want new files you create to be readable by other people, edit
the line at the end of your .bashrc file
umask 0077
to read
umask 0022
It is expected that people will not look at files not belonging to them
which they have no good reason to look at.
In Part 2 of this booklet we explain more about how to change who
can read your files.
20
Purchases
If you wish to buy a computer from your research grant funds, please
first check
http://www.maths.cam.ac.uk/computing/buying/
Then contact help@maths.
The University is a member of SUPC, which in summary means it
can purchase some hardware at discounted prices.
http://www.ucs.cam.ac.uk/support/
hardware-support/hwoverview
Broken Computers
The department fixes its own broken computers. Please email us if
your computer is broken, as we have no way to distinguish a broken
machine from one which is simply turned off.
For personal computers, a department computer officer may take a
quick look at your broken hardware (time dependent).
21
Sharing Resources
In store and scratch spaces, look at the total space available (df -h .).
Archive and compress or remove your files as you finish with them.
When a space fills a lot of people are inconvenienced.
Please remove personal data from the system before you leave.
It is impossible for the computing staff to know which files left
behind are left intentionally to share with others, and which are
left by accident. Clearing files when you leave frees up space for
newcomers.
If you are using the shared software area, make sure you keep your
index file up to date so that others can see what software you are
sharing with them.
http://www.maths.cam.ac.uk/computing/software/
user-maint.html
Leave public computers in a good state and report any problems with
them to the helpdesk.
22
Miscellaneous
24
If you have not used Unix before (or only used it for web-browsing
and email) please attend the UCS Introduction to Unix Course as
soon as possible. We strongly recommend this course.
The course runs over two half day sessions and is repeated several
times throughout the year.
http://www.training.cam.ac.uk/ucs/event/721643
For more advanced use of the shell and command line, please attend
the Simple Shell Scripting For Scientists course.
http://www.training.cam.ac.uk/ucs/event/722116
There are also courses offered in scientific computing.
To sign up for a course, start from
http://www.training.cam.ac.uk/ucs/theme
and choose the topic from the left-hand menu e.g. Unix (including
Linux) Systems & Use or Scientific Computing.
You will need your Raven password to sign up.
We have a Quick Reference List of Unix Commands online:
http://www.maths.cam.ac.uk/computing/linux/unixref.html
Starting
26
Shortcuts
The cursor keys (left and right, up and down) allow editing of the
current command and recalling of previous commands in an intuitive
manner.
Note also that pressing {TAB} when part-way through typing a file
name will cause the rest of the file name to be filled in automatically
if it is unique. This trick also works for command completion (type
his then press {TAB}).
The wild cards ? and * can be used to stand for any one character,
and any string of characters respectively:
# ls lists files, rm removes (deletes) files
$ ls
a.dat b.dat results.dat write-up.txt
$ ls ?.dat
a.dat b.dat
$ ls *.dat
a.dat b.dat results.dat
$ ls *
a.dat b.dat results.dat write-up.txt
$ rm *
$ ls
$
In this way the CLI is much more powerful than using the mouse
and the file-manager.
rm * should be used with considerable caution.
rm -r * should be used with EVEN more caution as the -r means
a recursive removal of all files and directories.
27
Filenames
The only character which is absolutely forbidden in a Unix filename is /, because this
separates the components of a path like /home/eva/test files.
28
29
From the CLI programs which are on your PATH are started by
typing their name:
$ firefox &
(the & sign causes a background process. This means you get
your prompt back immediately so that you can start other programs
without waiting for the firefox program to exit.)
The PATH and where a program is found on the PATH can be seen
with
$ echo $PATH
$ type firefox
Not all the locations you will put programs are on your PATH. To
start a program you have downloaded (e.g. with firefox):
$ cd Downloads
$ ./prog-01
(Without the & this is a foreground process. This will run the
program from the CLI and only return you to the shell prompt when
the program finishes/exits.)
You will learn more about this on the recommended CLI course.
30
Home Directory
31
Quota
As explained in Part One your Home Directory has a quota. The icon
at the top right hand side of your screen shows your quota usage.
Alternatively you can check your quota with the CLI:
$ quota
Disk quotas for user evatest3 (uid 1016):
Filesystem blocks
quota
limit
grace
rpc-serv1.maths.cam.ac.uk:/local/home/stats
83972 2097152 2097152
files
1337
32
quo
Hidden Files
33
http://www.maths.cam.ac.uk/
computing/linux/unixinfo/perms.html
34
By default no-one else can read any of your files. To make all
your new files readable by everyone else on the system, replace the
umask line at the end of your .bashrc with
umask 0022
To make an existing directory and everything in it readable by
everyone else, type
chmod -R go+rX my_directory
CAUTION: Dont do this for your home directory. Some computergenerated hidden files may contain passwords or other confidential
information.
35
$ ls -l thesis.tex
-rw-r--r-- 1 crsid
group
rwrr 1 mjr19
Access permissions
File owner
3410 Oct
12 15:13 thesis.tex
2 15:13 thesis.tex
Length (bytes)
Files group
File type
normal file
tcm
3410 Oct
File name
Link count
d directory
l link
Access permissions:
File
r Readable
w Writable
x eXecutable
Directory
ls works
File deletion and creation work
Can access files within directory.
36
Creating Documents
37
LATEX
# Create file.dvi
# View file.dvi
# Print file.dvi to printer ps2
pdflatex file.tex
evince file.pdf
# Create file.pdf
# View and optionally print file.pdf
The # sign indicates that the rest of the line is a comment which the computer will ignore.
You do not need to type these, but if you are cutting and pasting from an electronic form of this
booklet it is harmless to leave them in.
38
Viewing files
For text files there is no need to open an editor just to view their
content. To view a file using the mouse, double click on that file. If
this fails, right-click and choose a program to view the file with.
To view a text file with the CLI use the command cat or less.
less will show you the file page by page while cat will display
the whole file at once and you may need to use the terminal scroll
bar to see the beginning of the file.
For non-text files like PDF files, use the appropriate installed
software readers, for example evince for PDF files:
$ evince thing.pdf &
If you do not know what to use to open the file try using:
$ xdg-open thing.jpg
cat is also useful for merging the content of two or more text files.
$ ls
paper1.txt paper2.txt
$ cat paper1.txt paper2.txt > papers-combined.txt
$ ls
paper1.txt paper2.txt papers-combined.txt
Use > to send output to a file, and >> to append output to a file.
Use | to send the output to the input of another command.
For example to display all processes, one page at a time:
$ ps -A | less
39
40
Tidiness
results.dat
thesis.tex
results.dat
thesis.tex
For the adventurous you can remove directories with contents (and
all sub-directories) using the rm command with the -rf options:
$ rm -rf stuff
Be careful!
To create a new sub-directory using the graphical interface open your
Home Folder then File Create Folder.
41
Where Is It?
If you created a file but you cant remember where you put it, there
are various search mechanisms.
find is a standard Unix command, hlocate is a local command which
searches your home directory. You can use either of the following
two commands to search for a file with thesis in its name:
find -name "*thesis*" -print
hlocate thesis
You can also search by content, although this is slower than
searching by name as the shell needs to look inside every file. To
search for a file within the current directory which contains the word
Internet:
find . -type f -print | xargs grep Internet
More on searching for files:
http://www.maths.cam.ac.uk/computing/files/finding.html
If it turns out that the file was deleted rather than simply mislaid, see
the earlier page on backups.
http://www.maths.cam.ac.uk/computing/files/
backups/deletedfile.html
42
Trees
Directories form a tree: each directory has one parent directory, and
may have multiple sub directories. A file name is assumed to refer
to the current directory. Other locations can be specified by forming
a path using / to separate the components of the path, .. to refer
to a directorys parent, . to start a relative path and / to start an
absolute path.
$ ls -F
a/ results.dat
$ cp results.dat a/results.dat
$ ls -RF
.:
a/ results.dat
./a:
results.dat
$ ls ./a
results.dat
$ mkdir b
$ cd b
$ cp ../a/results.dat .
$ cd ..
44
Sharing Resources
45
Large Files
Data files tend to be large. Often too large for storing in your home
directory. Programs that write data to your home directory may quit
unexpectedly when your quota fills up. store areas, described in
Part 1, are dedicated storage typically used for long term storage of
data.
To see which store areas you have access to, type store-space.
Everyone has access to their departments store area and some
research groups have paid for store areas of their own.
To create your store space in one of the areas listed, type e.g.
store-space create DPMMS
This will create a directory /store/DPMMS/crsid which can then be
accessed with the cd command like any other directory.
Owing to the automounter only having the store areas actually in use
mounted at any given time, you cannot access /store/DPMMS via
the GUI without first going via the command line. To get around
this you can create what is called a symbolic link
$
$
$
$
cd
mkdir mydata
cd mydata
ln -s /store/DPMMS/crsid/ mystorespace
Now when you double click on your folder mydata, you will see
mystorespace. Double clicking on it will bring you direct to the
store space you created.
46
47
You can wake up computers from here if they are powered down.
To log into any Maths Unix machine from another:
$ ssh computer1
From a Unix computer outside Maths use an ssh client to connect
to the full name e.g. ssh.maths.cam.ac.uk (which is always
switched on).
$ ssh -C -Y crsid@ssh.maths.cam.ac.uk
Sometimes options need to be passed to ssh. For example -Y when
running remote graphical applications like matlab or firefox and -C
to compress data if your home broadband is slow.
For Windows computers putty is the recommended ssh client.
Note: this will only give you a text-based session. If you want a
graphical session use Winex instead.
http://www.chiark.greenend.org.uk/sgtatham/putty/
http://www.maths.cam.ac.uk/computing/win7/winex.html
http://www.maths.cam.ac.uk/computing/remoteaccess/general.
html
48
File Transfer
Copy files from your laptop to a Maths data area (this copies the
directory laptop data into /data/septal/crsid):
laptop$ rsync -avz \
laptop_data ssh.maths:/data/septal/crsid/
Note that the EOL \ means the command continues on the next line.
See also
http://www.maths.cam.ac.uk/computing/files/
linux_file_transfer.html
49
Conclusion
Leaving learning these skills until the last minute when you have
a thousand data files to manipulate and no time to learn, means
repeating the same action over and over and over and over. . . . The
shell and CLI provide tools to greatly simplify this sort of activity.
50
This section lists some useful command and summarises their use.
To find out more about any of them run man command-name or use
google.
There are lots of additional programs under the Applications menu
on your desktop.
awk
Manipulates files.
bash
Default shell. Look for Bash unix shell on wikipedia for a brief
history and list of keyboard shortcuts. For more information man
bash.
bunzip2
Uncompress a file.
bzip2
Compress a file to save space.
cal
Shows this months calendar. For the whole year run cal 2016.
cd
cd when run on its own changes to your home directory.
51
kile
GUI LATEXprogram.
kill
kill pid Ask a process to exit.
kill -KILL pid Tell a process to exit.
killall program-name
Causes all instances of program to be killed.
less filename
View a file, page at a time. Keystrokes include:
Open a file. This program will take a guess at what file type a file is
and open it with the appropriate piece of software.
xterm
Opens a new command shell in a window.
59
*, 27
/, 43
?, 27
>, 39
>>, 39
xdg-open, 39
xterm, 29
xv, 44
backups, 11
cat, 39
cd, 31, 41
chmod, 34
cp, 40
evince, 39
groups, 34
home directory, 31
kill, 44
killall, 44
less, 39
ls, 31, 36, 43
mkdir, 41
mv, 40
path, 30
permissions, 36
ps, 44
rm, 27, 40, 41
rmdir, 41
terminal, 29
text editors, 37
wild cards, 27
60