begin assgn3 bash PID info script
[assignments.git] / assgn2 / assgn2.sh
CommitLineData
5f59f2f7 1Ian 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
21cd /home/kremlin
22echo "Printing contents of home directory"
23ls -lah /home/kremlin
24echo "cd'ing to \"Desktop\" (although I'm using a tiled WM that doesn't support the XDG Desktop directory)"
25cd /home/kremlin/Desktop
26cd
27echo "Printing working directory"
28pwd
29echo "Creating \"Backups\" directory"
30mkdir ~/Backups
31echo "Writing name/SUID into /tmp/hw2"
32# I thought you meant something about the SUID permissions bit at first :)
33echo -ne "Ian Sutton\n417517518" > /tmp/hw2
34echo "Copying it to \"Backups\" folder"
35cp /tmp/hw2 ~/hw2
36echo "Removing original"
37rm /tmp/hw2
38echo "Listing contents of \"Backups\" folder"
39ls ~/Backups
40echo "Deleting \"Backups\" folder"
41rm -rf ~/Backups
42
43(4) See screenshots, script replicated here:
44
45#!/bin/sh
46
47echo "cd'ing to root directory"
48cd /
49ls -lah | grep bin
50echo "searching for file 'cpp' only one dir deep and displaying its file type.."
51find . -maxdepth 1 -type f -name cpp -exec file {} \;
52echo "printing the first 160 bytes of it in hex.."
53find . -maxdepth 1 -type f -name cpp -exec xd {} \; | head -c 160