Quick viewing(Text Mode)

Chapter 1 Introducing UNIX

Chapter 1 Introducing UNIX

Chapter 4 Attribute

Tien-Hsiung Weng 翁添雄 [email protected] Objectives

• Know seven fields of the –l output •Use to change file permission • Understand the significant of permissions • Concept of user mask and changes the default file and directory permission • Create hard links to a file with • 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 and to change owner and group owner of files • files with Listing File Attributes

• Field 1 of first column: file • a ordinary file • d directory • l symbolic links • Remaining nine characters of the first field: – r (read), (), 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 • Field 7: Three permission bits

• Discussion so far is 9 permission bits • stores 12 permission bits. • Three bits: – Set-user-id – Set-group-id – command

chmod recursive operation chmod -R 400 unit01 chmod -R u+x homework chmod -R ugo+r .c chmod go-rx fork.c chmod homework ugo=r chmod a=r homework chmod 644 homework chmod 755 unit01 – – – – – – – – -R Options: Changing File Permission. . • command ion. is a built in command. ke sense, because creating files and 97 in the text book umask 000 umask 062 umask 222 umask 666 umask 777 $ umask 022 – – – – – See table 4.3 page directories with no permissions.) Setting default file and directory permiss To see the current value of mask: $ umask n where = 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 ma (Umask value 000 means that you have not subtract anything, this could be dangerous.) • umask (User mask) and soft hard creating symbolic links ln • file can have multiple A • file has more than one link The • We can then access by any of the link • ln can create both a File Ownership • Chown and chgrp 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 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