DICE-PG: DICE Introductory Exercise
Aim
This is an introduction to the DICE environment, and also to some basic Linux commands which are run from the command line. It is also a chance to check that your DICE account is working as expected.
You can do this exercise either remotely or sitting in front of a DICE desktop computer. This exercise is equally valuable either way. The only difference is that if you login remotely, you won't be waking up a DICE computer's screen and logging on at the console. The environment you get using the DICE remote desktop is very similar.
Check your DICE account
A DICE computer's screen may sleep when it's not being used, so you may first of all have to press the <escape> key or move the mouse to make the login screen appear.
Your username is the same as the username for any University system - that is, s followed by your matriculation number. You should have received an email asking you to set your DICE password. If you haven’t already done this, you will need to do it now, before you can go any further with this exercise. To set your DICE password visit the Informatics password portal.
After entering your username into the login screen, you can select which Window Manager you prefer from the drop-down menu at the top right-hand corner of the login screen. If you have no preference or are not familiar with Linux Window Managers then we recommend that you stay with the default, which is MATE. This exercise assumes that you are using the MATE environment. If you are using the remote desktop, MATE is the only environment available.
Once logged in, you should see menus called Applications and Places and System at the top left-hand corner, and a few icons in the top right-hand corner.
Open a terminal window
To enter commands at the command line, you need a terminal window. Open a terminal by either:
- Click Applications then System Tools then MATE Terminal.
- Right click on the desktop and click ‘Open Terminal’.
Some basic commands
How do I know which directory I am in?
In Linux, files are stored in a tree of directories. When using the command line, there is always a "current directory". That's the directory where your files will be put, if you don't specify some other location for them. We say that you are "in" the current directory. To find out which is the current directory, type the command:
pwd
(This stands for Print Working Directory.) It should return something like:
/afs/inf.ed.ac.uk/user/s21/s2198765
How do I see my files?
Type the command:
ls
This lists all the files and directories in the current directory.
Now try:
ls -al
This will give you additional information about the files – who owns them, date last edited, permissions etc.
You can also tell ls to look elsewhere. Now try:
ls -al /home/infteach
You can add additional ‘arguments’ to the command. Try the following to see how the output changes.
ls -alrt
What is the Yesterday directory for?
At the bottom the list (using ls -alrt), you will likely find a directory called Yesterday:
dr-x--x--x 314 username people 69632 Sep 11 12:00 Yesterday
The ‘d’ indicates a directory. This directory contains a backup of your home directory from the day before. It is read only, so you cannot create any files in it, but you can copy files from it that you have accidentally deleted. It does not count towards your quota.
What is my quota and how do I check it?
First year and second year undergraduates get a 4GB quota; other undergraduates get a 10GB quota. We use dynamic quotas to make better use of our available space. This means that we do not always give everyone their full quota all at once. We can increase quota as your disk usage increases to a maximum of 10GB. Try the following commands:
fs lq -human
freespace
How do I copy files?
To do this, use the ‘cp’ command. Its format is:
cp fromfile tofile
Copy the file /home/infteach/system/testfile1 to your home directory and call it example1. Note: The shortened form for your home directory is /home/sMATRIC (where sMATRIC means your username) - or even more simply ‘~’ (the tilde character).
How do I move to another directory?
Move to the infteach home directory (/home/infteach or ~infteach) using the cd command.
cd ~infteach
Once there, try ‘ls’. You should see a directory called ‘Files’. Move to that directory and see what files are there.
How do I view the content of files?
You can use the ‘less’ command to see the content of plain text files. Take a look at some of the files in /home/infteach/Files. If you see a message “ ... see it anyway ?”, just say “n”. You exit ‘less’ by typing ‘q’.
less filename
To get back to your own home directory, type cd (with no arguments).
How do I create a directory?
- Make sure you are in your own directory. Use pwd and cd to check!
- Create a directory called ‘examples’: mkdir examples
- Copy the file ‘example1' into the examples directory using cp.
How do I move/rename files?
You use the command ‘mv’.
- Rename the file ‘example1’ in your home directory to ‘assessment’ using the ‘mv’ command. The man command gives usage details:
man mv
- Move to the ‘system’ directory in the infteach home directory, and copy ‘testfile2' back into your ‘examples’ directory and call it ‘example2’.
How do I delete files and directories?
To delete files, you use the ‘rm’ command.
To delete directories, you use the ‘rmdir’ command.
- Delete the file ‘assessment’.
- Try to delete your new ‘examples’ directory. (You should get an error. Remove all the files in the directory then try again.)
How do I print files?
All the printers in Informatics buildings are ‘cloud’ printers. This means that you can collect your printout from any printer in the University. For more details see our printing help pages.
How do I edit files?
There a number of editors available on Linux. If you are not familiar with Linux, try nano.
More experienced users might prefer vim or emacs.
You can open (and create) Microsoft Office files using OpenOffice:
ooffice
We recommend you use evince to read pdf files.
If you are not sure what type of file you are trying to open, the ‘file’ command will tell you. For example,
file poster-us-unit.odt
returns:
poster-us-unit.odt: OpenDocument Text
Other examples to try
- Look at the manual page for ls (type man ls) and find out how to list your files in colour.
- Identify the most recently modified file in your home directory.
- How many characters does the poem file (~infteach/system/poem) have? (Check the wc command.)
There is a special character “|” (‘pipe’) that allows you to pass the output from one command to another by placing it between 2 commands.
- Roughly how many files and directories do you have in your home directory?
- How many files are in the ~infteach directory (top level)?
Summary of commands
Command | Description |
---|---|
fs lq | Gives details of quota |
ls | Lists/gives details of files in a given directory |
man | Man gives on-line help |
cp | copies files from one location to another |
mv | moves/renames files |
less | views content of plain text files |
evince | pdf reader |
mkdir | creates directories |
rm | removes files |
rmdir | removes directories |
lpr | Print from the command line |
cd | Change directory |
passwd | The command to change your password |