Q: 1. Create a file called "exercise03answers.txt"
A:
e.g.
touch exercise03answers.txt
or
vi exercise03answers.txt
Q: 2. At the top of the file, use the label as defined before.
A:
as before
 
Q: 3. Put on a line the word "lab" by itself, then work on lab exercises 1-5 below. List all the relevant commands and arguments that you had to use in the lab exercises. Put in comments to show why you did something (this can help your mark even if you did something wrong).
A:
in sequence
  1. In my directory on the course linux server (my username is "gj"), is a directory called "public_html/dropbox". In this location, create a directory the name of which is your studentid. Set the permissions on this directory to 700.
    # go to the directory, so I don't have to type so much
    cd ~gj/public_html/dropbox/
    
    # create directory, where my studentid is 01234567890
    mkdir 01234567890
    
    # set the permissions as indicated with chmod
    chmod 700 01234567890
  2. In the directory you have just created, put a copy of lines 7-15 of the password file into a file called "partpasswd".
    # go to the directory, so I don't have to type so much later on
    cd 01234567890
    Different options:

    A:

    # copy original file
    cp /etc/passwd partpasswd
    # edit file
    vi partpasswd
    6dd9j100dd:w
    # = delete lines 1 to 6, go 9 lines down, remove 100 lines, write file
    B:
    # use tools
    head -15 /etc/passwd | tail -9
    # use cut and paste
    vi partpasswd
    C:
    # use tools and redirection
    head -15 /etc/passwd | tail -9 > partpasswd
  3. Change the permissions on "partpasswd" so that everyone can read and write the file, but nothing else.
    NOTE: this was an ambiguous question, so both the following answers are correct:

    A:

    # set permissions so that everyone can read and write the file, but
    # they cannot do anything else
    chmod 666 partpasswd
    B:
    # change the permissions so that everyone will get read and write
    # access, but leave other permissions alone
    chmod a+rw partpasswd
  4. Create a new file called "partgroup". Every line should contain one GID followed by a space, followed by the name of the group. List ONLY the GIDs that appear in "partpasswd". Make sure the list is sorted numerically, and remove duplicates.
    # copy partpasswd to a new file
    cp partpasswd partsolved
    # use vi, and edit
    vi partsolved
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j0
    6dwwd$j
    :w!
    
    # sort and remove duplicates
    sort -u partsolved > partgroup
    
    # cross reference the numbers by grepping for them in /etc/group
    grep 0 /etc/group
    grep 12 /etc/group
    etc...
    
    # put the entries in the file with vi
    vi partgroup
  5. Remove all write access from "partgroup".
    # remove write access from all
    chmod a-w partgroup
Q: 4. Put on a line the word "notes" by itself, then answer the questions from the course notes file called "permissions.txt"
A:
in sequence
---------
Exercises
---------

Given the following inode permissions:

    ---x------    1 dar      staff         123 Apr  1  2003 dar1
    dr---wx-w-    1 dar      dat2330       512 Apr  1  2003 dar2
    -r---wx-w-    1 les      dat2330       123 Apr  1  2003 les1
    drwxrw-r-x    1 les      alumni        512 Apr  1  2003 les2
    -rwxrw-r-x    1 pat      alumni        123 Apr  1  2003 pat1
    d--x------    1 pat      staff         512 Apr  1  2003 pat2
    -rw-r--r--    1 root     system        123 Apr  1  2003 root1
    drwx----wx    1 root     system        512 Apr  1  2003 root2

And these users:

    root - super user
    pat  - in groups "student" and "dat2330"
    les  - in groups "alumni" and "staff"
    dar  - in groups "alumni" and "dat2330"
    kai  - in groups "alumni" and "system"
    tam  - in groups "system" and "staff"
    dod  - in groups "nobody"

Answer these questions:

*)  What type of inode is each file?  (directory, file, other...)
Every name that ends with the number "1" is a file, every name that end with the number "2" is a directory.
*)  What permissions do each of the users have on each file inode?
    - which set of permissions apply to each user?
    - can the user read the file?
    - can the user write the file?
    - can the user execute the file?
 rootpatlesdarkaitamdod
dar1rwx--------x---------
les1rw--wxr---wx-w--w--w-
pat1rwxrwxrw-rw-rw-r-xr-x
root1rw-r--r--r--r--r--r--
*)  What permissions do each of the users have on each directory inode?
    - which set of permissions apply to each user?
    - can the user read the directory names?
    - can write the directory (create new names, delete names, rename)?
    - can search (pass through) the directory to the contained inodes?
dar2rwx-wx-w-r---w--w--w-
les2rwxr-xrwxrw-rw-r-xr-x
pat2rwx--x---------------
root2rwx-wx-wx-wx-------wx
 
Q: 5. Put on a line the word "book" by itself, then answer questions 1-4 and 6-10 from the book, chapter 4, pages 103-105.
A:
in sequence
 
Q: 6. Put on a line the word "advanced" by itself, then answer questions 12, 13, 15 and 18, chapter 4, pages 105-106.
A:
in sequence
 
Q: 7. Submit using the datsubmit command
A:
datsubmit 03 exercise03answers.txt