Upload
cecily-pearson
View
213
Download
0
Embed Size (px)
Citation preview
1© 2001 John Urrutia. All rights reserved.
Chapter 4
The LINUX FilesystemThe LINUX Filesystem
2© 2001 John Urrutia. All rights reserved.
TopicsThe Hierarchical File System
Directory and Ordinary Files
Working With Directories
Access Permissions
Links
3© 2001 John Urrutia. All rights reserved.
Hierarchical File SystemsStructured like an upside-down
tree
Grandparents at the top
Parents follow
Then Children
Topics
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)
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
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.
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
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
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
˜
10© 2001 John Urrutia. All rights reserved.
TopicsThe Hierarchical File System
Directory and Ordinary Files
Working With Directories
Access Permissions
Links
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
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
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
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
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
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.
17© 2001 John Urrutia. All rights reserved.
Your Working DirectoryGenerally you’re working directory
will be/home/userid
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
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
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
21© 2001 John Urrutia. All rights reserved.
Access PermissionsEvery file has access “permissions”
associated with them.r – read
w – write
x – execute
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
23© 2001 John Urrutia. All rights reserved.
Access PermissionsDirectory file access “permissions”
r – read the directory
w – write the directory
x – search the directory
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
25© 2001 John Urrutia. All rights reserved.
Directory Utilitieschmod – change access mode
u – User or owner
g – group
o – others
+ – add permission
- – remove permission
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
27© 2001 John Urrutia. All rights reserved.
Directory Utilitiesrmdir – remove Directory
rmdir directory-listdirectory-list
One or more directories separated by space
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
29© 2001 John Urrutia. All rights reserved.
Directory Utilitiescd – change directory
cd directory The directory (pathname) becomes the
working directory
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
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
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
33© 2001 John Urrutia. All rights reserved.
Link Utilityln – Make a link entry
ln [–s] filename linkname
ln [–s] file-list directory