OSA Unit - III

Views:
 
Category: Education
     
 

Presentation Description

Operating System and Administration: Introduction to the File System

Comments

Presentation Transcript

Introduction to the File System:

Introduction to the File System Reference: UNIX AND LINUX SYSTEM ADMINISTRATION HANDBOOK Authors : Evi Nemeth Garth Snyder Trent R. Hein Ben Whaley

Index:

Index Pathnames, File system Mounting and unmounting, The organization of the File Tree, File Types, File Attributes, Access Control lists 2

Introduction:

Introduction File: logically a container for data. Filesystem: represent and organize the system’s storage resources. Some portions of a file tree are handled by traditional disk based implementation; others are fielded by separate drivers within the kernel. A complicated factor in UNIX filesystems is that they tend to support more than one type of disk-based file systems. 3

Main Components:

Main Components Namespace: a way of naming and arranging things in a hierarchy. API (Application Programming Interface) : a set of system calls for navigating and manipulating nodes. Security Model: protection mechanism to enable sharing. Implementation: code that ties the logical model to the actual disk. 4

Some Standard Directories :

Some Standard Directories / (root) Base of the file system hierarchy bin Binary images of some UNIX commands dev Filenames that correspond to devices etc System administrator files lib Library files tmp Temporary files - some UNIX commands home User portion of file system (may also be called usr on some systems) 5

File/Directory Naming:

File/Directory Naming Up to 255 characters in length Case sensitive ( jan not same as Jan) Recommended characters are: Upper/lower case (A-Z, a-z) Numbers (0-9) Underscore (_) Period (.) Comma (,) 6

The root directory (/):

The root directory (/) The root directory (/) is the starting location for all directories in Unix Caution: if a directory name is preceded by the root directory (/), Unix assumes that we wish to specify the entire directory path! 7

Directory symbols:

Directory symbols Unix provides shortcut symbols to refer to certain directories. Examples: / (forward slash) – the root directory ~ (tilda) – your home directory . (period) – the current directory ..(double period) – the parent directory (one up in the tree) 8

Unix Directory Navigation:

Unix Directory Navigation Absolute – Always begins with the root directory. Example: /home/zabc123/public_html Relative – begins with the current directory (do not start with a slash(/) as that means absolute) Example: public_html assuming we are in the /home/zabc123 directory, public_html refers to the absolute directory name: /home/zabc123/public_html 9

Relative Directory Navigation:

Relative Directory Navigation May use the double period ( .. ) to move up the tree relative from the current directory. Cannot use .. in the root directory. Why not? Example: Assuming we are in directory: /home/zabc123/public_html .. /myprog will refer to directory /home/zabc123/myprog since .. means /home/zabc123/ 10

Change Directories (cd):

Change Directories (cd) Format: cd [ directory ] If the directory is omitted the user is returned to his/her home directory, directory may be either an absolute or relative directory name Examples: command type directory comments cd / home absolute go to directory: /home cd zabc123 relative go to directory zabc123 from current directory (e.g. if in / home directory would end up in / home/zabc123 directory) cd .. relative go to parent directory if in / home/zabc123 directory would end up in / home directory) cd go to your personal home directory cd ~/ public_html absolute go to the public_html directory within your home directory cd ../ def456 relative go up one directory and down to the def456 subdirectory of the parent 11

Pathnames:

Pathnames Unix organizes files in a single hierarchy. It starts at root directory /. It continues through an arbitrary number of subdirectories. List of directory to be traversed to locate a file forms the pathname. No restriction on depth of filesystem. 12

PowerPoint Presentation:

/ bin vmunix hosts passwd passwd etc dev usr local lib A directory tree 13

Pathnames Cont’d:

Pathnames Cont’d Pathnames can be either absolute (starting at the root directory) or relative (starting at the current directory). Each component of a pathname can not be more than 255 characters in length. To access a file with pathname longer than 1023 characters, “cd” to an intermediate directory and use a relative pathname. No restrictions on naming of files except they are limited in length and must not contain the “/” character or nulls. The space character is supported. Quote the file name containing spaces: % more “My Excellent file.txt” 14

Mounting:

Mounting One file system is configured to be the “root file system” and its root directory becomes the “system root directory”. Other file systems are attached to the root file system by mounting each new file system onto a directory in the root file system. That “mounted on” directory is also called the “mount point”. The previous contents of the mount point become inaccessible. 15

PowerPoint Presentation:

Mounting one filesystem to another / usr sys dev etc bin / local adm users bin fs0 fs1 usr / 16

Unmounting:

Unmounting File systems are detached with the unmount command. In order to unmount a file system: 1) No files or process should be open or running. 2) If a file system contains executable programs, they must not be running. 17

Unmounting Cont’d:

