2 manual & filestore mauro jaskelioff. introduction using the manual the unix filestore file...
TRANSCRIPT
![Page 1: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/1.jpg)
2 Manual & Filestore
Mauro Jaskelioff
![Page 2: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/2.jpg)
Introduction
• Using the manual• The UNIX filestore• File permissions
![Page 3: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/3.jpg)
The on-line manual• man <command> 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 man (of course)
![Page 4: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/4.jpg)
UNIX Filestore
• Files and directories
• The filesystem hierarchy
• File handling commands
• Permissions
![Page 5: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/5.jpg)
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
![Page 6: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/6.jpg)
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.bz2 = Compressed file• Me.tar = Archived file• Me.log = Log file
These are just conventions and are not enforced by the operating system!
![Page 7: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/7.jpg)
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
![Page 8: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/8.jpg)
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
![Page 9: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/9.jpg)
• Each user has their own personal home directory (~)
• There are 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
![Page 10: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/10.jpg)
(root)
staff usr bin stud etc
Research Teaching Private
pgugitmastersxxxgtrxxx
CUA
Coursework1.txt
CUA
xxx02u xxx04u
MVR
Lecture1.ppt
Lecture2.doc
.profile
The filestore
![Page 11: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/11.jpg)
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:../myDoc.txt
• An example of an absolute pathname:/stud/ug/xxx04u/Documents/myDoc.txt
![Page 12: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/12.jpg)
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
![Page 13: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/13.jpg)
Where am I in the File Structure? (2)
robin$ pwd/stud/ug/xxx04urobin$ cd USTrobin$ pwd/stud/ug/xxx04u/UST
robin$ pwd/stud/ug/xxx04u/USTrobin$ cd ..robin$ pwd/stud/ug/xxx04u/
(root)
staff usr bin stud etc
Research Teaching Private
pgugitmastersxxxgtrxxx
CUA
Coursework1.txt
UST
xxx02u xxx04u
MVR
Lecture1.ppt
Lecture2.doc
.profile
![Page 14: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/14.jpg)
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…]
![Page 15: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/15.jpg)
Viewing File Contents (2)
• head displays the first 10 lines of a file
• tail displays the last 10 lines of a file
![Page 16: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/16.jpg)
• ls [pathname…] lists the contents of the named directories– with no argument, the current directory is
listed• mv pathname1 pathname2 moves a file
from pathname1 to pathname2– if pathname2 already exists, then its
previous contents are lost– if not, then it is created
Viewing and Changing Directory Contents
![Page 17: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/17.jpg)
• cp pathname1 pathname2 copies the contents of pathname1 to pathname2
– if pathname2 already exists, – then its previous contents are lost– if not, then it is created
• rm pathname removes files but not directories (be careful)
Viewing and Changing Directory Contents (2)
![Page 18: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/18.jpg)
• mkdir pathname ... creates a new directory– it fails if they already exist
Manipulating Directories
robin$ rmdir fredrmdir: directory “fred”: Directory not empty
robin$ mkdir fredrobin$ mkdir fredmkdir: failed to make directory “fred”; File exists
• rmdir pathname removes directories– it fails if they are not empty
![Page 19: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/19.jpg)
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
![Page 20: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/20.jpg)
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
![Page 21: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/21.jpg)
Relative and Absolute Pathnames Revisited
(root)
staff usr bin stud etc
Research Teaching Private
pgugitmastersxxxgtrxxx
CUA
Coursework1.txt
CUA
xxx02u xxx04u
MVR
Lecture1.ppt
Lecture2.doc
.profile
/
../../.. /stud
You are here!
/stud/ug/xxx04u..
/stud/ug../..
../../../..
~ ~xxx04u
Relative Absolute
. /stud/ug/xxx04u/CUA
![Page 22: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/22.jpg)
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
![Page 23: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/23.jpg)
Permissions lists• Specify who can do what• There are three kinds of who:
u the user (owner)g members of the user’s groupo others - anyone else
• There are three kinds of what:r readw writex execute
![Page 24: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/24.jpg)
Permissions lists (2)
• Use ls -l to see permissions lists
drwxr--r-- 1 gtr staff 173568 Sep 21 15:41 Labsdrwxr--r-- 1 gtr staff 202752 Sep 21 17:43 Lectures-rw-r--r-- 1 gtr staff 2638848 Oct 6 18:58 Outline.doc-rw-r----- 1 gtr staff 87552 Oct 6 18:19 Intro.ppt
![Page 25: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/25.jpg)
Permissions lists (3)
type user group other
- rw- r-- r--
d rwx --- ---
- rw- rw- rw-
Each permissions list is shown as ten characters:
![Page 26: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/26.jpg)
Group’s permissions(read only)
User’s permissions
(read, write and execute)
Others’ permissions
(read only)File/Directory name
File size
Group that user is in
UserDate file was last modified/created
Directory
-rwxr--r-- 1 gtr staff 5173568 Sep 21 15:41 cve_userdrwxr--r-- 1 gtr staff 202752 Sep 21 17:43 Reports-rw-r--r-- 1 gtr staff 2638848 Oct 6 18:58 Yr1Report.doc-rwxr--r-- 1 gtr staff 5587552 Oct 6 18:19 plod_node_mgr
![Page 27: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/27.jpg)
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)
![Page 28: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/28.jpg)
other parents up to the root
file
parent directory
execute permission controls whether any files and directories below this point can be accessed at all
permissions control whether files can be accessed at all, listed, created and deleted
permissions control specific actions on this file
![Page 29: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/29.jpg)
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.docchmod u+rwx Admin
![Page 30: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/30.jpg)
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 100 which is interpreted as rw- r-- r--
– chmod 777 progress.txt777 is 111 111 111 which is interpreted rwx rwx rwx
– chmod 400 progress.txt400 is 100 000 000 which is interpreted as r-- --- ---
Setting and changing permissions – chmod (2)
![Page 31: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/31.jpg)
Setting and changing permissions – chmod (3)
• Files are created with a default permission– usually -rw- r-- r--– depends upon the command used to
create the file– set using the umask command
![Page 32: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/32.jpg)
Next Lecture
• UNIX commands for handling files• Regular Expressions and Searching
files• Redirecting output• Bash facilities
![Page 33: 2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions](https://reader035.vdocuments.us/reader035/viewer/2022062409/5697c0281a28abf838cd6e81/html5/thumbnails/33.jpg)
Summary
• Manual Pages
• The UNIX filestore
• Pathnames
• Security and file permissions