1.1 Overview1.2 Filesystem hierarchy 1.3 Type of information 1.4 Linux device files 1.5 Mounting and unmounting a device on thefilesystem 3... Physical storage device: HDD, DVD-ROM se
Trang 1MS Võ Minh Sơn
Students:
Nguyễn Đức Tiến 0620076 Nguyễn Xuân Thuận 0620069
Trang 31.1 Overview
1.2 Filesystem hierarchy
1.3 Type of information
1.4 Linux device files
1.5 Mounting and unmounting a device on thefilesystem
3
Trang 4 Physical storage device: HDD, DVD-ROM
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)
• ext3 (third extended filesystem)
Trang 6 File properties (Administrative information)
File manager KDE Konqueror
(Windows Explorer) GNOME Nautilus
Trang 77
Trang 10Data files
Link filesDirectory filesConfiguration files
Device files
Type of information
Application-specific files
o Program Applications
o Image files
Text files
Trang 1111
Trang 12 Linux treats all devices as files and uses a device just as it uses a file
Open file Write file
Read file
Close file
Device Driver: a special program that
controls a particular type of hardware
Any application can access a device by opening the file specific to that device
Trang 13 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, )
13
Trang 14 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
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
Trang 15Mounting a device on the filesystem
Trang 16 Example
• fd 0: the first floppy drive attached to your system
• sd a 2: the second partition on the first SCSI hard drive
hd IDE hard drive
1 – 4 are primary partitions
5 and up are logical partitions
sd SCSI hard drives
fd Floppy disks
lp Printer ports
cdrom Links to your CD-ROM device file
Trang 193 File Permissions
Three types of user accounts
• Owner The account that owns the file
• Group Members of a group that owns the file
• All users All accounts on the system
Do one or more of three things to the file
• Read (r) Look at the contents of the file
• Write (w) Save the file to the hard disk
• Execute (x) Run the file or enter the directory
Example: drwxr-x
Trang 20r 3 File Permissions (cont)
Format:
chmod who action permission filename
Example: chmod u+x nguyen.txt
Trang 214 File processing
4.1 Finding file
4.2 Creating Directories, Files, and Links4.3 Copying, Renaming, and Moving Files4.4 Viewing and Editing Text Files
4.5 Deleting Files and Directories
4.6 Backup and restoring files
Trang 234.1.1 Find command
find pathname conditions
Trang 244.1.2 Grep command
grep options pattern files
Trang 254.2 Creating Directories, Files, and Links
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
Trang 264.2 Creating Directories, Files, and Links (cont)
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
Trang 274.3 Copying, Renaming, and Moving Files
To copy or move a file, type:
(moves a file or directory)
Your account needs to have write permissions
Trang 284.4 Viewing and Editing Text Files
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
Trang 29Vi options
Trang 30Vi options (cont)
Trang 32ZZ: save file
:q!: close without saving file
Vi options (cont)
Trang 334.5 Deleting Files and Directories
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
Trang 34 +which files needing to back up
+how often
+what back up storage to use
Back up strategyBack up media
tap archiver command (tar)
Format: tar options tarfile filelist
Trang 35Tar options
Trang 36Tar options (cont)
Trang 401. Spring into Linux (AW), 2005
2. Linux All-In-One Desk Reference For