Out: Tuesday’s group: Sept 13, 2016
Monday’s Group: Sept 19, 2016

Due: Tuesday’s Group: Sept 27, 2016 (start of lecture)
Monday’s Group: TBA
This assignment is marked out of 24 for Group D, 30 for group A. Group A has one additional question.

CENG200 - Lab 2: Security, Simple Web Pages

Preliminary Steps

  1. When you log in for this lab, perform the following actions (one time only)

cp ~king/.vimrc ~

chmod a+x . public_html

The 1st command modifies the behaviour of vim as described in class.

The 2ndmakes your public_html directory navigable as a web site - which you need in exercise 3.

  1. Create a new directoriessecurity1 and security2. Use the touch command to create files a b c d e and f in both directories.
  2. Use the id comamnd and record your alternate group at the top of your report. It should be one of:
    sharks minnows or dolphins

Lab Exercises

1)Wildcards in the Bash shell (1 mark each/6 marks)

Repeat from Lab 1 – removed.
Apply the following commands in the /usr/bin directory on munro.
Record the command used in each case. Record the number of files matched. by piping the result through the wc command. (I am not looking for an actual list of files)
eg (for all files): ls | wc -l

a)list the name of all the files in the /usr/bin directory that start with ls.

b)list the name of all the files in the /usr/bin directry that end with ls

c)list the name of all the files that start with the letter q and end with the number 3

d)list the name of all the files that consist of 2 letters where the 1st letter is in the range from d to p.

e)List the name of all the files that start and end with a vowel.

f)List the name of all the files that start and end with a vowel where the whole file name is only 4 characters long.

2)Using chmod with symbolic operators (6 marks)
Usingchmodwith symbolic operators: ugo+-rwx, alter the permissions on the files in security1 as follows. (Note - you aren't allowed to use the = symbol - that would be too easy!) If you set the permissions to a file incorrectly either remove and recreate the file so that it has it’s default permissions or reset the permissions using the = option. (6 marks)

  1. The file a should be readable by you and others, but not members of your group.
  2. The file b should be readable and writable by no-one, but executable by the owner.
  3. The file c should be readable and writable only by others, not by you or members of your group.
  4. The file d should have write permissions turned on for you and your group, but should only be readable and executable by others.
  5. The file e should be executable by you and others, but not members of the group students, who should be able to write to the file.
  6. The file f should have all file permissions turned on, except the owner should not be able to write to the file.

When you run ls -l on the files the permissions should appear as follows:
r------r--a
--x ------b

------rw- c

--w--w-r-x d

---x -w- --x e

r-xrwxrwxf

3)Repeat the previous exercise on the files in your directory security2 but use the chmod command using octal values instead of symbols. Record the commands used. (6 marks)

4)Creating a really really simple web page hello.html (2 marks)
In your public_html directory create a file hello.txt containing a humorous saying. Make sure that the following is true:

  1. The file hello.txt is readable by others
  2. Your public_html directory is executable (navigable) by others
  3. Your home directory is executable by others

Test that your web page is visible to the outside world by bringing it up on a browser on a different machine

There is no need to hand anything in. To check the status of your web page, view the following web page which is actually a script:

5)The finger command (4 marks)
For this exercise pick a partner with who is in a group that you are not a member of. For example, if you are a member of sharks, pick a partner who is a member of minnows or dolphins. Record who your partner is and their user and group ids.
Each of you should create a .project and a .plan file in your home directories. In .project describe some project that you are currently working on. In .plan describe a long term goal that you might have.
The finger command is: finger userid
Each partner should finger the other's account and try to view your .project and .plan files.
In each of the following steps record the chmod command used each time and answer the questions:

a)Change the access permissions of your .plan and .project file so that only other members of your group can read the file and so that you are not allowed to read your own files nor can others. Can you finger yourself and see the .project and .plan files? Can your partner do the same?
Are your plans and projects visible?

b)Change the group membership of the .plan and .project files to your alternate groups using the chgrp command. ie: chgrp whales .plan .project (Reminder: your partner is NOT in the same group as you.) Can you still apply the finger command to each other and see the .plan and .project files? Can your partner?

c)Change the permissions of the .plan and .project files so that the only one who can't read these files is yourself. Can you still apply the finger command to each other and see the .plan and .project files? Your partner?

d)What is the least privilege required so that everyone, including yourself can see your .plan and .project files?

6)Hard links and symbolic links. (6 marks, 1 mark each)
This question only applies to Monday’s Group. It will be given to Tuesday’s Group in assignment #3, though in slightly different form.
Record all commands used:

  1. Record your terminal’s tty. In your home directory try creating a hard link and a symbolic link to your terminal. Do both commands work? If either command fails record the error message.
  2. What is the inode # of the directory /usr and one of the directories in it?
  3. How many hard links are there to the directory /usr? How would you account for that number?
  1. In your home directory create a hard link and a symbolic link to one of the commands that you know how to use in /usr/bin. For each verify whether or not you can use your hard or symbolic link to execute the command.
  2. Create both a hard link and a symbolic link to the symbolic link you created in the previous step. If either of these work this introduces 2 levels of indirection which you can think of as: file2 -> file1 -> cmd
    Record the commands you used. Test and report on which (if any) of these secondary links can be used as an alias to the command
  3. Use the file command on each of the files created in step e. What does it report? Try again using the -L flag of the file command - refer to the man page for the file command and explain the results.