| 1 | Ian Sutton - CSE 384 - Sept 9 2014 |
| 2 | |
| 3 | (1) The root directory is uppermost directory mounted on a filesystem, |
| 4 | usually written as "/". It is the first directory to be mounted |
| 5 | during boot, and the only directory to be mounted in the case of |
| 6 | emergency maintenance if booted in single-user mode. It contains |
| 7 | all the mountpoints for the other filesystems if the OS splits |
| 8 | system directories into seperate partitions. |
| 9 | |
| 10 | (2) The home directory contains perhaps 1 directory per user, named |
| 11 | after the user it is for. It contains that user's personal files. |
| 12 | A user almost certainly has write privileges to his/her home |
| 13 | directory. It is usually abbreviated as ~, and the `cd` command |
| 14 | with no arguments will cd to the executing user's home directory, |
| 15 | if it exists. |
| 16 | |
| 17 | (3) See screenshots, script replicated here: |
| 18 | |
| 19 | #!/bin/sh |
| 20 | |
| 21 | cd /home/kremlin |
| 22 | echo "Printing contents of home directory" |
| 23 | ls -lah /home/kremlin |
| 24 | echo "cd'ing to \"Desktop\" (although I'm using a tiled WM that doesn't support the XDG Desktop directory)" |
| 25 | cd /home/kremlin/Desktop |
| 26 | cd |
| 27 | echo "Printing working directory" |
| 28 | pwd |
| 29 | echo "Creating \"Backups\" directory" |
| 30 | mkdir ~/Backups |
| 31 | echo "Writing name/SUID into /tmp/hw2" |
| 32 | # I thought you meant something about the SUID permissions bit at first :) |
| 33 | echo -ne "Ian Sutton\n417517518" > /tmp/hw2 |
| 34 | echo "Copying it to \"Backups\" folder" |
| 35 | cp /tmp/hw2 ~/hw2 |
| 36 | echo "Removing original" |
| 37 | rm /tmp/hw2 |
| 38 | echo "Listing contents of \"Backups\" folder" |
| 39 | ls ~/Backups |
| 40 | echo "Deleting \"Backups\" folder" |
| 41 | rm -rf ~/Backups |
| 42 | |
| 43 | (4) See screenshots, script replicated here: |
| 44 | |
| 45 | #!/bin/sh |
| 46 | |
| 47 | echo "cd'ing to root directory" |
| 48 | cd / |
| 49 | ls -lah | grep bin |
| 50 | echo "searching for file 'cpp' only one dir deep and displaying its file type.." |
| 51 | find . -maxdepth 1 -type f -name cpp -exec file {} \; |
| 52 | echo "printing the first 160 bytes of it in hex.." |
| 53 | find . -maxdepth 1 -type f -name cpp -exec xd {} \; | head -c 160 |