Full Transcript

**1 File systems contain names of directories and files** *Note: The information in this document applies both to Unix and Linux.* **1.1 Files are a list of bytes** *In Unix/Linux, the term "file" often refers to anything in the file system: files, directories, links (covered in a future class),...

**1 File systems contain names of directories and files** *Note: The information in this document applies both to Unix and Linux.* **1.1 Files are a list of bytes** *In Unix/Linux, the term "file" often refers to anything in the file system: files, directories, links (covered in a future class), devices, etc.\ \ The manual page for the **find** command says that it can **search for files**, but it really means that it can search for any kind of thing, not just strictly a "file".* **1.2 Even hardware devices have file names** - - - - - - *In modern Unix/Linux, the directory's content can no longer be read as if it were a regular file, however devices can be (with sufficient permissions).* **2 Things are stored in Index Nodes = inodes** ***inode number \-\--\> inode with information on a file system object*** **2.1 Directories map names to inode numbers** ***directory: inode:**\ \ **name + inode number \-\--\> information on a file system object*** **2.2 One inode, many names** **2.3 Inodes contain pointers to disk blocks** ***directory: inode: file disk blocks:**\ \ **hello.txt, 12231 -\> 12231:..disk blocks -\> \[ hello\\n \]*** **2.4 Inodes contain attributes (owners, permissions, times, etc.)** **2.5 Inodes are unique inside a file system** **2.6 Inodes are a fixed resource** **3 File System Diagrams - when considering inodes** *The diagram on the left shows the file system hierarchy. The diagram on the right shows how the information is actually stored on the disk.* *The ROOT directory inode has no name because there is no directory above it to give it one! Every other directory except ROOT has a name because there is a directory inode above it that contains its name.* **4 Directories hold only names and inode numbers** **4.1 Attributes are stored with the inode, not the name** *To find out attribute information of some file system object, you must first use the inode number associated with the object to find the inode of the item and look at the item's attributes. This is why **ls** or **ls -i** are much faster than **ls -l** on a huge directory:* 1. 2. **5 Multiple names -- Hard Links** *You can use **ls -i** to see the inode numbers paired with each name, and the **find** command has a useful **-inum** expression operator, to find all files with a given inode number.* **5.1 Why have multiple names for the same data?** 1. 2. **5.2 Link counts count names; ln creates, rm removes only a name** **5.3 Linking, Moving, and Removing are directory operations: ln, mv, rm** - - - - **5.4 Hard links to directories?** - - - **5.5 An empty directory has a link count of two** 1. 2. 1. 2. 3. **6 Soft Links (Symbolic links / Symlinks)** **6.1 Creating Soft Links** *Note:* - - - - **6.2 Dangling symlinks** *Note the error message above from the **cat** command. It can be confusing, as the name **two**does exist!* **6.3 Second-class citizens** **6.4 Relative and absolute targets for symlinks** **7 Exercise Questions on Hard Links and Directories** - - - - - - 1. 2. 3. 4. 5. 6. **1 Unix/Linux is a Multi-user system** *The super-user account **root** on a Unix system can bypass and over-ride all read/write and access permissions. The super-user can access and do anything to any inode. In this document, we discuss permissions as they apply to ordinary, non-**root** users.* *You may have heard about smartphone users "rooting" their smartphones. This means that instead of programs running with the permissions provided to them, they run as **root**. Take into consideration that it means that running programs have full access to everything on your smartphone!* **2 Users, Groups and Processes** **2.1 Password file: /etc/passwd   Group file: /etc/group** *The password file **/etc/passwd** maps a user ID number to a name. The group file **/etc/group** maps each group ID number to a name. The name is a convenience for people; the processes calculate permissions based on the numeric IDs.* *User IDs may also be known as **userids** or **uids**. Group IDs may also be known as **groupids** or **gids**.* *You can easily change the name of a user or a group by changing its name in the password or group files. There are privileged system commands that safely do this for you, e.g. **usermod**and **groupmod**.* **2.2 Show user IDs and group IDs: whoami, groups, id** **2.3 Processes: one user ID and multiple group IDs** **3 File system inodes have one owner (user ID), only one group** **3.1 Summary: users and processes vs. file system inodes** **4 Permissions: Match login userid/groups to inode owner/group** **4.1 Symbolic mode of an inode** - - - - - - - - - - - - - **4.2 Matching process permissions with inode permissions** 1. 2. 3. **4.3 Example: matching three sets of three permissions** 1. 2. 3. **5 The three permissions: rwx** **5.1 Read Permission: r\--** **5.2 Write Permission: -w-** **5.3 eXecute/Search Permissions: \--x** **5.4 Ignore permissions on symbolic links** **5.5 Summary of rwx permissions** - - - - - - - - **6 Execute/Search permission for directories** **7 Names are separate from content** **7.1 Unix directories are only names and inodes** **7.2 Example: /etc/passwd** 1. 2. 3. **8 Changing Permissions using chmod** 1. 2. **8.1 Using octal-numeric mode with chmod** **8.2 Adding or Removing Permissions using symbolic + or -** **1 umask blocks default permissions** **2 Default Permissions: directory 777, file 666** **3 Masking is not subtracting** **4 The umask command affects default permissions** *Many modern Linux shells also accept symbolic **umask** permissions, in addition to the traditional octal numbers. See the manual page for your shell for details. In this course, we use the traditional octal numbers that work everywhere.* - - **5 umask is set and then passed to child processes** **5.1 umask Example** - - - **5.2 (OPTIONAL) umask can affect chmod if not using octal permissions** *Always specify the precise User/Group/Other permission string when using **chmod**, since you don't know what the current **umask** might be.*

Use Quizgecko on...
Browser
Browser