390 likes | 526 Views
This comprehensive guide from Nassau Community College's ITE153 course focuses on the essential concepts of file systems and security permissions in operating systems. It covers crucial topics like long-term information storage requirements, disk block organization, file operations, and permission management using commands such as `ls` and `chmod`. The guide also introduces the vi editor, detailing its features, modes, and commands to manipulate files effectively. By the end of this unit, students will have a solid understanding of file management and security.
E N D
Nassau Community College ITE153 – Operating Systems Session 6Files Systems: Hands-On
File Systems (1) Nassau Community College ITE153 – Operating Systems • Essential requirements for long-term information storage: • It must be possible to store a very large amount of information. • The information must survive the terminationof the process using it. • Multiple processes must be able to access the information concurrently.
File Systems (2) Nassau Community College ITE153 – Operating Systems • Think of a disk as a linear sequence of fixed-size blocks and supporting reading and writing of blocks. Questions that quickly arise: • How do you find information? • How do you keep one user from reading another’s data? • How do you know which blocks are free?
File Naming Nassau Community College ITE153 – Operating Systems Some typical file extensions.
File Attributes Nassau Community College ITE153 – Operating Systems Some possible file attributes.
File Operations Nassau Community College ITE153 – Operating Systems • The most common system calls relating to files: • Append • Seek • Get Attributes • Set Attributes • Rename • Create • Delete • Open • Close • Read • Write
Nassau Community College ITE153 – Operating Systems Session 6Files Systems: Hands-On Commands
File & Directory Permissions Nassau Community College ITE153 – Operating Systems Unit Objectives: By the end of this unit, you will be able to: • Use the ls command to determine existing permissions on files and directories • Describe the significance of permission settings • Change permissions using the chmod command • Determine default permissions for new files and directories • Change the default permissions for new files and directories
Overview of Security Permissions Nassau Community College ITE153 – Operating Systems • View existing permissions using ls -l $ ls -l drwxr-xr-x 2 cajs office 32 nov 27 2002 06:33 DOCS - rw-r--r-- 1 cajs office 96 nov 27 2002 14:12 abc
Nassau Community College ITE153 – Operating Systems Permission Symbols
Changing Permisssions with chmod Nassau Community College ITE153 – Operating Systems • chmod SETTING NAME(s) • SETTING • Symbolic or Octal notation • Use symbols or octal numbers • $ chmod g+w my.file • $ chmod 664 my.file • NAME(s) • Name of file(s) or directory(s)
Symbolic Notation u user g group o other + add - subtract = set exactly r read w write x execute Symbolic setting examples u+r ugo+x g=r go+w ugo=rw g-w ug+w,o-r $ chmod settingfilename(s) Nassau Community College ITE153 – Operating Systems
Nassau Community College ITE153 – Operating Systems Practice Using Symbols
Octal Notation Common Octal Settings Directories 777 drwxrwxrwx 755 drwxr-xr-x 700 drwx------ Files 777 -rwxrwxrwx 644 -rw-r--r-- Shortcut Setting Value r 4 w 2 x 1 - 0 rwxrw-rw- is 766 rwx 4+2+1=7 rw 4+2+0=6 rw 4+2+0=6 Nassau Community College ITE153 – Operating Systems
Nassau Community College ITE153 – Operating Systems Practice With Octal
Default File & Directory Permissions Nassau Community College ITE153 – Operating Systems • The chmod command changes EXISTING file or directory permissions. • DEFAULT permissions • Used when new files or directories are created • For files: 666 • For directories: 777 • Default can be modified using the umask command
umask Settings Nassau Community College ITE153 – Operating Systems • umask uses Octal notation • To determine existing umask setting:$ umask • To change umask setting:$ umask 022 • File default becomes: -rw-r--r-- • Directory default becomes: drwxr-xr-x
Nassau Community College ITE153 – Operating Systems Common umask Settings
Hands-onExercises Nassau Community College ITE153 – Operating Systems
Nassau Community College ITE153 – Operating Systems Session 6vi Editor: Hands-On Commands
Basics of the vi Editor Nassau Community College ITE153 – Operating Systems By the end of this unit, you will be able to: • Describe the features of a text editor • List the modes of the vi editor • Use commands to move around a text file • Use input commands to enter text • Perform a global substitution • Escape to the shell • Create an abbreviation • Save your file • Exit the vi editor
vi Overview vi is a text editor No automatic formatting Not a word processor With vi, you can: Create text Edit text Delete text Search for text Much more… Nassau Community College ITE153 – Operating Systems
Inventor of vi Editor Nassau Community College ITE153 – Operating Systems • wrote the vi editor in a weekend, 1976 • largely responsible for managing the authorship of BSD UNIX • co-founded Sun Microsystems in 1982 • lives in Aspen
vi Modes Nassau Community College ITE153 – Operating Systems a, i, o... <enter> Input Command ex <esc> : $ $ vi filename
Moving the Cursor: Little Moves In Command Mode Moving by line:<enter> Moving by words:w W Moving by character:<space><backspace> Nassau Community College ITE153 – Operating Systems
Moving the Cursor: Big Moves In Command Mode Scroll up and down:<ctrl-u><ctrl-d> Move within the screen:H homeM middleL last Move to a specified line:6G Move to line sixG Move to the last line Where am I?<ctrl-g> Nassau Community College ITE153 – Operating Systems
Entering Text In Command Mode Type an Input command (i,a,o,O) Type the text you want to enter Press <esc> to return to CommandMode Input commands are relative to the cursor: Nassau Community College ITE153 – Operating Systems O a i o
Changing Text Nassau Community College ITE153 – Operating Systems • Change word: cw • Change 3 words: 3cw • Change current line: cc The change command: • Displays a $ at the end of the word(s) or line to be changed • Puts you into input mode • Use <esc> to return to command mode • A number before the command multiplies the action
Deleting Text Nassau Community College ITE153 – Operating Systems • Delete word dw • Delete 5 words 5dw • Delete current line dd • Delete current character x • A number before the command multiplies the action.
The Undo Command Nassau Community College ITE153 – Operating Systems • u Undo the last change • U Restores the current line (Even after several changes.)
Searching for Text Nassau Community College ITE153 – Operating Systems • In command mode type: /patternFor example: /edit • Searches forward in the file for the pattern ‘edit’. • Puts cursor on the ‘e’ in the first instance found • Type n (for next) to go to the next instance
Copying & Moving Text Nassau Community College ITE153 – Operating Systems • To copy text use vi’s yank command: • yw yanks (copies) one word • yy yanks (copies) one line • To move text use any of vi’s delete commands like dd, dw, x • To paste:p puts copied or deleted text back at the cursor
ex Mode Nassau Community College ITE153 – Operating Systems • From command mode a : (colon) puts you in ex mode • Some tasks in ex mode: • save(write) and quit (example: :wq!) • make global changes • create abbreviations • customize vi • many more….
Save & Quit Nassau Community College ITE153 – Operating Systems • Write and quit vi :wq • Write without quitting :w • Quit without saving :q! • Write to a new filename :w filename
Global Substitutions Nassau Community College ITE153 – Operating Systems • In ex mode - :[address]s/pattern/replacement/[g] • Examples: • :1, $s/Monday/Friday/g • :.,10s/his/hers/g • :18s/lunch/dinner • :1,.s/rabbits/bunnies/g
Abbreviations • :abbr UOS UNIX Operating System • When you type ‘UOS’ in input mode, vi will replace it with ‘UNIX Operating System’
Hands-onExercises Nassau Community College ITE153 – Operating Systems
Important URLs Nassau Community College ITE153 – Operating Systems • How Linux file permissions work- a little more info about file permissions • What is Umask and How To Setup Default umask Under Linux? – good explanation of umask command • Access Rights and File Security– good write-up on file security • The vi Editor (Wikipedia) – very good history of vi • Learning the vi Editor, Sixth Edition - this is the online (free) version
Homework Nassau Community College ITE153 – Operating Systems • Review the Slides • Keep Practicing Commands • Compare to what you have learned on Linux to Windows