1 / 27

Introduction to the linux filesystem

Introduction to the linux filesystem. General overview of the Linux file system. "On a UNIX system, everything is a file; if something is not a file, it is a process." Programs, services, texts, images, and so forth, are all files

tocho
Download Presentation

Introduction to the linux filesystem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to the linux filesystem

  2. General overview of the Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Programs, services, texts, images, and so forth, are all files Input and output devices, and generally all devices, are considered to be files, according to the system

  3. Sorts of files Directories Special Files Links Sockets Named pipes

  4. Sorts of files raiden@TBE1ID980168:/home$ ls -l total 2 drwxr-xr-x 2 root root 48 2008-10-22 13:56 data drwxr-xr-x 39 raiden raiden 2008 2008-11-18 19:13 raiden lrwxrwxrwx 1 raiden raiden 8 2008-11-18 19:37 symlink_to_textfile -> textfile -rw-r--r-- 1 raiden raiden 0 2008-11-18 19:37 textfile drwxr-xr-x 2 root root 112 2008-11-18 09:20 ubuntu Example :

  5. Partitions data partition: the root partition containing all the data to start up and run the system swap partition: expansion of the computer's physical memory, extra memory on hard disk Partitioning depends on server purpose Different partitions may be needed : /usr, /var, /home, /opt

  6. Fdisk To access the tool : #fdisk /dev/sda In the menu (accessible with 'm') you can see all options what you can do. Fdisk is mostly used under the hood by GUI installers Very powerfull Q quits without writing, W writes the new partition table !! Be aware what you do here !!!

  7. Fdisk – a cli partition tool root@TBE1ID980168:/home# fdisk -l /dev/sda Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x94099409 Device Boot Start End Blocks Id System /dev/sda1 * 1 4865 39077608+ 7 HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sda2 4866 8455 28836675 f W95 Ext'd (LBA) /dev/sda3 8456 9549 8787555 83 Linux /dev/sda4 9550 9729 1445850 82 Linux swap / Solaris /dev/sda5 4866 8455 28826248+ 7 HPFS/NTFS

  8. Mount points All partitions are attached to the system via a mount point The mount point is a directory A device is attached to a mount point directory The cli tool ”mount” shows and manipulates the mounts The cli tool ”umount” unmounts the devices from the mount points

  9. Mount points root@TBE1ID980168:/home# mount /dev/sda3 on / type reiserfs (rw,relatime,notail) proc on /proc type proc (rw,noexec,nosuid,nodev) /sys on /sys type sysfs (rw,noexec,nosuid,nodev) varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755) varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777) udev on /dev type tmpfs (rw,mode=0755) devshm on /dev/shm type tmpfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) lrm on /lib/modules/2.6.24-21-generic/volatile type tmpfs (rw) /dev/sda5 on /media/sda5 type fuseblk (rw,nosuid,nodev,noatime,allow_other,default_permissions,blksize=4096) securityfs on /sys/kernel/security type securityfs (rw) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) none on /proc/fs/vmblock/mountPoint type vmblock (rw) gvfs-fuse-daemon on /home/raiden/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=raiden) //isengard/Data on /mnt/isengard type cifs (rw,mand) /dev/sdb1 on /media/USBNTFS type fuseblk (rw,nosuid,nodev,noatime,allow_other,blksize=4096)

  10. Mount points root@TBE1ID980168:/home# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 8.4G 3.5G 5.0G 41% / varrun 1010M 148K 1010M 1% /var/run varlock 1010M 0 1010M 0% /var/lock udev 1010M 60K 1010M 1% /dev devshm 1010M 12K 1010M 1% /dev/shm lrm 1010M 39M 971M 4% /lib/modules/2.6.24-21-generic/volatile /dev/sda5 28G 3.6G 24G 14% /media/sda5 //isengard/Data 233G 130G 104G 56% /mnt/isengard /dev/sdb1 112G 19G 93G 17% /media/USBNTFS

  11. /etc/fstab root@TBE1ID980168:/home# cat /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sda3 UUID=b0625ab5-11c0-41a2-88ac-d061a8c06f53 / reiserfs notail,relatime 0 1 # /dev/sda4 UUID=c334eba5-128a-4d0d-aa6a-e2bb5439076a none swap sw 0 0 /dev/sda5 /media/sda5 ntfs rw,uid=1000,gid=1000,file_mode=0664,dir_mode=0755 0 0 #/dev/sda1 /media/sda1 ntfs rw,uid=1000,gid=1000,file_mode=0664,dir_mode=0755 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 In this file all mountpoints can be set which need or get automounted on boot

  12. Filesystem Layout

  13. Filesystem Layout This is a layout from a RedHat system Depending on the system admin, the operating system and the mission of the UNIX machine, the structure may vary, and directories may be left out or added at will The names are not even required; they are only a convention

  14. Filesystem Layout root@TBE1ID980168:/home# ls -l / total 20 drwxr-xr-x 2 root root 2688 2008-10-13 10:06 bin drwxr-xr-x 3 root root 800 2008-11-13 12:50 boot lrwxrwxrwx 1 root root 11 2008-09-24 23:37 cdrom -> media/cdrom drwxr-xr-x 13 root root 14240 2008-11-18 18:57 dev drwxr-xr-x 134 root root 6736 2008-11-18 20:09 etc drwxr-xr-x 5 raiden raiden 184 2008-11-18 19:37 home drwxr-xr-x 2 root root 48 2008-07-02 12:16 initrd lrwxrwxrwx 1 root root 33 2008-09-25 09:28 initrd.img -> boot/initrd.img-2.6.24-21-generic lrwxrwxrwx 1 root root 33 2008-09-25 01:53 initrd.img.old -> boot/initrd.img-2.6.24-19-generic drwxr-xr-x 16 root root 5104 2008-11-10 15:35 lib lrwxrwxrwx 1 root root 44 2008-11-10 15:43 liblibvixAllProducts.so -> /usr/lib/vmware-vix/lib/libvixAllProducts.so drwxr-xr-x 6 root root 232 2008-11-18 18:57 media drwxr-xr-x 6 root root 152 2008-10-17 09:11 mnt drwxr-xr-x 2 root root 48 2008-07-02 12:16 opt dr-xr-xr-x 154 root root 0 2008-11-18 19:47 proc drwxr-xr-x 14 root root 920 2008-11-12 18:03 root drwxr-xr-x 2 root root 4552 2008-11-13 12:48 sbin drwxr-xr-x 2 root root 48 2008-07-02 12:16 srv drwxr-xr-x 12 root root 0 2008-11-18 19:47 sys drwxrwxrwt 17 root root 856 2008-11-18 19:59 tmp drwxr-xr-x 11 root root 264 2008-07-02 12:18 usr drwxr-xr-x 15 root root 384 2008-11-12 18:03 var lrwxrwxrwx 1 root root 30 2008-09-25 09:28 vmlinuz -> boot/vmlinuz-2.6.24-21-generic lrwxrwxrwx 1 root root 30 2008-09-25 01:53 vmlinuz.old -> boot/vmlinuz-2.6.24-19-generic

  15. Overview of the directories /bin Common programs, shared by the system, the system administrator and the users. /boot The startup files and the kernel, vmlinuz. Grub is the GRand Unified Boot loader /dev Contains references to all the CPU peripheral hardware /etc Most important system configuration files are in /etc, this is similar to the Control Panel in Windows /home Home directories of the common users. /initrd (on some distributions) Information for booting. Do not remove! /lib Library files, includes files for all kinds of programs needed by the system and the users. /lost+found Every partition has a lost+found in its upper directory. Files that were saved during failures are here. /misc For miscellaneous purposes. /mnt Standard mount point for external file systems, e.g. a CD-ROM or a digital camera. /net Standard mount point for entire remote file systems /opt Typically contains extra and third party software. /proc A virtual file system containing information about system resources. /root Home of root. Mind the difference between /, the root directory and /root, the home directory of the root user. /sbin Programs for use by the system and the system administrator. /tmp Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work! /usr Programs, libraries, documentation etc. for all user-related programs. /var Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler, .

  16. $PATH When you want the system to execute a command, you almost never have to give the full path to that command %echo $PATH Practically the same as %PATH% in Windows Can be different between users (eg. Root and other users) %which <command>

  17. Absolute and Relative paths A path, which is the way you need to follow in the tree structure to reach a given file An absolute path is the entire path to that file A relative path is the path based upon your current position %pwd shows where you are ~ is the direct relative path to your home-dir

  18. /etc is your control panel ! Everything is filebased Your tweaking and configuration is to be done from /etc GUI based configurations will adapt these files too Examples are /etc/fstab, /etc/resolv.conf, nsswitch.conf

  19. Most common devices /dev/[h][s]d /dev/cdrom /dev/fd /dev/md /dev/mouse or /dev/psaux

  20. Viewing File properties The command 'ls' is used for this %man ls Examples are : ls -l, ls -la, ls <dir/file>

  21. File shows the type root@TBE1ID980168:/home/raiden# file sig.jpg sig.jpg: JPEG image data, JFIF standard 1.01 root@TBE1ID980168:/home/raiden# file LinuxCupsPrinterPkg.01.2008.tar.gz LinuxCupsPrinterPkg.01.2008.tar.gz: gzip compressed data, was "IYIPqc.tar", from Unix, last modified: Tue Jan 22 08:43:19 2008 root@TBE1ID980168:/home/raiden# file xorg_20071115.conf xorg_20071115.conf: ASCII English text

  22. Common file-manipulators %mkdir <dir> (create a directory) %mv <file> <new-file> (move or rename files/dirs) %cp <file> <new-file> (copy files/dirs) %rmdir <dir> (remove an empty dir) %rm <file/dir> (remove files/dirs) %which <command> (find absolute path of a cmd)

  23. View files Use an editor like nano, pico, vi, vim, ... %cat <file> (show content of a file in the console) Grep (filter out lines of a file matching a pattern) e.g. %cat <file> | grep <pattern> Less is more ! Use less or more to view files Use 'q' to exit less or more

  24. File permissions First line of defense ! Every file is owned by a user and a group user There is also a third group of users who don't belong to the user and group that own the file Permissions are always set in the sequence ”owner – group – others” Possible clearances are read, write and execute

  25. File permissions 0 or - The access right that is supposed to be on this place is not granted. 4 or r Read access is granted to the user category defined in this place 2 or w Write permission is granted to the user category defined in this place 1 or x Execute permission is granted to the user category defined in this place %chmod 644 file means : 6 = 4 + 2 meaning rw- for the first one, the owner 4 = r, meaning r-- for the ownergroup 4 = r, meaning r-- for all te others Combined this gives : -rw-r--r-- 1 root root 0 2008-11-18 20:57 file

  26. Manipulate file-attributes %chmod <attributes> <file/dir> (Change permissions for the file/dir %chown <user> <file> (change owner of a file) %chgrp <group> <file> (change groupownership for a file) Trick : chown user:group <file>

  27. Basic File protection chmod 400 file To protect a file against accidental overwriting. chmod 500 directory To protect yourself from accidentally removing, renaming or moving files from this directory. chmod 600 file A private file only changeable by the user who entered this command. chmod 644 file A publicly readable file that can only be changed by the issuing user. chmod 660 file Users belonging to your group can change this file, others don't have any access to it at all. chmod 700 file Protects a file against any access from other users, while the issuing user still has full access. chmod 755 directory For files that should be readable and executable by others, but only changeable by the issuing user. chmod 775 file Standard file sharing mode for a group. chmod 777 file Everybody can do everything to this file.

More Related