touch exercise03answers.txtor
vi exercise03answers.txt
# 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
# go to the directory, so I don't have to type so much later on cd 01234567890Different 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 fileB:
# use tools head -15 /etc/passwd | tail -9 # use cut and paste vi partpasswdC:
# use tools and redirection head -15 /etc/passwd | tail -9 > partpasswd
A:
# set permissions so that everyone can read and write the file, but # they cannot do anything else chmod 666 partpasswdB:
# change the permissions so that everyone will get read and write # access, but leave other permissions alone chmod a+rw partpasswd
# 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
# remove write access from all chmod a-w partgroup
--------- 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?
root | pat | les | dar | kai | tam | dod | |
dar1 | rwx | --- | --- | --x | --- | --- | --- |
les1 | rw- | -wx | r-- | -wx | -w- | -w- | -w- |
pat1 | rwx | rwx | rw- | rw- | rw- | r-x | r-x |
root1 | rw- | 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?
dar2 | rwx | -wx | -w- | r-- | -w- | -w- | -w- |
les2 | rwx | r-x | rwx | rw- | rw- | r-x | r-x |
pat2 | rwx | --x | --- | --- | --- | --- | --- |
root2 | rwx | -wx | -wx | -wx | --- | --- | -wx |
cd
cd /home/loginname
pwd
mkdir literature/classics
cd literature; mkdir classics
mkdir /home/alex/litarature/classics
rmdir literature/classics
cd literature; rmdir classics
rmdir /home/alex/literature/classics
rm -r literature/classics
cd literature; rm -r classics
rm -r /home/alex/literature/classics
Filesystem Size Used Avail Use% Mounted on /dev/hda3 2.7G 2.3G 342M 87% / /dev/hda1 7.6M 4.4M 2.9M 61% /boot /dev/hdc1 17G 2.2G 14G 14% /d2
ln: creating hard link `./dat2330_04w.tar' to `/d2/dat2330_04w.tar': Invalid cross-device linkCreating a symbolic link works without errors.
/bin/bash /bin/false /bin/sash /bin/sh /bin/sync /bin/tcsh
chmod u+rwx jobs_listor
chmod u=rwx jobs_list
drwx------ 2 root root 16384 Jun 19 2003 lost+found/ drwx------ 14 root root 4096 Feb 25 13:59 root/All the other directories provide r-x permissions. The above shown directories only give access to the user/owner of the directories (the root user).
command | owner (jenny) | group (pubs) | other |
cd correspond/business/milk_co | change current dir to correspond/business/milk_co | change current dir to correspond/business/milk_co | error message: current dir not changed |
ls -al correspond/business | error message: permission denied | error message: permission denied | error message: permission denied |
cat correspond/business/cheese_co | displays the contents of cheese_co | displays the contents of cheese_co | error message: permission denied |
touch ./-ian argument that starts with a dash is interpreted by the touch command as an option, not as a filename.
rm ./-i
ls -i | sort -n