Скачать презентацию 2 Manual Filestore Introduction Using Скачать презентацию 2 Manual Filestore Introduction Using

50118c831cfda0a91a42d65d22a907d9.ppt

  • Количество слайдов: 36

2 Manual & Filestore 2 Manual & Filestore

Introduction • Using the manual • The UNIX filestore • File permissions Introduction • Using the manual • The UNIX filestore • File permissions

The on-line manual • man <command> gives detailed information about UNIX commands and other The on-line manual • man gives detailed information about UNIX commands and other facilities • Details include command format, description, examples, known problems, related files and commands • Sections for commands, programming, admin and others • man intro for the introduction • man (of course)

UNIX Filestore • Files and directories • The filesystem hierarchy • File handling commands UNIX Filestore • Files and directories • The filesystem hierarchy • File handling commands • Permissions

Files • From the user’s point of view, all information on the computer is Files • From the user’s point of view, all information on the computer is stored in files • Files may contain many kinds of information, including programs, data and documents • Like paper files, they have a name (chosen by the user) and some content • By convention, the filename suffix suggests the type of content • In some operating systems (for example Unix) it is optional, while in some others (such as Windows) it is a requirement

Example files • • Me. sh = Shell script Me. pl = Perl script Example files • • Me. sh = Shell script Me. pl = Perl script Me. txt = Text file Me. jpg, Me. png, Me. gif = Image files Me. html = HTML web page file Me. zip, Me. gz Me. bz 2 = Compressed file Me. tar = Archived file Me. log = Log file These are just conventions and are not enforced by the operating system! http: //filext. com/alphalist. php? extstart=%5 EA

Directories • Files are stored in directories (folders in Windows) • Each directory may Directories • Files are stored in directories (folders in Windows) • Each directory may contain many files and also other directories • By convention, directory names do not usually have suffixes (why not? ) • A file should have an extension (why? )

The filestore • There is a single hierarchical filestore that is shared by all The filestore • There is a single hierarchical filestore that is shared by all users • It might be spread over the network, may involve many disks on may different computers and may even be linked to other filestores

The filestore • Each user has their own personal home directory (~) • There The filestore • Each user has their own personal home directory (~) • There also common areas for programs, administration, etc. • The filestore starts at the root directory (/) • A user is always in a current working directory (CWP) from which they give commands to access files • When users log on, the CWP is set to their home directory

The filestore (root) staff xxx gtr usr stud itmasters xxx Research Teaching Private CUA The filestore (root) staff xxx gtr usr stud itmasters xxx Research Teaching Private CUA bin MVR Lecture 1. ppt Lecture 2. doc etc ug pg xxx 02 u xxx 04 u . profile CUA Coursework 1. txt

Absolute and Relative Pathnames • There are two ways of specifying filenames – from Absolute and Relative Pathnames • There are two ways of specifying filenames – from the current directory - relative pathnames – from the root directory - absolute pathnames • Simple pathnames consist of sequences of names separated by ‘/’ characters • An example of a relative pathname: . . /my. Doc. txt • An example of an absolute pathname: /stud/ug/xxx 04 u/Documents/my. Doc. txt

Where am I in the File Structure? • pwd prints the pathname of the Where am I in the File Structure? • pwd prints the pathname of the current working directory • cd pathname changes current directory – with no argument it goes to the home directory

Where am I in the File Structure? (2) (root) staff xxx gtr usr stud Where am I in the File Structure? (2) (root) staff xxx gtr usr stud itmasters xxx Research Teaching Private CUA bin MVR Lecture 1. ppt Lecture 2. doc ug pg xxx 02 u. profile etc robin$ pwd /stud/ug/xxx 04 u robin$ cd UST robin$ pwd /stud/ug/xxx 04 u/UST xxx 04 u UST Coursework 1. txt robin$ pwd /stud/ug/xxx 04 u/UST robin$ cd. . robin$ pwd /stud/ug/xxx 04 u/

File handling commands – Viewing File Contents • The cat [filename…] command displays the File handling commands – Viewing File Contents • The cat [filename…] command displays the contents of the named files • It reads the contents of the file(s) and outputs to the shell window • with no arguments cat simply echoes back what you type at the keyboard • there is no scrolling with the cat command • more [filename…] lets you scroll through a file – also less [filename…]

Viewing File Contents (2) • head displays the first 10 lines of a file Viewing File Contents (2) • head displays the first 10 lines of a file • tail displays the last 10 lines of a file

Viewing and Changing Directory Contents • ls [pathname…] lists the contents of the named Viewing and Changing Directory Contents • ls [pathname…] lists the contents of the named directories – with no argument, the current directory is listed • mv pathname 1 pathname 2 moves a file from pathname 1 to pathname 2 – if pathname 2 already exists, then its previous contents are lost – if not, then it is created

Viewing and Changing Directory Contents (2) • cp pathname 1 pathname 2 copies the Viewing and Changing Directory Contents (2) • cp pathname 1 pathname 2 copies the contents of pathname 1 to pathname 2 – if pathname 2 already exists, – then its previous contents are lost – if not, then it is created • rm pathname removes files but not directories (be careful)

Manipulating Directories • mkdir pathname. . . creates a new directory – it fails Manipulating Directories • mkdir pathname. . . creates a new directory – it fails if they already exist robin$ mkdir fred mkdir: failed to make directory “fred”; File exists • rmdir pathname removes directories – it fails if they are not empty robin$ rmdir fred rmdir: directory “fred”: Directory not empty

