introduction to unix (ca263) file system by tariq ibn aziz
Post on 19-Dec-2015
230 views
TRANSCRIPT
![Page 1: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/1.jpg)
Introduction to Unix (CA263)
File System
By
Tariq Ibn Aziz
![Page 2: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/2.jpg)
2
Objectives
• After reading this chapter and completing the exercises, you will be able to:Discuss UNIX/Linux file systemsExplain partitions and inodesUnderstand the elements of the root hierarchyUse the mount commandExplain and use paths, pathnames, and promptsNavigate the file systemCreate and remove directoriesCopy and delete filesConfigure file permissions
![Page 3: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/3.jpg)
3
Understanding UNIX/LinuxFile Systems
• File: basic component for data storage
– UNIX/Linux considers everything to be a file
• A file system is UNIX/Linux’s way of organizing files on mass storage devices
– A physical file system is a section of the hard disk that has been formatted to hold files
• The file system is organized in a hierarchical structure (inverted tree)
![Page 4: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/4.jpg)
4
Understanding UNIX/LinuxFile Systems (continued)
![Page 5: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/5.jpg)
5
UNIX File System
• Most versions of UNIX and Linux support the UNIX file system (ufs), which is the original native UNIX file system.
• ufs is a hierarchical (tree structure) file system that is– expandable, – supports large amounts of storage, – provides excellent security, and is reliable.
• ufs supports journaling, – if a system crashes unexpectedly, it reconstruct files or to roll
back recent changes for minimal or no damage of the files.
• ufs also supports hot fixes – by moving data automatically from damaged portions of disks to
areas that are not damaged.
![Page 6: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/6.jpg)
6
UNIX File System
• In Linux, the native file system is called the extended file system (ext or ext fs), which is installed by default.
• ext is modeled after ufs,
![Page 7: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/7.jpg)
7
Understanding the Standard Tree Structure
• The structure starts at the root level– Root is the name of the file at this basic level and it is
denoted by the slash character (/)• Directory: file that can contain other files and directories• Subdirectory: directory within a directory
– The subdirectory is considered the child of the parent directory
![Page 8: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/8.jpg)
8
Using UNIX/Linux Partitions
• The section of the disk that holds a file system is called a partition– When installing UNIX/Linux, one of the first tasks
is deciding how to partition a storage device, or hard disk
– Hard disks may have many partitions• UNIX/Linux partitions are given names
– LINUX uses hda1 and hda2
![Page 9: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/9.jpg)
9
Using UNIX/Linux Partitions (continued)
• Storage devices are called peripheral devices
• Peripheral devices connect to the computer through electronic interfaces
– IDE: Integrated Drive Electronics
– SCSI: Small Computer System Interface
![Page 10: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/10.jpg)
10
![Page 11: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/11.jpg)
11
Setting Up Hard Disk Partitions
• Partitioning your hard disk provides organized space for file systems
• At least 3 partitions (root, swap, /boot) often recommended
• Root partition holds root file system directory (/), size depends on installation but often ranges between 1.2 to 5+ GB
![Page 12: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/12.jpg)
12
Setting Up Hard Disk Partitions (continued)
• Swap partition acts as a memory extension, often has same size as RAM, enables virtual memory
• /boot partition used to store OS files comprising kernel, relatively small
• Other often used partitions include /usr, /home, /var
![Page 13: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/13.jpg)
13
Using Inodes
• Inodes are associated with directories and files in ufs and ext file systems
• An inode contains the name, general information, and location information (a pointer) for a file or directory
![Page 14: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/14.jpg)
14
Using Inodes
• The file system itself is identified by the superblock– A superblock contains information about block layout
on a specific partition– Without the superblock, the file system cannot be
accessed.– For this reason, many copies of the superblock are
written into the file system at the time the file system is created through partitioning and formatting.
– If the superblock is destroyed, you can copy one of the superblock copies over the original, damaged superblock to restore access to the file system.
![Page 15: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/15.jpg)
15
Exploring the Root Hierarchy
• UNIX/Linux must mount a file system before any programs can access files on it
• To mount a file system is to connect it to the directory tree structure
• The root file system is mounted by the kernel when
the system starts
![Page 16: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/16.jpg)
16
Exploring the Root Hierarchy (continued)
• The root directory contains sub-directories that contain files:– /bin contains binaries, or executables needed to start
the system and perform system tasks– /boot contains files needed by the bootstrap loader as
well as kernel images– /dev contains system device reference files, such as
the hard disks, mice, printers, consoles, modems, memory, floppy disks, and CD-ROM drives.
![Page 17: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/17.jpg)
17
![Page 18: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/18.jpg)
18
Exploring the Root File Hierarchy (continued)
• Root subdirectories continued:– /etc contains configuration files that the system uses
when the computer starts
– /home is used to offer disk space for users– /lib contains kernel modules, security information, and
the shared library images
– /mnt contains mount points for temporary mounts by the system administrator. A temporary mount is used to mount a removable storage medium, such as a floppy disk or CD/DVD
– /proc is a virtual file system allocated in memory only
![Page 19: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/19.jpg)
19
Exploring the Root File Hierarchy (continued)
• Root subdirectories continued:– /root is the home directory of the root user, or the
system administrator– /sbin contains essential network programs used only
by the system administrator – /tmp is a temporary place to store data during
processing cycles, for example sorting– /usr partition houses software offered to users– /var contains subdirectories which have sizes that
often change, such as error logs. For incoming mail and printing spooling we have /var/spool/mail subdirectory or /var/spool/lpd subdirectory,
![Page 20: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/20.jpg)
20
Using the mount Command
• Users can access mounted file systems which they have permission to access
• Additional file systems can be mounted at any time using the mount command
• To ensure system security, only the root user uses
the mount command
![Page 21: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/21.jpg)
21
Using the mount Command
• Suppose you want to access files on a CD-ROM for your organization.You or the system administrator can mount a CD-ROM by inserting a disk in the CD-ROM drive, and thenusing the following mount command:
– mount -t iso9660 /dev/cdrom /mnt/cdrom• This command mounts the CD on a device called
“cdrom” located in the /dev directory. The actual mount point in UNIX/Linux is /mnt/cdrom, a directory that references the CD-ROM device. After the CD is mounted, you can access its files through the /mnt/ cdrom directory.
![Page 22: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/22.jpg)
22
Using the unmount Command
• system administrator unmounts them using the umount command before removing the storage media,– umount /mnt/floppy– umount /mnt/cdrom
![Page 23: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/23.jpg)
23
Using Paths, Pathnames, and Prompts
• To specify a file or directory, use its pathname, which follows the branches of the file system to the desired file– A forward slash (/) separates each directory
name– The UNIX/Linux command prompt may indicate
your location within the file system– Use the UNIX/Linux pwd command to display the
current path name
![Page 24: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/24.jpg)
24
Configure Shell Prompt
![Page 25: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/25.jpg)
25
Configure Shell Prompt
![Page 26: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/26.jpg)
26
Configure Shell Prompt
• An environment variable, PS1, contains special formatting characters that determine your prompt’s configuration.
• variable contains: [\u@\h \W]\$– Characters that begin with \ are special Bash
shell formatting characters.
![Page 27: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/27.jpg)
27
Navigating the File System
• To navigate the UNIX/Linux directory structure, use the cd (change directory) command
• UNIX/Linux refers to a path as either:
– Absolute - begins at the root level and lists all subdirectories to the destination file
– Relative - begins at your current working directory and proceeds from there
![Page 28: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/28.jpg)
28
Using Dot and Dot Dot Addressing Techniques
• UNIX/Linux interpret a single dot (.) to mean the current working directory
• Two dots (..) mean the parent directory• cd .. moves you up a level in the directory structure
![Page 29: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/29.jpg)
29
Listing Directory Contents
The ls (list) command displays a directory’s contents, including files and subdirectories
![Page 30: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/30.jpg)
30
Using Wildcards
• A wildcard is a special character that is used as a placeholder
• The * wildcard represents any group of characters in a file name
• The ? wildcard represents a single character in a file name
![Page 31: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/31.jpg)
31
Creating and Removing Directories and Files
• mkdir (make directory) command
– Create a new directory
• rmdir (make directory) command
– Delete an empty directory
• cp (copy) command
– Copy files from one directory to another
• rm (remove) command
– Delete files
![Page 32: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/32.jpg)
32
Configuring File Permissions for Security
![Page 33: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/33.jpg)
33
Configuring File Permissions for Security (continued)
File Permissionsr Owner has read
w Owner has write
x Owner has execute
r Group has read
- Group does not have write
x Group has execute
r Others have read
- Others do not have write
x Others have execute
![Page 34: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/34.jpg)
34
Configuring File Permissions for Security (continued)
• chmod command– To set file permissions– Settings are read (r), write (w), execute (x)– The three types of users are owners, groups, and
others• Setting permissions to directories
– Use the execute (x) to grant access
![Page 35: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/35.jpg)
35
Chapter Summary
• In UNIX/Linux, a file is the basic component for data storage and UNIX and Linux consider everything a file
• A file system is UNIX/Linux’s way of organizing files on mass storage devices and each file is referenced using a correct and unique pathname
• The section of the mass storage device that holds a file system is a partition
![Page 36: Introduction to Unix (CA263) File System By Tariq Ibn Aziz](https://reader036.vdocuments.mx/reader036/viewer/2022062313/56649d375503460f94a102ea/html5/thumbnails/36.jpg)
36
Chapter Summary (continued)
• You can customize your command prompt to display the current working directory name, the current date and time, and several other items
• The ls command displays the names of files and directories contained in a directory
• Use the chmod command to set permissions such as read (r), write (w), execute (x) for files that you own