08.file system
-
Upload
minsuk-lee -
Category
Documents
-
view
192 -
download
1
Transcript of 08.file system
![Page 1: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/1.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Linux File Systems and File
Minsuk LeeHansung University, Seoul, Korea
![Page 2: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/2.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Linux File System
• In Linux, everything is a file.– Its attribute is different
• Regular File, Directory, Link, Device
• Every file has owner and group.• Every file has permission for– owner, group, and others
• Prebuilt directory architecture :– /etc, /dev, /usr, /sbin, /…
DON’T CHANGE IT !YOU MANAGE YOUR OWN HOME DIRECTORY ~/
![Page 3: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/3.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Attribute of a File
• $ ls -l
Attr perm #link owner group file size date time filename----------------------------------------------------------------------------------------rw-r--r-- 1 myuser myuser 164 2011-08-28 14:25 myfile - rwx r-x
r— 0 7 5 4Attribute user group other
Attribute:- : regular file b : block devicec : character de-viced : directoryl : symbolic link p : pipes : socket
File name :256 charactersCase sensitiveNo extensionMost special characters ac-cepted
$ chmod, $chown work here !
permission:r : readablew : writablex : executable (traversable)
![Page 4: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/4.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
• Inode has information of a file– Inode also exists in disk– All the attributes, times, owner– Data block locations
Inode (metadata for a File)
inode
![Page 5: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/5.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
File link• Link (hard link), Symbolic Link
– myfile and myfile-link shares same disk space• One good usage of hard link is to protect not to be erased acciden-
tally
– myfile-sym-link is a link file with the target file name in it
Inode 블럭
Data 블럭디렉토리
![Page 6: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/6.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Permission Masking
• Default permission setting– ‘$ umask mask ‘ : masking 666 (rw-rw-rw-) with mask – default mask value = 022 (rw-r--r--)– ‘x’ field cannot be masked
![Page 7: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/7.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
• Some commands needs to change other’s file
Need some mechanism to run command with file owners permis-sion
• $ chmod u+s <executable-file>– Sets UID field in inode attributes– Makes rwx to rws
Set UID option !
THINKSECURITY
!!
![Page 8: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/8.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
The Root Directory ‘/’ (1)
![Page 9: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/9.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
The Root directory (2)• / : the root directory (top most directory in the system)
– All absolute directory path starts with ‘/’
–There is NO ‘C:\’, ‘D:\’,– every storage is mounted somewhere in directory hier-
archy• /cdrom, /mnt/floppy, …
![Page 10: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/10.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
/dev (1)• Device special files : the abstraction to access hardware
devices– block devices : hdd, cdrom, floppy disk, tape, USB memory– character devices : serial port, …– other devices
![Page 11: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/11.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
/dev (2)
• IDE hdd– brw-rw---- : b block device, user/group :
rw– Owner : root, group : disk– Device Major, minor number : 8,0– /dev/sda : the Whole IDE disk• /dev/sda1, /dev/sda2, /dev/sda5 : partitions
![Page 12: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/12.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Partition table
![Page 13: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/13.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Other directories (1)• /bin : Most frequently used commands • /etc : Configuration File directory– System itself, servers, applications, …
• /home : user’s home directories• /lib : shared libraries, kernel modules• /lost+found : area for file system check utility• /mnt : default mount point (not mandatory)– For removable storages (cdrom, usb, floppy, ...)
• /root : home directory for superuser• /sbin : commands for system management– fsck, ifconfig, lsmod, mkfs, reboot…
![Page 14: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/14.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Other directories (2)
• /tmp : directory for temporary data • /var : directory for frequently changed data
– Logs, mail spool, print spool, lock files• /sys. /proc : system monitoring (virtual)• /usr : commands/library/data for users
• /boot : files for Boot– Booting Process
• PowerON ROM-BIOS (read MBR) BootLoader Kernel• For embedded devices there is no ROM-BIOS
![Page 15: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/15.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Locating files• $ which <filename>
– Search execution file in PATH
• $ whereis <filename>– Search Execution file, source, man page file
• $ locate <filename-pattern>– Search system for the pattern
• Works like ‘$ find ./ -name *pattern*’
– Needs ‘$ updatedb’ to refresh database
![Page 16: 08.file system](https://reader036.fdocuments.us/reader036/viewer/2022081515/5588f760d8b42a9e4e8b4609/html5/thumbnails/16.jpg)
CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPANEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Let’s practice !
• Make link and symbolic link for a file– See what happen if erase files• Erasing the link file, erasing the original file
• Apply umask and generate file with $vi