Chapter 6. Linux File System

Similar documents
Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

CST8207: GNU/Linux Operating Systems I Lab Nine Disks, Partitions, and File Systems Part 2. Disks, Partitions, and File Systems - Part 2 of 2

Manage Directories and Files in Linux. Objectives. Understand the Filesystem Hierarchy Standard (FHS)

File systems and Filesystem quota

LiLo Crash Recovery. 1.0 Preparation Tips. 2.0 Quick Steps to recovery

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Disks, Filesystems 1

Getting Started with Linux

Embedded System Design

Full file at

Unix System Architecture, File System, and Shell Commands

Disks, Filesystems, Booting Todd Kelley CST8177 Todd Kelley 1

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Chapter 4 File system management. Chapter 4 File system management

Disks, Filesystems Todd Kelley CST8177 Todd Kelley 1

5/8/2012. Creating and Changing Directories Chapter 7

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Filesystem Hierarchy Operating systems I800 Edmund Laugasson

UNIX System Programming Lecture 3: BASH Programming

CSE 265: System and Network Administration

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

RocketRAID 231x/230x SATA Controller Debian Linux Installation Guide

File System Hierarchy Standard (FHS)

Lecture 2: The file system

Partitioning and Formatting Guide

Linux Command Line Primer. By: Scott Marshall

RocketRAID 231x/230x SATA Controller Red Hat Enterprise/CentOS Linux Installation Guide

RocketRAID 231x/230x SATA Controller Fedora Linux Installation Guide

RocketRAID 2680/2684 SAS Controller Red Hat Enterprise/CentOS Linux Installation Guide

Fedora Linux Installation Guide

RocketRAID 2522 SATA Controller Ubuntu Linux Installation Guide

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Exam Linux-Praxis - 1 ( From )

Filesystem Hierarchy and Permissions

Project 3: An Introduction to File Systems. COP 4610 / CGS 5765 Principles of Operating Systems

CST Algonquin College 2

SLES Linux Installation Guide

RocketRAID 2310/2300 Controller Fedora Linux Installation Guide

Filesystem Hierarchy and Permissions

Lab Working with Linux Command Line

CSE 265: System and Network Administration

TestOut Linux Pro - English 4.0.x OBJECTIVE MAPPING: CompTIA Linux+ LX0-103

CSCI 2132 Software Development. Lecture 4: Files and Directories

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

File System. yihshih

Presented by Bill Genske Gary Jackson

Project 3: An Introduction to File Systems. COP4610 Florida State University

Std: XI CHAPTER-3 LINUX

Ubuntu Linux Installation Guide

Rocket RAID 2644 SAS Controller opensuse Linux Installation Guide

Fedora Linux Installation Guide

h/w m/c Kernel shell Application s/w user

How To Resize ext3 Partitions Without Losing Data

Introduction to Linux Part I: The Filesystem Luca Heltai

Chapter-3. Introduction to Unix: Fundamental Commands

CREATION OF A MINIMAL STAND ALONE RTAI SYSTEM ================================================

Linux Nuts and Bolts

UNIX File Hierarchy: Structure and Commands

Linux Files and the File System

Soma s Installation Notes

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

OPS235. Linux File Systems Partitioning Mounting File Systems

Week 10 Project 3: An Introduction to File Systems. Classes COP4610 / CGS5765 Florida State University

INTRODUCTION TO LINUX

LPIC-1 System Administrator

The landscape. File hierarchy overview. A tree structure of directories The directory tree is standardized. But varies slightly among distributions

Introduction to UNIX command-line

Files and Directories

RH133. Red Hat Linux System Administration

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Stop all processes and then reboot - same as above startx. Log in as superuser from current login exit

Installation of the OS

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Asianux Server 3 Installation Guide

Perl and R Scripting for Biologists

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Some Practical Matters. Introduction to Unix. What's Our Goal? Linux!= UNIX

Files

Introduction to Linux

Files. Computer Center, CS, NCTU. % ls l. d rwx--x--x 7 liuyh gcs 1024 Sep 22 17:25 public_html. File type. File access mode.

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Unix Introduction to UNIX

File System: Interface and Implmentation

Operating Systems: Lecture 12. File-System Interface and Implementation

Lab E2: bypassing authentication and resetting passwords

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

A file system is a clearly-defined method that the computer's operating system uses to store, catalog, and retrieve files.

Disks & File Systems. Dick Gillman, ITSS. 1/19/06 10:20:11 am docs/disks.sxi

ELEC 377 Operating Systems. Week 8 Class 1

Linux Essentials Objectives Topics:

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Using grub to Boot various Operating Systems

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Linux Systems Administration Getting Started with Linux

Basic Linux Command Line Interface Guide

PiCloud. Building owncloud on a Raspberry PI

Learn Linux, 101: Control mounting and unmounting of

Transcription:

Chapter 6 Linux File System 1

File System File System management how to store informations on storage devices The Hierarchical Structure Types of file Common File system Tasks 2

The Hierarchical Structure of the Linux File System / home etc usr bin boot dev lib root local bin 3

