
Chapter 4 File Attribute Tien-Hsiung Weng 翁添雄 [email protected] Objectives • Know seven fields of the ls –l output •Use chmod to change file permission • Understand the significant of directory permissions • Concept of user mask and umask changes the default file and directory permission • Create hard links to a file with ln • Learn limitations of hard links and how they overcome by symbolic links • Know importance of ownership and group ownership of a file and how they affect security •Use chown and chgrp to change owner and group owner of files • Locate files with find Listing File Attributes • Field 1 of first column: file type • a ordinary file • d directory • l symbolic links • Remaining nine characters of the first field: – r (read), w (write), x (execute), and - • Field 2: the number of links associated with the file. • Field 3: ownership and • Field 4: group ownership. • Field 5: the file size in bytes • Field 6: last modification time • Field 7: filename Three more permission bits • Discussion so far is 9 permission bits • inode stores 12 permission bits. • Three bits: – Set-user-id – Set-group-id – Sticky bit chmod command Changing File Permission. – chmod -R 400 unit01 – chmod -R u+x homework – chmod -R ugo+r fork.c – chmod go-rx fork.c – chmod ugo=r homework – chmod a=r homework – chmod 644 homework – chmod 755 unit01 •Options: -R recursive operation . umask (User mask) command Setting default file and directory permission. is a shell built in command. To see the current value of the mask: $ umask 022 $ umask n where n = 000~777 For ordinary file, the value of access permission become 666 – n For directory, the value of access permission become 777 – n (a mask value of 666 and 777 does not make sense, because creating files and directories with no permissions.) (Umask value 000 means that you have not subtract anything, this could be dangerous.) – umask 000 – umask 062 – umask 222 – umask 666 – umask 777 •See table 4.3 page 97 in the text book ln creating symbolic links • A file can have multiple filenames • The file has more than one link • We can then access by any of the link • ln can create both a hard and soft link File Ownership • Chown and chgrp touch modification and access time •ls-l Æ time of last file modification •ls-lu Æ time of last access •ls-lcÆ time of last inode modification • touch filename find Locating files • Powerful tool • Recursively examines a directory tree to look for files matching some criteria • find path_list selection_criteria action • find . –name a.out –print • find / -name t\* -print • find . –name “*.c” –print • find . –name ‘[A-Z]*’ -print Find continue • find / -inum 13975 –print • find . –mtime -2 –print • Find /home –atime +365 –print • Find . ! –name “*.c” –print • Find /home \( -name “*.sh” –o –name “*.pl” \) – print.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-