Sei sulla pagina 1di 41

OVERVIEW OF FILESYSTEM MANAGEMENT IN LINUX

Lecturer: Click V Minh Sn to edit Master subtitle MS.

style Students:

Nguyn c Tin 0620076 Nguyn Xun Thun 0620069

CONTENTS
1 2 3 4 5 6
22

Exploring the Linux filesystem Examining Files File permissions File processing Demo Q&A
filesystem management in in Linux Filesystem management Linux

1.1 Exploring the Linux filesystem


1.1 Overview 1.2 Filesystem hierarchy 1.3 Type of information 1.4 Linux device files 1.5 Mounting and unmounting a device on the
33

filesystem

filesystem management in in Linux Filesystem management Linux

1.1 Overview
l

Physical storage device: HDD, DVDROM sector, track, cylinder

HDDs can be divided into separate storage devices called partitions

A filesystem is the methods and data structures that an operating system uses to keep track of files on a disk or partition (the way the files are organized on the disk)

44

ext3 (third extended filesystem)


filesystem management in in Linux Filesystem management Linux

1.1 Overview (cont)

55

filesystem management in in Linux Filesystem management Linux

1.1 Overview (cont)


l

File properties (Administrative l Name l Data created/ information)


l l l l

Location Size Owner/Group Type

l l l

accessed/modified Permissions Desktop Command line

files inode l File manager (Windows Explorer)


66

KDE Konqueror GNOME Nautilus


Filesystem management Linux Filesystemmanagement inin Linux

1.2 Filesystem hierarchy

77

filesystem management in in Linux Filesystem management Linux

1.1 Understanding the filesystem hierarchy (cont)

88

filesystem management in in Linux Filesystem management Linux

1.2 Filesystem hierarchy (cont)


l

path (pathname) absolute name vs relative name

/home/nguyenxuanthuan/programs /home/guest/programs current directory directory immediately above the current directory

shorcut

. ..
99

Filesystem management Linux Filesystemmanagement inin Linux

1.3 Type of information


Data files

Application-specific files
o o

Type of information

Configuration files Directory files Link files

Text files

Program Applications Image files

Device files
1010 Filesystem management Linux Filesystemmanagement inin Linux

1.4 Linux device files

1111

filesystem management in in Linux Filesystem management Linux

1.4 Linux device files (cont)


l

Linux treats all devices as files and uses a device just as it uses a file
Open file Close file Write file Read file

Device Driver: a special program that controls a particular type of hardware l Any application can access a device by opening the file specific to that device
Filesystem management Linux Filesystemmanagement inin Linux

1212

1.4 Linux device files (cont)


l

Device file: the file which applications use to access a device

These special appear in the /dev directory in the Linux filesystem block devices b character devices c network devices ethx/pppx (x = 0, 1, ...)

1313

Filesystem management Linux Filesystemmanagement inin Linux

1.5 Mounting and unmounting a device on the filesystem


l

Each of storage device has own filesystem when you want to add a new storage device, you need to
format it as a filesystem and then attach it to your Linux file structure

1414

Mounting is the operation you perform to cause the filesystem on a physical storage device to appear as part of the Linux filesystem Mounting point is a specified directory that contains the mount command to mount a device on the Linux filesystem
Filesystem management Linux Filesystemmanagement inin Linux

1515

Mounting a device on the filesystem management in in Linux Filesystem management Linux filesystem

How to name a storage in Linux


hd IDE hard drive 1 4 are primary partitions 5 and up are logical partitions SCSI hard drives Floppy disks Printer ports Links to your CD-ROM device file

sd fd lp cdrom
l

Example fd0: the first floppy drive attached to your system sda2: the second partition on the first SCSI hard drive
Filesystem management Linux Filesystemmanagement inin Linux

1616

2. Examining Files
File information GUI: right-click the file icon and select properties. Command line: ls options: -l, -a operators: >,>> pwd

Filesystem management Linux Filesystemmanagement inin Linux

1818

Filesystem management Linux Filesystemmanagement inin Linux

3. File Permissions
l

Three types of user accounts

Do one or more of three things to the file