/ The Hierarchical Structure of the /bin /etc /boot /dev /usr /home Linux File System - first of mount point in linux - contains shells (bash) and file system management utilities - keep linux text-based configuration files - keep important linux booting files - keep all device files - keep all user binary and X library - keep user home directory /proc - is pseudo file system for tracking running process and state of linux system 4

The Hierarchical Structure of the Linux File System /var - keeping variable data, log file and printer spooling /lib - contain shared library that is required by system program /tmp - contain system temporary file /root - the root user s home directory /sbin - contains important system management and admin files (fdisk, fsck, ifconfig, init, mkfs, shutdown, halt) /media - system use to mount externel devices (CD/DVD, floppy drives) (or /mnt) 5

The Hierarchical Structure of the Linux File System Files in /etc directory 6

The Hierarchical Structure of the Linux File System FHS (Filesystem Hierarchy Standard) provide a standard directory structure for the file system, ensuring consistency between systems and distributions. http://www.pathname.com/fhs 7

Types of Files Regular files Links FIFOs Sockets 8

Navigating the File System Path absolute path Current directory & relative path Home directory (~) pwd, cd, ls pwd (Present Working Directory) Display the current directory $ pwd cd Change the current directory $ cd /var/log $ cd.. $ cd ~ (or press cd ) 9

Navigating the File System pwd, cd, ls ls List the files and subdirectories that exist within a directory $ ls / $ ls /bin $ ls l / $ ls a /var/run $ ls R /var/run $ ls 10

Navigating the File System $ ls l ~ 1 file type 2 Owner s /Group/Other Permissions 3 Number of link 4 Owner s name 5 Group s name 6 Size 7 Last Update datetime 11 8 File/Dir name

Navigating the File System File type normal file - Block device file b Character device file c Directory d Link file l Permissions on file /directory Read r Write w Execute x 12

Creating Files and Directories Creating a new file : touch or vi touch command touch myfile.txt // size = 0 Using a Text editor vi newfile.txt vi /home/user1/file.txt Creating a directory : mkdir mkdir mydir mkdir /home/ti/mydir mkdir -p /home/ti/aa/bb 13

Viewing text file content cat, more, less, head, tail cat filename more more filename less filename Auto stop when full screen. Using spacebar, page up, page down, arrow keys when viewing head filename Display the first couple of lines of a text file tail filename Display the last couple of lines of a text file tail f filename : display new content to be added to the end of the file 14

Copying, moving, deleting cp, mv, rm, rmdir cp /tmp/schedule.txt ~ //copy file cp R ~/mydir ~/backup //copy dir. mv /tmp/mylog.txt /var/log //move file mv myfile.txt mynewfile.txt //rename rm filename //delete file rm -r dirname //delete directory rm -i filename //prompt rmdir dirname //delete empty directory 15

Using wildcard charaters *,?, [ab], [a-z] Example : there are these files in current directory vd.txt, vda.txt, vdb.txt, vdabc.txt, vd1.txt, vd22.txt, vd3.txt $ cp *.txt /home/an //copy 7 files $ cp vd[1-5].txt /home/an // copy 2 file $ cp vd[ab].txt /home/an // copy 2 file 16

Link files Hard link and Symbolic link (soft link) Pointers a different file/directory in the file system Symbolic link : similar shortcut in Windows OS ln pointee_file pointer_file ln -s pointee_file pointer_file (pointee_file = source file/dir pointer_file = hard link/ symbolic link file) $ ln -s /usr/share/doc/ ~/docs 17

Running executable file Linux OS searches through the directories listed in your PATH environment variable for the executable file you specified. Adding a new path to the $PATH PATH=$PATH:newpath Determine resident of exec file which $ which vi /usr/bin/vi $ which ls /bin/ls 18

Searching the File System find, locate, grep Find utility searchs for files of a specified name, or owner, or size Using *,? when specified name find path -name filename find path -user username find path -size size find path -size +size find path -size -size find / -name *.log find / -user root find / -size +100 19

Searching the File System Locate utility builds an index of the files. When searching files, locate runs a query of the index, doesn t search the file system directly. Locate runs much faster than find To use locate, must first install the findutilslocate package 20