Unmounting Cont’d Do not use command unmount –f . It forces a busy filesystem to be unmounted and may cause crash. Earlier versions of Solaris: a) lockfs –h dir to “hard lock” the file system. b) unmount it normally. To determine exactly what the offending processes are, run ps with a list of the PIDs returned by fuser . 18

Unmounting Cont’d:

Unmounting Cont’d To find out why a file system is busy, run the fuser -c dir command. Example: % fuser -c /usr /usr: 157tom 315ctom …… 19

Unmounting Cont’d:

Activity codes shown by fuser -c Codes Meaning f,o The process has a file open for reading or writing. c The process’s current directory is on the filesystem. e,t The process is currently executing a file. r The process’s root directory (set with chroot) is on the filesystem. m,s The process has mapped a file or shared library. 20 Unmounting Cont’d

Organization of the File Tree:

Organization of the File Tree Root file system contains the root directory and a minimal set of files and subdirectories. File containing the kernel is called unix or vmunix , and it resides in either the root directory or in a subdirectory such as /kernel or /stand . Part of the root filesystem are: /dev -- for device files. /etc -- for critical system files. /sbin and /bin -- for important utilities. /tmp -- for temporary files. 21

Organization of the File Tree Cont’d:

Organization of the File Tree Cont’d Some systems keep shared libraries and the C preprocessor in the /lib directory. Others have moved this into /usr/lib . /usr contains most of the user programs and online manuals etc. /var provides a home for spool directories, log files, accounting information etc. Home directories of users should be kept on different file systems and mounted beneath /usr . 22

File Types:

File Types Regular Files. Directories. Character Device Files. Block Device Files. UNIX domain sockets. Named pipes (FIFOs). Symbolic links. A few systems do not support UNIX domain sockets and named pipes. 23

File Types cntd….:

24 File Types cntd….

File Attributes:

File Attributes Mode: 9 permission bits control who can read, write and execute the contents of the file. 3 bits affect the operation of executable programs. the 12 bits can be changed by the owner of the file or the superuser by using the chmod command. 16-bit word 12 bits together with 4 bits of file type information. The 4 file type bits are set when the file is first created and can’t be changed 25

File Attributes Cont’d:

File Attributes Cont’d The setuid and setgid bits: bits with octal values 4000 and 2000. They allow programs to access files and processes that would be otherwise off-limits to the user that runs them. The sticky bit: octal value 1000. If this bit is set, most UNIX systems don’t allow you to delete them unless You are superuser, the owner of directory, or the owner of the file. The permission bits: remaining 9 bits are permission bits. There are sets of permissions for the owner, group owner and everyone else. 26

PowerPoint Presentation:

File Attributes Cont’d use ls -l to view file attributes. Example: % ls -l /bin/ sh - rwxr - xr -x 1 root bin 85924 Sep 27 1997 /bin/ sh - regular file rwxr - xr -x three sets of permission bits 1 link count for the file root owner of the file bin group owner of the file 85924 size of the file in bytes Sep 27 1997 the date of last modification /bin/ sh name of the file 27

PowerPoint Presentation:

File Attributes Cont’d ls -lo : sees the FreeBSD bonus flags attached to a file. chmod : changes the permissions on a file. chown : changes a file's ownership. chgrp : changes a file’s group ownership. umask : asigns the default permissions. 28

setfacl:

setfacl User command utility to set, modify, or delete ACLs on a file Can be ran by file owner or anyone given permission to modify permissions Sample commands: setfacl –s u:alice:+rx:i myFile setfacl –m o::drwx myFile setfacl –u myFile setfacl –d u:alice myFile

getfacl:

getfacl User utility to examine the ACL on a particular file Examines a file’s inode to detemine what permissions are set Sample: getfacl myFile

Example:

Example $touch samplefile $getfacl samplefile #no ACL set $ setfacl –s u:welsh:+rw samplefile $ getfacl samplefile # file: samplefile # owner: dlu # group: brown # Inherits from parent user::rw-p:i user:welsh:rw-- :i group::r---:i other:r---:i

Example:

Example $ setfacl –m u:welsh:dxp samplefile $ getacl samplefile # file: samplefile # owner: dlu # group: brown user::rw-p:i user:welsh:rw<x><p>:i group::r---:i other:r---:i

Example – permission partitions:

Example – permission partitions Development Marketing QA

Problems:

Problems Open Source code is inconsistently documented Communication between kernel and user programs is confusing Testing is a pain

Future Work:

Future Work Make it as a patch to the current linux distribution Determine the optimum number of ACLs to be kept Caching effective ACLs minimizes performance hit from inheritance Graphical User Interface

The Ideal ACL:

The Ideal ACL Deny and allow have equal importance, based on their location in the ACL. I.e. Order matters. Example User Chuck member of: everyone, losers. ACL: allow Chuck; deny losers; allow everyone  Chuck is given access. Existing implementation  Chuck is denied access

authorStream Live Help