* 1 *
The exercises this week are dedicated to the Linux command line using your Linux account at the student server studssh.iu.hio.no. If you are not able to access this server yet, use the Linux server at UiO, login.ifi.uio.no with the username and password you got from the University of Oslo. For those of you who are familiar to Linux command line, there are some extra challenges and the bottom of this page. Finally you should log on to, explore and get used to your network of virtual machines. .
Complete the following exercises by logging in to your account at the server studssh.iu.hio.no(or login.ifi.uio.no) from any of the Windows PC's using putty and the same username and password as for Windows.
Document the commands your run and the output that appears on the screen.
You may want to use the script-command to do this. Where there is a question, answer it. NB: "print" refers
to displaying something in your terminal, not actually printing it out
(some more exercises for a Unix crashcourse are located at
http://www.iu.hio.no/~haugerud/unix/ if you need more practice. In the extra Linux class, Mondays 14:45-16:30 in PH424, we will work on these Linux assignments.)
Use Matt Disneys Linux
crashcourse as an instructional reference. Another resource is
Mark Burgess book:
The unix programming environment
The assignment should be submitted individually. Submit using fronter(wait till your fronter room is available).
Write a short report answering the questions in a textfile.
Answer all the questions and submit them using classfronter(log on at
http://www.hio.no/fronter and choose engelsk(english) as language),
using the folder "Obligatory assignment, 1st week". Any format is
accepted, preferably PDF or ascii-text. If you submit using a editable
format, like ascii, odt or doc, you may receive comments within the
text from the teachers. Submit the complete assignment in a single document.
- Read the manual page for the script command by man script.
If you run the command script week1.txt everything you type and its output will
be stored in the file week1.txt. Find out how to stop the script session.
- Access the manual page for the ls command. What does the -l option do?
- Print your working directory (your current location in the filesystem)
using the command pwd.
- Change to the root ( / ) directory using
cd. Confirm your location using pwd.
- Change back to your home directory.
- Go to the directory /usr/bin using absolute path.
- Go to your home directory. The go to the directory /usr/bin using relative path.
- Run ls. Now run ls -a. What is the
difference in these two commands?
- Make a new directory using the command mkdir myfolder. Verify
that it exists using one or more of the commands you learned earlier.
- Remove the directory you just created using the command rmdir myfolder.
Verify that it no longer exists.
- Create a new file by using the jed editor: jed myfile. (If jed is not installed, use emacs, pico or nano). Type "Hello world!"
in your text document. Be sure to save it.
- Use the utility cat to view the new file you just created.
Use the utility cat to view the file ~dstud/twocolpaper.tex. (At login.ifi.uio.no, view
the file ~haarekh/twocolpaper.tex).
What do you think the ~ represents?
- Now use the utility less to view the same file. What is the difference between
cat and less?
- Copy that file to your home directory using the command cp.
- Create a new directory called testdir. Confirm that it exists.
- Move the twocolpaper.tex file to your new directory using
the utility mv. Confirm that the move worked.
- Use the utility rmdir to remove the testdir directory. Why does
that not work? What command will enable you to remove that directory?
- Use the command echo hello to print out the word hello.
- Use the same command, but add the following to create a file containing the word hello: "> hellofile". Confirm that your new file contains the appropriate text.
- Use the command "echo" to print the value of the SHELL variable.
- Assign your first name to the variable NAME. Use echo to print it.
- Use the editor jed to create a new file with some text of your choice: jed mytextfile.
- Now run the command jed MyTextFile. Where are the contents of the file you created in the previous step? What happened?
- Determine how to display the date for the Orthodox Easter using the ncal. Put this command in a text file called myscript. Run sh myscript. Congratulations, you have written your first shell script!
- Create a shell script blah.bash which does the following things:
- Assign "/etc/default" to a variable
- Using ls and your new variable, output the list of files in /etc/default to the file blah.txt.
- Change the file permissions of blah.bash so that the
owner has all permission to to anything (and can run it by $
./blah.bash), the group may read and run it and all others may
just read the file.
- Challenge: Using the output from /sbin/ifconfig,
assign the IP-address of studssh to the variable $IP.
Mapping your virtual network
- Start by reading the document HowToConnectToVM.pdf located under Resources in fronter and make sure you are able to log on to the gateway of your network using ssh and VNC . Make sure you also are able to log on to the Windows VM using Remote Desktop and VNC.
- Log on to your gateway using putty or from a Linux console window using ssh as the 'group13' user where you should exchange 13 with your group number. Check that you are able to gain root priviliges using the sudo command. Learn about sudo searching the net and reading the man pages if you are not familiar with it.
Investigate your network and draw a map of it.
Start at the gateway doing
to see which network interfaces are connected. Then you should use nmap in order to find the IP's of your subnet. You
will need to install nmap by
sudo apt-get install nmap
After you have installed nmap you should do
group1@gateway:~$ nmap 10.0.0.*
Then you will see your available IP's and their services. Connect to all these IP's using ssh and the same username/password
as for the gateway. Use ifconfig and nmap at the new IP's and draw a complete map of your network including name, IP,
services running, name of network interfaces and how they are connected. Identify all subnets of the network and specify their
Extra challanges for the command line savvy (not obligatory, but interesting!)
Find whitch program is started when you give the
commands ls. (hint: Try $ type ls).
Edit a file in your home directory with jed
and call it ls. Write in the following shell-script:
Make the script runnable with the commmand chmod 755 ls.
Write the command
ls in the shell. Is it "your" or the system ls that is
executed? Add the line
echo This is my ls script. to your ls.
run the ls-command again and try to make the system list the files
with your script.
- Make your own traceroute-command by writing a short bash script which utilizes
the response to ping-packets with an increasing TTL-value, starting from one:
ping -w 1 -c 1 -t 1 vg.no | grep icmp
The output could be similar to this
studssh$ mytrace vg.no
1 From cadeler30-gw.uninett.no (188.8.131.52) icmp_seq=1 Time to live exceeded
2 From pil52-gw.uninett.no (184.108.40.206) icmp_seq=1 Time to live exceeded
3 From stolav-gw.uninett.no (220.127.116.11) icmp_seq=1 Time to live exceeded
4 From ge-0-2-0.br4.osls.no.catchbone.net (18.104.22.168) icmp_seq=1 Time to live exceeded
5 From ge-0-1-1.cr1.osls.no.catchbone.net (22.214.171.124) icmp_seq=1 Time to live exceeded
6 From v99.rs2.sand.no.catchbone.net (126.96.36.199) icmp_seq=1 Time to live exceeded
7 From 188.8.131.52 icmp_seq=1 Time to live exceeded
8 64 bytes from 184.108.40.206: icmp_seq=1 ttl=249 time=1.31 ms