Printing • lpr pathname prints files – it goes to your default printer – Printing • lpr pathname prints files – it goes to your default printer – you can specify a printer with the -P flag, for example lpr -Phet fred. ps • do not send text files and program listings to laser printers • do not send postscript files to line printers! • Printing not configured on unnc-cslinux • Most of these commands have many flags for specifying different options

More about pathnames • Special symbols can be used in pathnames. . the directory More about pathnames • Special symbols can be used in pathnames. . the directory one level above this. . /. . the directory two levels above this. the current directory ~ this user’s home directory ~user a specific user’s home directory * wildcard matching any string ? wildcard matching any single character

Relative and Absolute Pathnames Revisited Relative. . /. . (root) staff xxx gtr usr Relative and Absolute Pathnames Revisited Relative. . /. . (root) staff xxx gtr usr bin Research Teaching Private CUA MVR Lecture 1. ppt Lecture 2. doc / . . /. . etc stud itmasters xxx Absolute ug pg xxx 02 u /stud . . /. . /stud/ug/xxx 04 u. . ~. profile You are here! CUA . Coursework 1. txt ~xxx 04 u /stud/ug/xxx 04 u/CUA

Security and file permissions • A shared filestore needs a security mechanism to prevent Security and file permissions • A shared filestore needs a security mechanism to prevent the unauthorised reading and writing of files • UNIX associates a permissions list with each file saying who can do what to it • Each directory also has a permissions list • How you can access a file depends upon its permissions list and those of all its parent directories

Permissions lists • Specify who can do what • There are three kinds of Permissions lists • Specify who can do what • There are three kinds of who: u the user (owner) g members of the user’s group o others - anyone else • There are three kinds of what: r read w write x execute

Permissions lists (2) • Use ls -l to see permissions lists • (think of Permissions lists (2) • Use ls -l to see permissions lists • (think of –l as ‘long’) drwxr--r--rw-r--r--rw-r----- 1 1 gtr gtr staff 173568 202752 2638848 87552 Sep 21 15: 41 Labs Sep 21 17: 43 Lectures Oct 6 18: 58 Outline. doc Oct 6 18: 19 Intro. ppt

Permissions lists (3) Each permissions list is shown as ten characters: Permissions lists (3) Each permissions list is shown as ten characters:

Group’s permissions (read only) Directory User -rwxr--r-drwxr--r--rw-r--r--rwxr--r-- 1 1 gtr gtr Group that user Group’s permissions (read only) Directory User -rwxr--r-drwxr--r--rw-r--r--rwxr--r-- 1 1 gtr gtr Group that user is in staff User’s permissions (read only) 5173568 202752 2638848 5587552 Sep 21 15: 41 cve_user Sep 21 17: 43 Reports Oct 6 18: 58 Yr 1 Report. doc Oct 6 18: 19 plod_node_mgr Others’ permissions (read, write and execute) Date file was last modified/created File size File/Directory name

The effect of directory permissions • Execute lets you change (cd) into that directory The effect of directory permissions • Execute lets you change (cd) into that directory – (i. e. you are searching the directory) • Read lets you list files in the directory – (i. e. you are reading the directory contents) • Write lets you create and delete files – (i. e. you are writing to the directory contents) • To use a file at all you must have execute permission on all of its parents (otherwise it is as if it doesn’t exist)

other parents up to the root execute permission controls whether any files and directories other parents up to the root execute permission controls whether any files and directories below this point can be accessed at all parent directory permissions control whether files can be accessed at all, listed, created and deleted file permissions control specific actions on this file

Setting and changing permissions -chmod • chmod mode pathname is used to alter permissions Setting and changing permissions -chmod • chmod mode pathname is used to alter permissions lists • Mode specifies a sequence of changes, each of the form who operation permission – who is u, g or o – operation is + (grant) or - (revoke) – permission is r, w or x • Examples: chmod o-r g-r plan. doc chmod u+rwx Admin

Setting and changing permissions – chmod (2) The mode can also be a three Setting and changing permissions – chmod (2) The mode can also be a three digit octal number that is interpreted as a sequence of nine bits to set the whole permissions list at once: – chmod 644 progress. txt 644 is 110 100 which is interpreted as rw- r-- – chmod 777 progress. txt 777 is 111 111 which is interpreted rwx rwx – chmod 400 progress. txt 400 is 100 000 which is interpreted as r-- ---

Setting and changing permissions – chmod (3) • Files are created with a default Setting and changing permissions – chmod (3) • Files are created with a default permission – usually -rw- r-– depends upon the command used to create the file – set using the umask command

Setting and changing permissions – chmod (3) • Files are created with a default Setting and changing permissions – chmod (3) • Files are created with a default permission – usually -rw- r-– depends upon the command used to create the file – set using the umask command

Nice quote 1 • At a recent computer expo (COMDEX), Bill Gates reportedly compared Nice quote 1 • At a recent computer expo (COMDEX), Bill Gates reportedly compared the computer industry with the auto industry and stated, "If GM had kept up with technology like the computer industry has, we would all be driving $25. 00 cars that got 1, 000 miles to the gallon. " (also size – you could fit a Rolls Royce on the head of a pin. )

Nice quote 2 • In response to Bill's comments, General Motors issued a press Nice quote 2 • In response to Bill's comments, General Motors issued a press release stating: If GM had developed technology like Microsoft, we would all be driving cars with the following characteristics: • 1. For no reason whatsoever, your car would crash twice a day.

Next Lecture • UNIX commands for handling files • Regular Expressions and Searching files Next Lecture • UNIX commands for handling files • Regular Expressions and Searching files • Redirecting output • Bash facilities

Summary • Manual Pages • The UNIX filestore • Pathnames • Security and file Summary • Manual Pages • The UNIX filestore • Pathnames • Security and file permissions