managing files csci n321 – system and network administration copyright © 2000, 2011 by the...
TRANSCRIPT
![Page 1: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/1.jpg)
Managing Files
CSCI N321 – System and Network Administration
Copyright © 2000, 2011 by the Trustees of Indiana University except as noted
![Page 2: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/2.jpg)
Section Overview
File types
File attributes and ownership
Changing access permissions
Special attributes
Searching the filesystem
![Page 3: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/3.jpg)
References
CQU 85321 System Administration Course Chapter 5
![Page 4: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/4.jpg)
Types of Files
Regular FilesDirectoriesDevices Character Devices Block Devices
Sockets and Named PipesSymbolic Links
![Page 5: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/5.jpg)
Files and Directories
Everything is referenced via a fileDirectories List of files & inodes “.” – Reference to the current
directory “..” – Reference to parent directory Root (/) – “.” and “..” are the same
![Page 6: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/6.jpg)
Device Files
Character Devices Transfer unit: byte Example: /dev/console
Block Devices Transfer unit: Group of bytes (block) Examples: /dev/hda
Device Numbers Major – Type of device Minor – Device number
![Page 7: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/7.jpg)
Sockets & Named Pipes
Enables communication between processesSocket Processed must have a connection first Example: X Windows
Named Pipe Communication between unrelated processes FIFO Not used very often
![Page 8: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/8.jpg)
Link Files
Multiple names for same fileHard Link Pointer to Inode Can’t cross partitions File removed when all links deleted
Symbolic (Soft) Links Pointer to file path name Dangling symlink – Real file which no longer
exists
ln [-s] <real_file> <link_file>
![Page 9: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/9.jpg)
Magic Numbers
Byte pattern at beginning of filePatterns listed in file called magicRedHat: /usr/share/magicfile – Tests a file to determine type Filesystem Test Magic Number Test Language Test
![Page 10: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/10.jpg)
Access Control Model
SubjectSubjectOSOS
ReferenceReferenceMonitorMonitor
ObjectObjectAccessAccessrequestrequest
AccessAccessGrantedGranted
![Page 11: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/11.jpg)
MS File/Directory Attributes
Read-OnlyRead-Only
HiddenHidden
SystemSystem
ArchiveArchive
![Page 12: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/12.jpg)
UNIX/Linux File Attributes
InodeInode
Permissions
Ownership
Time StampsChangeModificationAccess
File Size
Link Count
Pointers to data
![Page 13: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/13.jpg)
Viewing File Attributes
File TypePermissionsLink CountOwnership
File Size/Device #Modification DateFile Name
ls –l: Long listing (includes attributes)
stat: Lists all attributes
![Page 14: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/14.jpg)
File Type Attribute
# ls -ld /home /etc/passwd /dev/console
crw--w--w- 1 root root 5, 1 Sep 27 11:27 /dev/console
-rw-r--r-- 1 root root 559 Sep 22 13:14 /etc/passwd
drwxr-xr-x 3 root root 0 Sep 26 10:42 /home
File TypeFile Type MeaningMeaning
- Regular File
d Directory
l Symbolic Link
b Block Device
c Character Device
p Named Pipe
s Domain Socket
![Page 15: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/15.jpg)
Ownership
User Owner of file User names/UIDs defined in /etc/passwd
Group Organization of users accessing the file Group names/GIDs defined in /etc/group
# ls -ld /home /etc/passwd /dev/console
crw--w--w- 1 root root 5, 1 Sep 27 11:27 /dev/console
-rw-r--r-- 1 root root 559 Sep 22 13:14 /etc/passwd
drwxr-xr-x 3 root root 0 Sep 26 10:42 /home
![Page 16: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/16.jpg)
Permissions
3 levels of access – Owner, Group, Other
# ls -ld /home /etc/passwd /dev/console
crw--w--w- 1 root root 5, 1 Sep 27 11:27 /dev/console
-rw-r--r-- 1 root root 559 Sep 22 13:14 /etc/passwd
drwxr-xr-x 3 root root 0 Sep 26 10:42 /home
OperatioOperationn
FileFile DirectoryDirectory
Read Read file List files
Write Delete/Modify file
Create/Delete file
Execute Run program Access file
![Page 17: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/17.jpg)
Changing Access
Users & Groups chown [-R] user file… chgrp [-R] group file
Permissions chmod [-R] <op> file… Numeric: <op> = [#]### Symbolic: <op> = <who op perm>
Who: (u)ser (g)roup (o)ther (a)llop: (+)add (-)remove (=)setPerm: (r)ead (w)rite e(x)ecute
![Page 18: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/18.jpg)
Numeric/Symbolic Permissions
OctalOctal BinaryBinary SymbolicSymbolic
0 000 ---
1 001 --x
2 010 -w-
3 011 -wx
4 100 r--
5 101 r-x
6 110 rw-
7 111 rwx
![Page 19: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/19.jpg)
Default Permissions
umask Shell Environment VariableDefines permissions to remove
NumericNumeric BinaryBinary Effective Effective PermsPerms
0 000 rwx
1 001 rw-
2 010 r-w
3 011 r--
4 100 -wx
5 101 -w-
6 110 --x
7 111 ---
![Page 20: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/20.jpg)
Special AttributesSetuid (SUID) Bit Run program with access of owner Symbolic: s Numeric: 4000
Setgid (SGID) Bit Run program with access of owner
group Symbolic: s Numeric: 2000
![Page 21: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/21.jpg)
Sticky Bit
Purpose File: Force program to stay in RAM
(obsolete) Directory: Cannot remove file unless
you own the file or directory
Symbolic: tNumeric: 1000Example: /tmp
![Page 22: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/22.jpg)
Microsoft Permissions
ReadCreateWriteAppendDelete
ExecuteSearchOwnershipAccess Control
GUI and CLI (iGUI and CLI (icaclscacls) tools to manage) tools to manage Denials and effective permissionsDenials and effective permissions
![Page 23: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/23.jpg)
Default Permissions?
Linux/Mac Predefined default (users can change) umask
Microsoft Inherited from parent directory Can disable
![Page 24: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/24.jpg)
Group Access
Users requiring same access to objectSimplifies adding/removing of access Adding/Removing users Adding/removing permissions to object
Multiple group membership interaction Union Interception Deny permissions
![Page 25: Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted](https://reader030.vdocument.in/reader030/viewer/2022032606/56649e975503460f94b9a603/html5/thumbnails/25.jpg)
Searching the Filesystemfind: Command line search tool
Searches through directory hierarchy Search by any combination of file names and attributesDisplay files or perform operations on themExamples: find /var –mtime -1 find / -name core –exec rm –f {} \;