08.file system

491 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
491
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

08.file system

  1. 1. Linux File Systems and File Minsuk Lee Hansung University, Seoul, Korea minsuk@hansung.ac.krNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  2. 2. 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 ~/NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  3. 3. 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— File name : 0 7 5 4 256 characters Case sensitive Attribute user group other No extension Most special characters acceptedAttribute: - : regular file b : block device permission: c : character device r : readable d : directory w : writable l : symbolic link x : executable (traversable) p : pipe s : socket $ chmod, $chown work here !NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  4. 4. Inode (metadata for a File) • Inode has information of a file – Inode also exists in disk – All the attributes, times, owner – Data block locations inodeNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  5. 5. File link • Link (hard link), Symbolic Link 디렉토리 Inode 블럭 Data 블럭 – myfile and myfile-link shares same disk space • One good usage of hard link is to protect not to be erased accidentally – myfile-sym-link is a link file with the target file name in itNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  6. 6. 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 maskedNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  7. 7. Set UID option ! • Some commands needs to change other’s file  Need some mechanism to run command with file owners permission • $ chmod u+s <executable-file> – Sets UID field in inode attributes – Makes rwx to rws THINK SECURITY !!NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  8. 8. The Root Directory ‘/’ (1)NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  9. 9. 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 hierarchy • /cdrom, /mnt/floppy, …NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  10. 10. /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 devicesNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  11. 11. /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 : partitionsNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  12. 12. Partition tableNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  13. 13. 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…NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  14. 14. 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-BIOSNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  15. 15. 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 databaseNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  16. 16. 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 $viNEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA

×