Owner The account that owns the file Group Members of a group that owns the file All users All accounts on the system Read (r) Write (w) Execute (x)

Look at the contents of the file Save the file to the hard disk Run the file or enter the directory Example: drwxr-xr-Filesystem management Linux Filesystemmanagement inin Linux

3. File Permissions (cont)


Format: chmod who action permission filename

Example: chmod u+x nguyen.txt


Filesystem management Linux Filesystemmanagement inin Linux

4. File processing
4.1 Finding file 4.2 Creating Directories, Files, and Links 4.3 Copying, Renaming, and Moving Files 4.4 Viewing and Editing Text Files 4.5 Deleting Files and Directories 4.6 Backup and restoring files

Filesystem management Linux Filesystemmanagement inin Linux

4.1 Finding file


l

Use: find command to find files by filename or properties and grep command to find files by content

Filesystem management Linux Filesystemmanagement inin Linux

4.1.1 Find command


find pathname conditions

Filesystem management Linux Filesystemmanagement inin Linux

4.1.2 Grep command


grep options pattern files

Filesystem management Linux Filesystemmanagement inin Linux

4.2 Creating Directories, Files, and Links


v

To create a directory in any directory where you have write permission, use the mkdir command: mkdir path/dirname If path includes directories don't yet exist, you can create them in one command with the -p option: mkdir -p /usr/local/newparent/mydir
Filesystem management Linux Filesystemmanagement inin Linux

4.2 Creating Directories, Files, and Links (cont)


l

Files can be created by applications, such as a word processor, and cat command. Links can be created at the command line using the ln command

Filesystem management Linux Filesystemmanagement inin Linux

4.3 Copying, Renaming, and Moving Files


v To copy or move a file, type: + cp path/sourcename path/targetname (copies a file) + cp -r path/sourcename path/targetname (copies a directory) + mv path/sourcename path/targetname (moves a file or directory) v Your account needs to have write permissions
Filesystem management Linux Filesystemmanagement inin Linux

4.4 Viewing and Editing Text Files


l l

Applications: Kate, Kwrite, Command lines: cat filename: The entire file contents display on the screen at once less filename: display the contents one screen at a time vi filename: edit file

Filesystem management Linux Filesystemmanagement inin Linux

Vi options

Filesystem management Linux Filesystemmanagement inin Linux

Vi options (cont)

Filesystem management Linux Filesystemmanagement inin Linux

Vi options (cont)

Filesystem management Linux Filesystemmanagement inin Linux

Vi options (cont)

ZZ: save file :q!: close without saving file


Filesystem management Linux Filesystemmanagement inin Linux

4.5 Deleting Files and Directories


l l l l l

rm filename: delete a file rm *: delete all file in current directory rmdir dirname: remove a empty directory rm -r dirname: remove a directory Must have write permissions on the directory containing the files

Filesystem management Linux Filesystemmanagement inin Linux

4.6 Backup and Restoring files


+which files needing to back Back up strategy up Back up media +how often l +what back upcommand to tap archiver storage (tar) usel Format: tar options tarfile filelist
l

3434

Filesystem management Linux Filesystemmanagement inin Linux

Tar options

Filesystem management Linux Filesystemmanagement inin Linux

Tar options (cont)

Filesystem management Linux Filesystemmanagement inin Linux

Tar options (cont)

Filesystem management Linux Filesystemmanagement inin Linux

Tar options (cont)

Filesystem management Linux Filesystemmanagement inin Linux

5. DEMO
l l l

VMWare Workstation

Version 6.0.0 build-45731 Distribution Tinycore

Linux OS Demo

3939

Filesystem management Linux Filesystemmanagement inin Linux

Reference
1. 2. 3. 4. 5.
4040

Spring into Linux (AW), 2005 Linux All-In-One Desk Reference For Dummies 2e (Wiley, 2006) Beginning Linux Programming 4e (Wrox, 2007) Linux: The Complete Reference, Sixth Edition www.tinycore.com
Filesystem management Linux Filesystemmanagement inin Linux

6. Q&A

Thank You !

4141

Filesystem management Linux Filesystemmanagement inin Linux

Potrebbero piacerti anche