Searching the File System Using grep to search for content within a file grep search_text file grep r help /*.txt grep help *.txt 21

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 22

Storage Devices In Linux system, storage devices is referenced as device files that stored in /dev directory. SCSI Hard disks, USB disks sda sdb sdc /dev/sda /dev/sdb /dev/sdc IDE Hard disks hda hdb hdc /dev/hda /dev/hdb /dev/hdc Floppy disks fd0 fd1 /dev/fd0 /dev/fd1 CDRom SCSI sr0 sr1 /dev/sr0 /dev/sr1 23

Partitions Primary and Extended partitions On the IDE hard disk, up to four primary partitions One of the primary partitions can be extended partition Include many logical partitions M B R 1 2 3 4 primary M B R 1 2 5 6 3 7 4 8 extended logical 24

Partitions Each Partition is referenced as one device, and have a device file in /dev Partitions as sda1, sda2, sda3, have corresponding device driver files as /dev/sda1, /dev/sda2, /dev/sda3, Ex. fdisk /dev/sda mount /dev/sda2 25

File system A file system style is the way that data is organized to store in the storage device Linux supports many of fs styles ext2, ext3, ext4, reiser, // Linux vfat, fat32, ntfs // Windows iso9660, //cdrom File system term also refer to a partition has been formatted with a file system 26

File system Linux uses a Virtual File System (VFS) that creates a single hierarchy that encompasses all partitions on all storage devices in the system Hình: Hệ thống tập tin ảo 27

Mount Mount the partition into an existing directory in your file system, before can use it (read/write data). sda sda1 / sda2 home etc usr bin sda3 sda4 local bin Storage device Logic file system 28

Unmount Unmount the partition into a directory sda sda1 / sda2 home etc usr bin sda3 sda4 local bin hda1 Storage device logic file system Storage device 29

Unmount T1 : / ñược mount với sda1 $ ls /usr/local vd1.txt T2: /usr ñược mount với sda2 $ vi /usr/local/vd2.txt $ ls /usr/local??? T3: umount /usr với sda2 $ ls /usr/local??? 30

Using fdisk to create disk partitions Syntax : $ fdisk /dev/sdb =>press m to open menu Choose p to view partition table Choose n to make new partition Choose d to delete a partition Choose w to write table and exit, or q to exit without saving 31

Using fdisk to create disk partitions To make a new partition Choose making a primary partition or extended partition? Size of partition (MB or start and end cylinder) Have to create at least two partitions on a primary hard disk : swap partition and root partition a swap partition OS uses it as virtual memory it s size is at least twice as large as your installed RAM 32

Using fdisk to create disk partitions 33

Using fdisk to create disk partitions To view the partition table $ fdisk -l 34

Building a file system with mkfs mkfs Used to make an ext2 or ext3 (or FAT) file system on a partiton mkfs -t ext3 /dev/sda2 mkreiserfs Used to make a Reiser file system on a partition mkreiserfs /dev/sdc3 Other utilities : mkswap, mk2fs, mkfs.msdos, mkfs.vfat 35

Mounting a partition with mount mount command syntax: mount t type device target-dir type : ext2, ext3, reiserfs, device : /dev/hda1, /dev/hdb1, target-dir : /, /var, /home, /mnt/cdrom, 36

Mounting a partition with mount Using mount command / hda3, ext2 hda1,ext2 /var /home hda4,ext2 $ mount t ext2 /dev/hda3 / $ mount t ext2 /dev/hda4 /home $ mount t ext2 /dev/hda1 /var 37

Mounting a partition with mount After mounting the partition, you can use the mount command with no options to view all mounted file systems. Or using df utility $ mount $ df 38

Mounting a partition with mount Automatically mount when the system boot or reboot The /etc/fstab file contains a list of file systems that the operating system mounts whenever it boots. Each line specifies a separate file system to be mounted on boot partition mount_point fs_type options dump check 39

Mounting a partition with mount You can add a new mount partition entry in /etc/fstab that Linux will automatically mount at boot. - Using vi editor to open /etc/fstab, then add the new line 40

unmount Using umount command: two ways umount dir_name umount device_name - Have to unmount before unplug removable devices - Unmount to free the mount point - Automatically unmount when the OS shutdowns (halt) 41

ðĩa USB : /dev/sdb Có 2 partittion /dev/sdb1 /dev/sdb2 /mnt/usb1 /mnt/usb2 Cần rút ñĩa USB => thực hiện unmount umount /dev/sdb Hoặc: umount /mnt/usb1 umount /mnt/usb2 umount /dev/sdb1 umount /dev/sdb2 42

Checking the file system with fsck Using fsck to check your file systems for errors and make repairs fsck device $ fsck /dev/sdc1 43

Use Removable Media Floppies, optical devices, USB, FireWire devices Need to mount with a directory Need to unmount before remove 44

Working with floppy $ mount t vfat /dev/fd0 /media/floppy $ mount $ vi /etc/fstab /dev/fd0 /media/floppy auto noauto,user,sync 0 0 $ mount /dev/fd0 $ umount /dev/fd0 45

Working with optical devices (1) mount t iso9660 /dev/hdc /media/cdrom (2) Adding a line in /etc/fstab file : /dev/hdc /media/cdrom iso9660 noauto,user,sync 0 0 so, mount a cdrom by entering mount /dev/hdc (3) umount /dev/hdc 46

USB, FireWire devices Automatically detect a new device when connect an external storage device SCSI device Check /var/log/messages file after connecting the device Create on the device A partition A file system Mount device mount t auto /dev/sdd /media/thumbdrive umount the device before remove it 47

Using YaST YaST utility Install software, manage hardware settings, partition hard drives, configure bootloaders, configure network board, configure users and groups, settings for the services running on system Ex. : Using YaST to partition on usb disk 48

Back up data Selecting a Backup Medium Floppies, tape drive CDs, DVDs USB External hard drives 49

Back up data Selecting a Backup Strategy Selecting Backup type : Full Incremental Differential Selecting a backup schedule Determining what to back up 50

Back up data Linux Backup Utilites tar, cpio 51