Linux File System Linux File System Describe the
Linux File System
Linux File System Describe the Linux File System Complete Common File System Tasks Manage Disk Partitions Use Removable Media Back Up Data
File System is developed for create/store/load/delete/seek file on media Media example Magnetic Media Optical Media 5. 1. 2022 Tape Floppy disk Hard disk Cdrom Dvd 3
File System of OS File system of Windows OS Windows 98 and Windows ME Windows 2000 Support FAT 16, FAT 32, NTFS Windows XP Support FAT 16, FAT 32 Support FAT 32, NTFS File system of BSD Family OS 5. 1. 2022 FFS (Fast File System) 4
File System in Linux is divided into 2 type Linux Swap is used in virtual memory system Linux File System is used to store file there is various type of file system 5. 1. 2022 ext 2 ( is first introduced in kernel 2. 0. x ) reiserfs ( is first introduced in kernel 2. 2. x ) ext 3 ( is first introduced in kernel 2. 4. x ) 5
Different between Linux and Windows File System 5. 1. 2022 6
Linux File System Layout 5. 1. 2022 / - first of mount point in linux /etc - keep linux default configuration /boot - keep important linux booting files /dev - keep all device files /usr- keep all user binary and X library /home - keep user home directory /proc - is pseudo file system for tracking running and state of linux system /var - keeping mail, log file and printer spooling /lib - contain shared library that is required by program /tmp - contain system temporary file process system 7
Searching the File System 5. 1. 2022 8
Using find Syntax: find path –name “filename” Ex: find / –name “*. log” –user “username” –size “size” 5. 1. 2022 9
Using locate Syntax: locate filename 5. 1. 2022 10
Using grep Search content in the file Syntax: grep search_text file Ex: grep vnc /var/log/messages 5. 1. 2022 11
Using grep When working with grep, you can use the following options: ■ –i Ignores case when searching for the search text. ■ –l Doesn’t display the actual matching line of text. Only displays the names of the files that contain the matching text. ■ –r Searches recursively through subdirectories of the path specified. 5. 1. 2022 12
Managing Files and Directories 5. 1. 2022 13
Creating files and directories Viewing file contents Deleting files and directories Copying and moving files and directories Creating links 5. 1. 2022 14
Creating Files and Directories To create file params within tmp: touch /tmp/params To create a directory: mkdir /tmp/backup 5. 1. 2022 15
Viewing Text File Contents cat filename less filename head filename tail filename 5. 1. 2022 16
Deleting Files and Directories rmdir dir_name : the directory must empty rm -r dir_name: delete directory rm filename: delete filename 5. 1. 2022 17
Copy or move file cp: copy mv: move 5. 1. 2022 18
Creating Links Hard link: Soft link (symbolic link): similar shortcut in windows 5. 1. 2022 19
PATH? 5. 1. 2022 20
5. 1. 2022 21
How Linux mount this layout? / /var /home Using mount command mount –t type device target-dir 5. 1. 2022 type ex. ext 2, ext 3, reiserfs, … device ex. /dev/hda 1, /dev/hdb 1, … target-dir ex. /, /var, /home, /mnt/cdrom, … 22
How to use mount command? / /var /home mount command example 5. 1. 2022 mount –t ext 2 /dev/hda 3 / mount –t ext 2 /dev/hda 4 /home mount –t ext 2 /dev/hda 1 /var 23
How can we check current mounted partition? Check current mounted by using mount command without parameter Example result for checking current mounted partition 5. 1. 2022 24
How to use un-mount partition? umount is used to un-mount partition umount directory umount device Example umount /var Or 5. 1. 2022 umount /hda 1 25
Where is linux store list of mounting partition when booting ? It is locate in /etc/fstab file Example of fstab file 5. 1. 2022 26
How can we add new mount partition entry in /etc/fstab? Assume – we would like to add windows partition (hdb 1, FAT 32) that linux have to mount at boot time at /mnt/windows 5. 1. 2022 file system = /dev/hdb 1 mount point = /mnt/window type = vfat Options = defaults Dump = 0 Pass = 1 27
How can we add new mount partition entry in /etc/fstab? From the previous information, we have to add following line in /etc/fstab files /dev/hba 1 5. 1. 2022 /mnt/windows vfat defaults 0 0 28
Working with Floppies mount –t vfat /dev/fd 0 /media/floppy
Working with Optical Devices Syntax: mount –t iso 9660 device mount_point Ex: mount –t iso 9660 /dev/hdc /media/cdrom.
Working with USB and Fire. Wire Devices Syntax: mount –t auto device mount_point Ex: mount –t auto /dev/sdd /media/THUMBDRIVE
Ex: 6. 5, page: 320
Manage Disk Partitions Using fdisk to create disk partitions Building a file system with mkfs Mounting a partition with mount Checking the file system with fsck Exercise: 6. 4, page: 312
Back Up Data ■ Selecting a backup medium ■ Selecting a backup strategy ■ Using Linux backup utilities
Selecting a Backup Strategy ■ Selecting a backup type ■ Selecting a backup schedule ■ Determining what to back up
Selecting a Backup Type ❑ Full backups back up everything and flag the files as having been backed up. ❑ Incremental backups back up everything that has been modified since the last full or incremental backup and flag the files as having been backed up. ❑ Differential backups back up everything that has been backed up since the last full backup. It doesn’t flag the files as having been backed up.
Using Linux Backup Utilities tar –cvf filename directory. The –c option tells tar to create a new archive. The –v option tells tar to work in verbose mode, displaying each file being backed up on screen. The –f option specifies the name of the tar archive to be created. tar –cvf /media/usb/backup. tar /home.
Using Linux Backup Utilities tar cpio
tar –cvf /dev/st 0 /home Backup /home to tape
Use tar to restore To restore a tar archive, simply enter tar –xvf filename
Create cpio find. –print –depth | cpio –ov > /media/usb/backup. cpio.
Cpio restore cpio –iv < /media/usb/backup. cpio.
- Slides: 44