CIS 90 - Lesson 7 Lesson Module Status Slides – draft Properties - done Flash cards – No-stress quiz – Web Calendar summary – Web book pages – done Commands – done Lab – Supplies – Class PC's – NA Hide script – Next class 1
CIS 90 - Lesson 7 Quiz Please close your books, turn off your monitor, take out a blank piece of paper and answer the following questions: What option for the rm command provides confirmation when deleting files? What command is used to rename a file? If two files are hard linked do they have the same or different inode numbers? 2
CIS 90 - Lesson 7 ObjectivesAgenda Be able to reassign user and group file ownerships Identify permissions for ordinary and directory files Use chmod to set and change file permissions Define the default permissions for new files Quiz Review test results Question on previous material File permissions Wrap up = hands on exercise for topic File Permissions 3
CIS 90 - Lesson 7 Housekeeping 4
CIS 90 - Lesson 7 Test 1 – Most Missed Questions ; and filename expansion 26-15pathname and filename expansion 31-12using type to find location of command 27-11pathname 20-11shell operation d option for ls 24-10pathname directory structure 30-8/bin/mail 17-8using man command to get an option 33-7/bin/mail 22-7PS1 and the Opus prompt 19-7using type to find location of command 23-6display value of a variable 34-5head command 35-5file command 09-5/etc/passwd file usage 32-4wc command 28-4/etc/passwd pathname 25-4file tree navigation and.. hidden files 08-2/bin/mail 02-2long listing 01-1shell 21-1 shell operation 13-1shell operation 11-1/bin/mail 10-1history of Linux 07-1PS1 and prompt string 05-1inodes 04-1Linux architecture 16-0displayed prompt 14-0hostname command 12-0file structure 06-0SSH Question#-#students with incorrect answer
CIS 90 - Lesson 7 Test 1 – Most Missed Questions 6 Q29 XXXXX XXXXX XXXXX From your home directory change to the Poems/Yeats/ directory. What one-liner command would clear the screen and print the last line of all three Yeats poems without having to type the names of each individual poem file name? clear; tail -n 1 * Q26 XXXXX XXXXX XXXXX From your home directory, using an absolute pathname, what complete command would you use to do a long listing of the files in /usr/bin that start with a p and end with a y? ls -l /usr/bin/p*y Q31 XXXXX XXXXX XX In what directory is the crash command found? /usr/bin/ (use type crash)
CIS 90 - Lesson 7 Test 1 – Most Missed Questions 7 Q27 XXXXX XXXXX X What is the relative path from your home directory to the file /bin/mail ?../../../bin/mail (test with ls../../../bin/mail) Q20 XXXXX XXXXX X Type the command cat /etc/password. Which program writes the error message? cat Q18 XXXXX XXXXX X What is the inode number of the /home directory? (use ls –id /home) Q24 XXXXX XXXXX From your home directory, what single command would print the last line of Shakespeare’s sonnet5 using a relative path? tail -1 Poems/Shakespeare/sonnet5 Q3 XXXXX XXXXX UNIX directories are like phone books. Instead of names and phone numbers they contain? Filename and inode numbers
CIS 90 - Lesson 7 Test 1 – Most Missed Questions 8 Q30 XXXXX XXX Calculate: (23^2 * 4 – 100) – sqrt(64) and (using /bin/mail) the answer to rsimms /home/cis90/simmsben/Poems/Yeats $ bc bc 1.06 Copyright , 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. (23^2 * ) - sqrt(64) 2008 quit $/home/cis90/simmsben/Poems/Yeats $ mail rsimms Subject: Q Cc: /home/cis90/simmsben/Poems/Yeats $
CIS 90 - Lesson 7 Test 1 – Most Missed Questions 9 Q17 XXXXX XXX Using uname, what is the release of the Linux kernel you are using? generic (use man uname and uname –r) Q33 XXXXX XX How can you keep a copy of messages you send with /bin/mail? cc: yourself at the end Q22 XXXXX XX What complete command would change your Frodo prompt to match your prompt on Opus (which displays the current working directory)? PS1=’$PWD $ ’ Q19 XXXXX XX In which directory of your path is the man command found? /usr/bin (use type man) Q23 XXXXX X What is the value of your $PS1 environment variable? $PWD $(use echo $PS1)
CIS 90 - Lesson 7 Test 1 – Most Missed Questions 10 Q34 XXXXX What is the very first line of the file /usr/share/doc/python /README? This is Python version 2.4 (use head -1 /usr/share/doc/python-2.4.3/README) Q35 XXXXX What kind of a regular file is /boot/grub/fat_stage1_5? data (use file /boot/grub/fat_stage1_5) Q9 XXXXX In what file are all the user accounts stored? /etc/passwd
UNIX File Tree Pathname Practice CIS 90 - Lesson 7 home cis90 cis191 bin var simmsben roddyduk homer sbin etc lib boot usr bin cal apropos bin ls Poems mission letter ant / / passwdmail bin banner 11
CIS 90 - Lesson 7 Previous material and assignment 1.Questions on last Lab assignment? 2.Questions on file management commands? 12
CIS 90 - Lesson 7 one more mv 13
CIS 90 - Lesson 7 Home directory cleanup Move your graded work to /class/labs mv lab??.graded class/labs/ Check with ls command 14
CIS 90 - Lesson 7 Permissions 15
File Permissions Relevant fields from the inode CIS 90 - Lesson 7 16 How do we control access to files and directories? Answer: file permissions
File Permissions Relevant fields from the inode CIS 90 - Lesson 7 17 What permissions are there? Answer: read, write and execute
File Permissions Relevant fields from the inode CIS 90 - Lesson 7 18 Who do permissions apply to? Answer: The file's owner, the file's group and everyone else (others)
File Permissions Relevant fields from the inode CIS 90 - Lesson 7 19 File permissions, owners, and groups are displayed in long listings /home/cis90/simmsben $ ls -l total 176 drwxrwxr-x 3 simmsben cis Mar 18 06:49 africa -rw-r--r-- 2 simmsben cis Jul bigfile drwxr-xr-x 2 simmsben cis Sep bin -rw-r--r-- 1 simmsben cis90 0 Jul empty d simmsben cis Feb Hidden drwxrwxr-x 4 simmsben cis Mar 18 08:12 island drwxr-xr-x 2 simmsben cis Feb Lab2.0 drwxr-xr-x 3 simmsben cis Feb Lab2.1 -rw-r--r-- 1 simmsben cis Jul letter drwxr-xr-x 2 simmsben cis Sep Miscellaneous -rw-r--r-- 1 simmsben cis Jun mission drwxr-xr-x 5 simmsben cis Jan Poems -rw-r--r-- 1 simmsben cis Aug proposal1 -rw-r--r-- 1 simmsben cis Jul proposal2 -rw-r--r-- 1 simmsben cis Sep proposal3 -rw-rw-r-- 1 simmsben cis90 0 Mar 18 06:36 sawyer -rw-r--r-- 1 simmsben cis Nov small_town -rw-r--r-- 1 simmsben cis Aug spellk -rw-r--r-- 1 simmsben cis Jul text.err -rw-r--r-- 1 simmsben cis Jul text.fxd -rwxr-xr-x 1 simmsben cis Jun timecal -rw-r--r-- 1 simmsben cis Jul what_am_i Permissions Owner Group
CIS 90 - Lesson 7 Superblock Inode Table ext2 file system Data Blocks ~]$ls -il letter rw-r--r-- 1 simmsben cis Jul letter Hello Mother! Hello Father! Here I am at Camp Granada. Things are very entertaining, and they say we'll have some fun when it stops raining. All the counselors hate the waiters, and the lake has alligators. You remember Leonard Skinner? He got ptomaine poisoning last night after dinner. Now I don't want this to scare you, but my bunk mate has malaria. You remember Jeffrey Hardy? Their about to organize a searching party. Take me home, oh Mother, Father, take me home! I hate Granada. Don't leave me out in the forest where I might get eaten by a bear! Take me home, I promise that I won't make noise, or mess the house with other boys, oh please don't make me stay -- I've been here one whole day. Dearest Father, darling Mother, how's my precious little brother? I will come home if you miss me. I will even let Aunt Bertha hug and kiss me! Wait a minute! It's stopped hailing! Guys are swimming! Guys are sailing! Playing baseball, gee that's better! Mother, Father, kindly disregard this letter. Alan Sherman bigfile bin letter bigfile bin letter simmsben cis Pointer(s) to data blocks inode number Type Number of links Owner Group Size Modification time Access Time Change time Pointer(s) to data blocks rw-r--r-- Permissions 20 Permissions are kept in the inode of a file
File Permissions CIS 90 - Lesson 7 21 /home/cis90/simmsben $ id simmsben uid=1001(simmsben) gid=103(cis90) groups=103(cis90),100(users) context=user_u:system_r:unconfined_t /home/cis90/simmsben $ Owner is based on the UID (User ID)
/home/cis90/simmsben $ id simmsben uid=1001(simmsben) gid=103(cis90) groups=103(cis90),100(users) context=user_u:system_r:unconfined_t /home/cis90/simmsben $ File Permissions CIS 90 - Lesson 7 22 Group is based on the GID (Group ID)
File Permissions Relevant fields from the inode CIS 90 - Lesson 7 A.Owner of the file: uid B.Group Membership of the file: gid C.Permissions: read, write, execute rwx rwx rwx owner group other 1.the Read permission has a numeric value of 4 (100 binary) 2.the Write permission has a numeric value of 2 (010 binary) 3.the EXecute permission has a numeric value of 1 (001 binary) The total permissions assigned to a file for a particular identity is the sum of these three values. 23 Permissions are shown as triplets using either letters or numbers These permissions would be 777 using numeric form
File Permissions Viewing relevant fields from the inode CIS 90 - Lesson simmsben cis Pointer(s) to data blocks inode number Type Number of links Owner Group Size Modification time Access Time Change time Pointer(s) to data blocks rw-r--r-- Permissions 24 The permissions on letter are rw-r--r-- or 644 owner has read and write group has only read others have only read The stat command shows permissions in both formats numeric form ~]$ stat letter File: `letter' Size: 1044 Blocks: 16 IO Block: 4096 regular file Device: 805h/2053d Inode: Links: 2 Access: (0644/-rw-r--r--) Uid: ( 1160/simmsben) Gid: ( 103/ cis90) Access: :15: Modify: :04: Change: :16: ~]$
File Permissions Binary CIS 90 - Lesson 7 25 Permissions are stored internally using binary numbers DecimalBinary
File Permissions Viewing relevant fields from the inode CIS 90 - Lesson simmsben cis Pointer(s) to data blocks inode number Type Number of links Owner Group Size Modification time Access Time Change time Pointer(s) to data blocks rw-r--r-- Permissions The permissions on letter are rw-r--r-- or 644 owner has read and write group has only read others have only read 110 (binary) = 6 (decimal) 100 (binary) = 4 (decimal)
File Permissions CIS 90 - Lesson 7 27 What is the numeric form of r--r----- ?
File Permissions CIS 90 - Lesson 7 28 What is the numeric form of r--r----- ? Answer: 440 Owner has read Group has read Others have no permissions
File Permissions CIS 90 - Lesson 7 29 What is the numeric form of rwxrw-r-- ?
File Permissions CIS 90 - Lesson 7 30 What is the numeric form of rwxrw-r-- ? Answer: 764
File Permissions CIS 90 - Lesson 7 31 What is the numeric form of rwxr-xr-x ?
File Permissions CIS 90 - Lesson 7 32 What is the numeric form of rwxr-xr-x ? Answer: 755 Owner has read, write and execute Group has read and execute Others have read and execute
File Permissions CIS 90 - Lesson 7 33 What permissions are 644 ?
File Permissions CIS 90 - Lesson 7 34 rw-r--r What permissions are 644 ? Answer: owner has read and write group has read others have read
File Permissions Relevant Commands CIS 90 - Lesson 7 chown - Changes the ownership of a file. (Only superuser has this privilege) chgrp - Changes the group of a file. (Only groups that you belong to) chmod - Changes the permissions of a file. Numeric: chmod 640 letter (sets the permissions) Mnemonic: chmod ug+rw letter (changes the permissions) Mnemonic: u=user(owner), g=group, o=other r=read, w=write, x=execute umask - Sets the default mask applied to permissions for newly created files. 35
Directory3]$ touch myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chown rsimms myfile chown: changing ownership of `myfile': Operation not permitted Directory3]$ chgrp users myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben users 0 Oct 15 14:40 myfile Directory3]$ Directory3]$ chgrp cis90 myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ CIS 90 - Lesson 7 File Permissions chown and chgrp command - examples Everyone can use chgrp 36 Only root can use chown
CIS 90 - Lesson 7 Directory3]$ ls -l total 4 -rwxrwxr-- 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod -x myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod og+x myfile Directory3]$ ls -l total 4 -rw-rwxr-x 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod go-rwx myfile Directory3]$ ls -l total 4 -rw simmsben cis90 0 Oct 15 14:40 myfile File Permissions chmod command - examples 37 Use chmod to add or remove permissions from a file remove execute from all add execute to others and group remove read, write, execute from groups and others
File Permissions chmod command - examples CIS 90 - Lesson 7 Directory3]$ chmod 664 myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod 777 myfile Directory3]$ ls -l total 4 -rwxrwxrwx 1 simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod 640 myfile Directory3]$ ls -l total 4 -rw-r simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod 000 myfile Directory3]$ ls -l total simmsben cis90 0 Oct 15 14:40 myfile Directory3]$ chmod 644 myfile Directory3]$ ls -l total 4 -rw-r--r-- 1 simmsben cis90 0 Oct 15 14:40 myfile 38
File Permissions Commands that require file permissions CIS 90 - Lesson 7 PermissionFileDirectory Read (4)cat, more, file, head, tail, cp ls Write (2)vi, saving mailcp, mv, rm, ln Execute (1)$ commandcd, ls -l, find 39
File Permissions examples CIS 90 - Lesson 7 ~]$ chmod u-w Directory3 ~]$ ls -ld Directory3 dr-xrwxr-x 2 simmsben cis Oct 15 15:00 Directory3 ~]$ cd Directory3 Directory3]$ ls -l total 4 -rw-r--r-- 1 simmsben cis90 0 Oct 15 15:00 myfile Directory3]$ rm myfile rm: cannot remove `myfile': Permission denied Directory3]$ chmod 777 myfile Directory3]$ ls -l total 4 -rwxrwxrwx 1 simmsben cis90 0 Oct 15 15:00 myfile Directory3]$ rm myfile rm: cannot remove `myfile': Permission denied Directory3]$ 40 So why can't Benji remove his own file? Benji has full permissions on his own file inside that directory Remove write permission on the directory
File Permissions Another example CIS 90 - Lesson 7 ~]$ ls -ld Directory3 drwxr-xr-x 2 simmsben cis Oct 15 15:00 Directory3 ~]$ cd Directory3 Directory3]$ chmod 000 myfile Directory3]$ ls -l total simmsben cis90 0 Oct 15 15:00 myfile Directory3]$ rm myfile rm: remove write-protected regular empty file `myfile'? yes Directory3]$ 41 Now Beni has no permissions on this file So how come he can delete it?
File Permissions Default Permissions CIS 90 - Lesson 7 Default permissions Default permissions for an ordinary file: rw-rw-rw- 666 Default permissions for directories: rwxrwxrwx 777 The umask is a three digit octal value whose bits strip away (mask off) default permissions: umask strips off all permissions from a file or directory umask leaves the default permissions alone umask strips off write permissions from group and other 42 What permissions are files created with? Answer: This is determined by the umask setting
File Permissions umask - examples CIS 90 - Lesson 7 Directory3]$ umask 0002 Directory3]$ rm myfile Directory3]$ touch myfile Directory3]$ ls -l total 4 -rw-rw-r-- 1 simmsben cis90 0 Oct 15 14:59 myfile Directory3]$ Directory3]$ umask 000 Directory3]$ rm myfile Directory3]$ touch myfile Directory3]$ ls -l total 4 -rw-rw-rw- 1 simmsben cis90 0 Oct 15 15:00 myfile Directory3]$ Directory3]$ umask 022 Directory3]$ rm myfile Directory3]$ touch myfile Directory3]$ ls -l total 4 -rw-r--r-- 1 simmsben cis90 0 Oct 15 15:00 myfile Directory3]$ rw_rw_r__ rw_rw_rw_ rw_r__r__ 43 This displays current umask setting Change umask to 000 Change umask to 022
File Permissions exercise - setup CIS 90 - Lesson 7 /home/cis90/simmsben $ mkdir Directory1 Directory2 /home/cis90/simmsben $ chmod 751 Directory1 /home/cis90/simmsben $ chmod 775 Directory2 /home/cis90/simmsben $ ls -ld Directory* drwxr-x--x 2 simmsben cis Oct 15 11:11 Directory1 drwxrwxr-x 2 simmsben cis Oct 15 11:11 Directory2 /home/cis90/simmsben $ cd Directory1 /home/cis90/simmsben/Directory1 $ echo "blah blah blah" > file1 /home/cis90/simmsben/Directory1 $ echo "blah blah blah" > file2 /home/cis90/simmsben/Directory1 $ echo "blah blah blah" > file3 /home/cis90/simmsben/Directory1 $ chmod 664 file1 /home/cis90/simmsben/Directory1 $ chmod 755 file2 /home/cis90/simmsben/Directory1 $ chmod 554 file3 /home/cis90/simmsben/Directory1 $ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 44
File Permissions exercise - setup CIS 90 - Lesson 7 /]$ ls -ld /home /home/cis90 /home/cis90/simmsben drwxr-xr-x 16 root root 4096 Jan 27 19:20 /home drwxr-x guest90 cis Feb 19 05:49 /home/cis90 drwxr-xr-x 13 simmsben cis Mar 30 06:47 /home/cis90/simmsben 45 Note that other users have no permissions for the /home/cis90 directory
File Permissions exercise – can owner change these files? CIS 90 - Lesson 7 /home/cis90/simmsben/Directory1 $ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 /home/cis90/simmsben/Directory1 $ /home/cis90/simmsben/Directory1 $ echo "changes" > file1 46 Can Benji write to file1?
File Permissions exercise – can owner change these files? CIS 90 - Lesson 7 /home/cis90/simmsben/Directory1 $ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 /home/cis90/simmsben/Directory1 $ /home/cis90/simmsben/Directory1 $ echo "changes" > file1 /home/cis90/simmsben/Directory1 $ echo "changes" > file2 47 Yes, he can. Can Benji write to file2?
File Permissions exercise – can owner change these files? CIS 90 - Lesson 7 /home/cis90/simmsben/Directory1 $ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 /home/cis90/simmsben/Directory1 $ /home/cis90/simmsben/Directory1 $ echo "changes" > file1 /home/cis90/simmsben/Directory1 $ echo "changes" > file2 /home/cis90/simmsben/Directory1 $ echo "changes" > file3 48 Yes, he can. Can Benji write to file3?
File Permissions exercise – can owner change these files? CIS 90 - Lesson 7 /home/cis90/simmsben/Directory1 $ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 /home/cis90/simmsben/Directory1 $ /home/cis90/simmsben/Directory1 $ echo "changes" > file1 /home/cis90/simmsben/Directory1 $ echo "changes" > file2 /home/cis90/simmsben/Directory1 $ echo "changes" > file3 -bash: file3: Permission denied /home/cis90/simmsben/Directory1 $ /home/cis90/simmsben/Directory1 $ cat f* changes blah blah blah /home/cis90/simmsben/Directory1 $ 49 No he cannot Benji could write to file 1 and file 2 but not file 3
File Permissions exercise – can group user change these files? CIS 90 - Lesson 7 Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 8 Oct 15 11:48 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 Directory1]$ echo "changes" > file1 50 Can Duke write to Benji's file1?
File Permissions exercise – can group user change these files? CIS 90 - Lesson 7 Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 8 Oct 15 11:48 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 Directory1]$ echo "changes" > file1 Directory1]$ echo "changes" > file2 51 Yes, he can. Can Duke write to Benji's file2?
File Permissions exercise – can group user change these files? CIS 90 - Lesson 7 Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 8 Oct 15 11:48 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 Directory1]$ echo "changes" > file1 Directory1]$ echo "changes" > file2 -bash: file2: Permission denied Directory1]$ echo "changes" > file3 52 No, he cannot. Can Duke write to Benji's file3?
Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 8 Oct 15 11:48 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 Directory1]$ echo "changes" > file1 Directory1]$ echo "changes" > file2 -bash: file2: Permission denied Directory1]$ echo "changes" > file3 -bash: file3: Permission denied Directory1]$ File Permissions exercise – can group user change these files? CIS 90 - Lesson 7 53 No, he cannot.
/]$ ls -ld /home /home/cis90 /home/cis90/simmsben drwxr-xr-x 16 root root 4096 Jan 27 19:20 /home drwxr-x rsimms cis Feb 19 05:49 /home/cis90 drwxr-xr-x 13 simmsben cis Mar 30 06:47 /home/cis90/simmsben Directory1]$ cd; ls -l D*1/file* -rw-rw-r-- 1 simmsben cis90 15 Mar 30 06:49 Directory1/file1 -rwxr-xr-x 1 simmsben cis90 15 Mar 30 06:49 Directory1/file2 -r-xr-xr-- 1 simmsben cis90 15 Mar 30 06:49 Directory1/file3 File Permissions exercise – can other user change these files? CIS 90 - Lesson 7 / ~]$ ls -l /home/cis90/simmsben/Directory1 ls: /home/cis90/simmsben/Directory1: Permission denied ~]$ echo "simmsmar" > /home/cis90/simmsben/Directory1/file1 -bash: /home/cis90/simmsben/Directory1/file1: Permission denied ~]$ echo "simmsmar" > /home/cis90/simmsben/Directory1/file2 -bash: /home/cis90/simmsben/Directory1/file2: Permission denied ~]$ echo "simmsmar" > /home/cis90/simmsben/Directory1/file3 -bash: /home/cis90/simmsben/Directory1/file3: Permission denied ~]$ 54 Mary is not in the cis90 group. She does not have read permission to /home/cis90 or write permission to any of Benji's files
File Permissions exercise – can the owner remove these files? CIS 90 - Lesson 7 Directory1]$ ls -ld drwxr-x--x 2 simmsben cis Oct 15 12:42. Directory1]$ Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 Directory1]$ rm file1 Directory1]$ rm file2 Directory1]$ rm file3 rm: remove write-protected regular file `file3'? y Directory1]$ 55 Can Benji remove his files? Yes he can, even the one he does not have write permission to!
File Permissions exercise – can group user remove these files? CIS 90 - Lesson 7 Directory1]$ ls -ld drwxr-x--x 2 simmsben cis Oct 15 12:42. Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ rm../simmsben/Directory1/file1 rm: cannot remove `../simmsben/Directory1/file1': Permission denied ~]$ rm../simmsben/Directory1/file2 rm: remove write-protected regular file `../simmsben/Directory1/file2'? y rm: cannot remove `../simmsben/Directory1/file2': Permission denied ~]$ rm../simmsben/Directory1/file3 rm: remove write-protected regular file `../simmsben/Directory1/file3'? y rm: cannot remove `../simmsben/Directory1/file3': Permission denied ~]$ 56 Can Duke remove Benji's files? Nope
File Permissions exercise – can other user remove these files? CIS 90 - Lesson 7 57 Can Mary remove Benji's files? Nope, no read permission on /home/cis90 or write permission on /home/cis90/simmsben /]$ ls -ld /home /home/cis90 /home/cis90/simmsben drwxr-xr-x 16 root root 4096 Jan 27 19:20 /home drwxr-x rsimms cis Feb 19 05:49 /home/cis90 drwxr-xr-x 13 simmsben cis Mar 30 06:47 /home/cis90/simmsben Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ rm /home/cis90/simmsben/Directory1/file1 rm: cannot remove `/home/cis90/simmsben/Directory1/file1': Permission denied ~]$ rm /home/cis90/simmsben/Directory1/file2 rm: cannot remove `/home/cis90/simmsben/Directory1/file2': Permission denied ~]$ rm /home/cis90/simmsben/Directory1/file3 rm: cannot remove `/home/cis90/simmsben/Directory1/file3': Permission denied ~]$
File Permissions exercise – can owner read these files? CIS 90 - Lesson 7 ~]$ ls Directory1 file1 file2 file3 ~]$ cat Directory1/* blah blah blah ~]$ 58 Can Benj read his own files? Directory1]$ ls -ld drwxr-x--x 2 simmsben cis Oct 15 12:42. Directory1]$ Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 yes he can
File Permissions exercise – can group user read these files? CIS 90 - Lesson 7 59 Can Duke read Benji's files? Yep! Directory1]$ ls -ld drwxr-x--x 2 simmsben cis Oct 15 12:42. Directory1]$ Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ cat../simmsben/Directory1/file* blah blah blah ~]$
File Permissions exercise – can other user read these files? CIS 90 - Lesson 7 /]$ ls -ld /home /home/cis90 /home/cis90/simmsben drwxr-xr-x 16 root root 4096 Jan 27 19:20 /home drwxr-x guest90 cis Feb 19 05:49 /home/cis90 drwxr-xr-x 13 simmsben cis Mar 30 06:47 /home/cis90/simmsben Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ cat /home/cis90/simmsben/Directory1/file1 cat: /home/cis90/simmsben/Directory1/file1: Permission denied ~]$ cat /home/cis90/simmsben/Directory1/file2 cat: /home/cis90/simmsben/Directory1/file2: Permission denied ~]$ cat /home/cis90/simmsben/Directory1/file3 cat: /home/cis90/simmsben/Directory1/file3: Permission denied ~]$ 60 Can Mary read Benji's files? Nope! - No read permissions to the /home/cis90 directory
File Permissions exercise – can owner execute these files? CIS 90 - Lesson 7 ==> file1 <== #!/bin/bash echo "blah blah blah" exit 0 ==> file2 <== #!/bin/bash echo "blah blah blah" exit 0 ==> file3 <== #!/bin/bash echo "blah blah blah" exit 0 61 Directory1]$ ls -l total 32 -rw-rw-r-- 1 simmsben cis90 41 Oct 15 13:16 file1 -rwxr-xr-x 1 simmsben cis90 41 Oct 15 13:17 file2 -r-xr-xr-- 1 simmsben cis90 41 Oct 15 13:18 file3 Directory1]$./file1 -bash:./file1: Permission denied Directory1]$./file2 blah blah blah Directory1]$./file3 blah blah blah
File Permissions exercise – can group user execute these files? CIS 90 - Lesson 7 Directory1]$ ls -ld drwxr-x--x 2 simmsben cis Oct 15 12:42. Directory1]$ Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ /home/cis90/simmsben/Directory1/file1 -bash: /home/cis90/simmsben/Directory1/file1: Permission denied ~]$ /home/cis90/simmsben/Directory1/file2 blah blah blah ~]$ /home/cis90/simmsben/Directory1/file3 blah blah blah ~]$ 62
File Permissions exercise – can other user execute these files? CIS 90 - Lesson 7 /]$ ls -ld /home /home/cis90 /home/cis90/simmsben drwxr-xr-x 16 root root 4096 Jan 27 19:20 /home drwxr-x rsimms cis Feb 19 05:49 /home/cis90 drwxr-xr-x 13 simmsben cis Mar 30 06:47 /home/cis90/simmsben Directory1]$ ls -l total 24 -rw-rw-r-- 1 simmsben cis90 15 Oct 15 11:13 file1 -rwxr-xr-x 1 simmsben cis90 15 Oct 15 11:13 file2 -r-xr-xr-- 1 simmsben cis90 15 Oct 15 11:13 file3 ~]$ /home/cis90/simmsben/Directory1/file1 -bash: /home/cis90/simmsben/Directory1/file1: Permission denied ~]$ /home/cis90/simmsben/Directory1/file2 -bash: /home/cis90/simmsben/Directory1/file2: Permission denied ~]$ /home/cis90/simmsben/Directory1/file3 -bash: /home/cis90/simmsben/Directory1/file3: Permission denied ~]$ 63 Nope, Mary is locked out at the /home/cis90 level
CIS 90 - Lesson 7 Lab 6 64
CIS 90 - Lesson
CIS 90 - Lesson 7 Wrap up 66
CIS 90 - Lesson 7 New commands: chgrpchange file's group chmodchange file permissions chownchange file owner (superuser only) umaskchange permission mask New Files and Directories: NA 67
CIS 90 - Lesson 7 Next Class Assignment: Check Calendar Page on web site to see what is due next week. Quiz questions for next class: With a umask of 002 what permissions would a newly created file have? What is the numeric permission equivalent of rwxr-xr-- ? Does chmod o+w give write permission to the owner or to other users? 68
CIS 90 - Lesson 7 Backup 69