1 © 2001 john urrutia. all rights reserved. chapter 4 the linux filesystem
TRANSCRIPT
![Page 1: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/1.jpg)
1© 2001 John Urrutia. All rights reserved.
Chapter 4
The LINUX FilesystemThe LINUX Filesystem
![Page 2: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/2.jpg)
2© 2001 John Urrutia. All rights reserved.
TopicsThe Hierarchical File System
Directory and Ordinary Files
Working With Directories
Access Permissions
Links
![Page 3: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/3.jpg)
3© 2001 John Urrutia. All rights reserved.
Hierarchical File SystemsStructured like an upside-down
tree
Grandparents at the top
Parents follow
Then Children
Topics
![Page 4: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/4.jpg)
4© 2001 John Urrutia. All rights reserved.
Child 1 Child 2 Child 3
Grandparent
Parent aunt uncle
/Alice /Bobby /Carol
/home /tmp /bin
Hierarchical Structure/
(aka root)
![Page 5: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/5.jpg)
5© 2001 John Urrutia. All rights reserved.
Hierarchical File SystemsDirectories and ordinary files
Directories / sub-directoriesSpecial files used for grouping
Ordinary FilesContain the kitchen sink
![Page 6: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/6.jpg)
6© 2001 John Urrutia. All rights reserved.
Directory assistanceDirectories provide an organized
method to access ordinary files.path –
A series of directory files traveling from the root to the ordinary file.
pathname – The sequenced listing of directory names
from the root to the ordinary file.
![Page 7: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/7.jpg)
7© 2001 John Urrutia. All rights reserved.
FilenamesFilenames
Max length 255 characters
A thru Z, a thru z, 0 thru 9 _ . ,Some file systems limit these to 14 characters
Make them meaningful30952344 IMd12CRU OOicu812
![Page 8: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/8.jpg)
8© 2001 John Urrutia. All rights reserved.
Filename ExtensionsBegins with a period
Generally are optional
Used by applications to identify specific file needed by the applicationExamples: CPP TXT INI
![Page 9: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/9.jpg)
9© 2001 John Urrutia. All rights reserved.
Invisible FilesMust start with a period
Normally not displayed
Used by Unix for special purposes
Use “ls –a” to see these
˜
![Page 10: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/10.jpg)
10© 2001 John Urrutia. All rights reserved.
TopicsThe Hierarchical File System
Directory and Ordinary Files
Working With Directories
Access Permissions
Links
![Page 11: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/11.jpg)
11© 2001 John Urrutia. All rights reserved.
Creating a directorymkdir – utility creates a directory
The argument can either specify an absolute pathname or a relative pathname
mkdir mydirectoryIn this example “mydirectory” will be
created under the current or working directory
![Page 12: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/12.jpg)
12© 2001 John Urrutia. All rights reserved.
Directory fileTwo invisible files are created for
each directory createdOne is the pathname of the working
directory named “”
Two is the pathname of the parent directory named “ ”cat ./Test.filecat Test.file
![Page 13: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/13.jpg)
13© 2001 John Urrutia. All rights reserved.
Path (to glory or destruction)
Every file has a PATHNAMEAbsolute Pathnames begin with the root
(/)
Each directory in the hierarchy from the root to the file is separated by a slash
![Page 14: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/14.jpg)
14© 2001 John Urrutia. All rights reserved.
Test.file
Path example:
/Alice /Bobby /Carol
/home /tmp /bin
//
/home
/Bobby
Test.file
/home/Bobby/Test.file
![Page 15: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/15.jpg)
15© 2001 John Urrutia. All rights reserved.
Absolute & Relative PathAbsolute path is fully qualified
cat /home/Bobby/Test.file
Relative path is based on the working directorypwd – Print Working Directory
/home/Bobbycat Test.file
![Page 16: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/16.jpg)
16© 2001 John Urrutia. All rights reserved.
The Working DirectoryYou’re working directory is assigned
by the login process.
To access files in working directory simply refer to the filename no path is needed.
Files outside your working directory require a pathname.
![Page 17: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/17.jpg)
17© 2001 John Urrutia. All rights reserved.
Your Working DirectoryGenerally you’re working directory
will be/home/userid
![Page 18: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/18.jpg)
18© 2001 John Urrutia. All rights reserved.
Important Directories and FilesThe root - / (of all evil)
/root – Home directory for root
/boot – static files of the boot loader
/bin – files needed to boot the system
/sbin – /usr/sbin system admin. utilities
/dev – device files
/etc – admin. and configuration files
![Page 19: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/19.jpg)
19© 2001 John Urrutia. All rights reserved.
Important Directories and Files/tmp – temporary files
/home – user home directories
/lib – shared libraries
/mnt – mount point of temporary partitions
/tmp – temporary files
/usr – 2nd major hierarchy – rarely change
/proc – kernel and process information
![Page 20: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/20.jpg)
20© 2001 John Urrutia. All rights reserved.
Changing working directorypwd – displays your working directory
cd - change directoryBy default places you in your working
directory(ie /home/userid)
cd ~ (will do the same thing)
cd path/path1 – changes relative to your working directory
![Page 21: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/21.jpg)
21© 2001 John Urrutia. All rights reserved.
Access PermissionsEvery file has access “permissions”
associated with them.r – read
w – write
x – execute
![Page 22: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/22.jpg)
22© 2001 John Urrutia. All rights reserved.
Access PermissionsEvery ordinary file has three access
groups.Owner or User
User who created the file
GroupUsers who are associated
OthersThe rest of the world
![Page 23: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/23.jpg)
23© 2001 John Urrutia. All rights reserved.
Access PermissionsDirectory file access “permissions”
r – read the directory
w – write the directory
x – search the directory
![Page 24: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/24.jpg)
24© 2001 John Urrutia. All rights reserved.
Access PermissionsSetting default “permissions”
umask 000One digit each for U,G,OOctal value representing the 3 bits
R W X R W X R W X
4 2 1 4 2 1 4 2 1
![Page 25: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/25.jpg)
25© 2001 John Urrutia. All rights reserved.
Directory Utilitieschmod – change access mode
u – User or owner
g – group
o – others
+ – add permission
- – remove permission
![Page 26: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/26.jpg)
26© 2001 John Urrutia. All rights reserved.
Directory Utilitiesmkdir – Make Directory
mkdir –p directory-listThe –p option creates the parent
directory if it doesn’t existdirectory-list
One or more directories separated by space
![Page 27: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/27.jpg)
27© 2001 John Urrutia. All rights reserved.
Directory Utilitiesrmdir – remove Directory
rmdir directory-listdirectory-list
One or more directories separated by space
![Page 28: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/28.jpg)
28© 2001 John Urrutia. All rights reserved.
Directory Utilitiesrm – remove
rm –r directory-listThe –r option removes recursively. All
subdirectories are removeddirectory-list
One or more directories separated by space
![Page 29: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/29.jpg)
29© 2001 John Urrutia. All rights reserved.
Directory Utilitiescd – change directory
cd directory The directory (pathname) becomes the
working directory
![Page 30: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/30.jpg)
30© 2001 John Urrutia. All rights reserved.
Linksaka – Also Known As
Creates an entry in the directory that point to an existing file or directory.
Doesn’t create a copy of the file
![Page 31: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/31.jpg)
31© 2001 John Urrutia. All rights reserved.
Links – Hard and SymbolicHard links
Behave just like a file
Cannot distinguish the original filename from the link
Cannot cross file systems
Directory links by superuser only
![Page 32: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/32.jpg)
32© 2001 John Urrutia. All rights reserved.
Links – Hard and SymbolicSymbolic links
Indirect pointer to file or directory
Can be created by anyone
Can reside anywhere
Can become an orphan
![Page 33: 1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem](https://reader035.vdocuments.mx/reader035/viewer/2022081603/5697bf831a28abf838c865a0/html5/thumbnails/33.jpg)
33© 2001 John Urrutia. All rights reserved.
Link Utilityln – Make a link entry
ln [–s] filename linkname
ln [–s] file-list directory