CS2718 Assignment 4

Your Name -- Your Student Number

Complete this assignment by downloading this HTML file and editing it (using a text editor---not a special HTML editor). Wherever you see emphasized text (e.g. "Your name" and "Your Student Number" above) you should insert your own text, as appropriate. Submit via D2L by 5:00 p.m. on Wednesday, February 17.

BASH history

Using the manpage, man history, explain the command expansion of the following history substitutions:

  1. !!

    *Change this with your answer

  2. !-4

    *Change this with your answer

  3. !ls

    *Change this with your answer

  4. !34

    *Change this with your answer

Emulating the History Expansions

Assuming that the .bash_history file contains the most recent version of your bash history. Give commands (possibly including pipelines) which will do the same as the following history expansions. To put this another way, lets say that the history expansions were disabled. How could you re-create them? Note that your commands should simply display the corresponding history entry, but do not need to execute them.

  1. !!

    *Change this with your answer

  2. !-4

    *Change this with your answer

  3. !ls

    *Change this with your answer

Permissions: What's Allowed?

On Ubuntu 14.04, determine if the following are allowed or not allowed. Assume each command is independent. If not allowed, provide a brief explanation why.

  1. rm -rf /etc

    Change with your answer

  2. mkdir -p /tmp/foo/bar

    Change with your answer

  3. cd /tmp; touch foo; chmod a-rwx foo; rm -fr foo

    Change with your answer

  4. cd /tmp; mkdir goo; touch goo/bar; chmod a-w goo; rm -fr goo/bar

    Change with your answer

  5. echo hi > /bin/ls

    Change with your answer

Permissions: Octal Syntax

For each exercise part, replace the sequence of chmod commands with one chmod that uses the octal syntax. You can assume that "file" is created from scratch for each command.

  1. touch file; chmod a=rwx file; chmod a-r file

    *Change this with your answer

  2. touch file; chmod a=rwx file; chmod go-rwx file

    *Change this with your answer

  3. touch file; chmod a=rwx file; chmod go-rwx file; chmod g+r file

    *Change this with your answer

  4. touch file; chmod 0000 file; chmod u+rw file;

    *Change this with your answer

umask and Permissions

User alice types the following commands:

alice% umask 0007
alice% cd /tmp
alice% mkdir top-dir
alice% chmod o-rw top-dir
alice% chmod o+x top-dir
alice% chmod ug=rwx top-dir
alice% echo "A message" > top-dir/msg
alice% chmod 0000 top-dir/msg
alice% mkdir top-dir/test
alice% chmod 0707 top-dir/test
alice% echo "Hi There" > top-dir/test/hi
alice% chmod a+rw top-dir/test/hi

Determine if the following commands are allowed (i.e., is there sufficient permission) or not allowed. If they are not allowed, provide a brief explanation.

  1. User bob tries the following command. bob is in the same group as alice. (hint: /tmp/top-dir/test permission is 0707).

    ls -l /tmp/top-dir/test
    

    Change this with your answer

  2. User bob tries the following command. bob is in the same group as alice.

    touch /tmp/top-dir/bob-was-here
    

    Change this with your answer

  3. User sue tries the following command. sue is not in the same group as alice.

    touch /tmp/top-dir/sue-was-here
    

    Change this with your answer

  4. User sue tries the following command. sue is not in the same group as alice.

    touch /tmp/top-dir/test/sue-was-also-here
    

    Change this with your answer

  5. User alice tries the following command.

    echo "another line" >> /tmp/top-dir/msg
    

    Change this with your answer

umask

Why is the umask 0000 command unsafe?

*Change this with your answer*