* 1 *

The exercises this week are dedicated to the Linux command line using your Linux account at the student server studssh.cs.hioa.no or any other server running Linux. 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.cs.hioa.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 on paper.
Use Matt Disneys Linux crash course as an instructional reference. Another resource is Mark Burgess book: The unix programming environment (pdf)

(some more exercises for a Unix crash course are located at http://www.cs.hioa.no/~haugerud/unix/ if you need more practice.)

The assignment should be submitted individually. Submit using fronter(wait till your fronter room is available).

  1. 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.
  2. Access the manual page for the ls command. What does the -l option do?
  3. Print your working directory (your current location in the filesystem) using the command pwd.
  4. Change to the root ( / ) directory using cd. Confirm your location using pwd.
  5. Change back to your home directory.
  6. Go to the directory /usr/bin using absolute path.
  7. Go to your home directory. The go to the directory /usr/bin using relative path.
  8. Run ls. Now run ls -a. What is the difference in these two commands?
  9. Make a new directory using the command mkdir myfolder. Verify that it exists using one or more of the commands you learned earlier.
  10. Remove the directory you just created using the command rmdir myfolder. Verify that it no longer exists.
  11. 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.
  12. Use the utility cat to view the new file you just created.
  13. Use the utility cat to view the file ~dstud/twocolpaper.tex. What do you think the ~ represents?
  14. Now use the utility less to view the same file. What is the difference between cat and less?
  15. Copy that file to your home directory using the command cp.
  16. Create a new directory called testdir. Confirm that it exists.
  17. Move the twocolpaper.tex file to your new directory using the utility mv. Confirm that the move worked.
  18. Use the utility rmdir to remove the testdir directory. Why does that not work? What command will enable you to remove that directory?
  19. Use the command echo hello to print out the word hello.
  20. 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.
  21. Use the command "echo" to print the value of the SHELL variable.
  22. Assign your first name to the variable NAME. Use echo to print it.
  23. Use the editor jed to create a new file with some text of your choice: jed mytextfile.
  24. Now run the command jed MyTextFile. Where are the contents of the file you created in the previous step? What happened?
  25. 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!
  26. Create a shell script blah.bash which does the following things:
    1. Assign "/etc/default" to a variable
    2. Using ls and your new variable, output the list of files in /etc/default to the file blah.txt.
  27. 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.
  28. Using the output from /sbin/ifconfig, assign the IP-address of studssh to the variable $IP.
  29. Find which 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:
    #! /bin/bash 
    Make the script runnable with the command 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.
  30. 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 ( icmp_seq=1 Time to live exceeded
    2 From pil52-gw.uninett.no ( icmp_seq=1 Time to live exceeded
    3 From stolav-gw.uninett.no ( icmp_seq=1 Time to live exceeded
    4 From ge-0-2-0.br4.osls.no.catchbone.net ( icmp_seq=1 Time to live exceeded
    5 From ge-0-1-1.cr1.osls.no.catchbone.net ( icmp_seq=1 Time to live exceeded
    6 From v99.rs2.sand.no.catchbone.net ( icmp_seq=1 Time to live exceeded
    7 From icmp_seq=1 Time to live exceeded
    8 64 bytes from icmp_seq=1 ttl=249 time=1.31 ms
Write a short report answering the questions in a text file. Answer all the questions and submit them using fronter(log on at http://www.hioa.no/fronter and choose engelsk(english) as language), using the folder "Assignment 1". 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.