Presentation on theme: "Introduction to Unix (CA263) File System"— Presentation transcript:
1 Introduction to Unix (CA263) File System ByTariq Ibn Aziz
2 ObjectivesAfter 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
3 Understanding UNIX/Linux File Systems File: basic component for data storageUNIX/Linux considers everything to be a fileA file system is UNIX/Linux’s way of organizing files on mass storage devicesA physical file system is a section of the hard disk that has been formatted to hold filesThe file system is organized in a hierarchical structure (inverted tree)
4 Understanding UNIX/Linux File Systems (continued)
5 UNIX File SystemMost 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 isexpandable,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 fixesby moving data automatically from damaged portions of disks to areas that are not damaged.
6 UNIX File SystemIn 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,
7 Understanding the Standard Tree Structure The structure starts at the root levelRoot 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 directoriesSubdirectory: directory within a directoryThe subdirectory is considered the child of the parent directory
8 Using UNIX/Linux Partitions The section of the disk that holds a file system is called a partitionWhen installing UNIX/Linux, one of the first tasks is deciding how to partition a storage device, or hard diskHard disks may have many partitionsUNIX/Linux partitions are given namesLINUX uses hda1 and hda2
9 Using UNIX/Linux Partitions (continued) Storage devices are called peripheral devicesPeripheral devices connect to the computer through electronic interfacesIDE: Integrated Drive ElectronicsSCSI: Small Computer System Interface
11 Setting Up Hard Disk Partitions Partitioning your hard disk provides organized space for file systemsAt least 3 partitions (root, swap, /boot) often recommendedRoot partition holds root file system directory (/), size depends on installation but often ranges between 1.2 to 5+ GB
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 smallOther often used partitions include /usr, /home, /var
13 Using InodesInodes are associated with directories and files in ufs and ext file systemsAn inode contains the name, general information, and location information (a pointer) for a file or directory
14 Using Inodes The file system itself is identified by the superblock A superblock contains information about block layout on a specific partitionWithout 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.
15 Exploring the Root Hierarchy UNIX/Linux must mount a file system before any programs can access files on itTo mount a file system is to connect it to the directory tree structureThe root file system is mounted by the kernel when the system starts
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.
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
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,
20 Using the mount Command Users can access mounted file systems which they have permission to accessAdditional file systems can be mounted at any time using the mount commandTo ensure system security, only the root user uses the mount command
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/cdromThis 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.
22 Using the unmount Command system administrator unmounts them using the umount command before removing the storage media,umount /mnt/floppyumount /mnt/cdrom
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 fileA forward slash (/) separates each directory nameThe UNIX/Linux command prompt may indicate your location within the file systemUse the UNIX/Linux pwd command to display the current path name
26 Configure Shell Prompt An environment variable, PS1, contains special formatting characters that determine your prompt’s configuration.variable contains: \W]\$Characters that begin with \ are special Bash shell formatting characters.
27 Navigating the File System To navigate the UNIX/Linux directory structure, use the cd (change directory) commandUNIX/Linux refers to a path as either:Absolute - begins at the root level and lists all subdirectories to the destination fileRelative - begins at your current working directory and proceeds from there
28 Using Dot and Dot Dot Addressing Techniques UNIX/Linux interpret a single dot (.) to mean the current working directoryTwo dots (..) mean the parent directorycd .. moves you up a level in the directory structure
29 Listing Directory Contents The ls (list) command displays a directory’s contents, including files and subdirectories
30 Using WildcardsA wildcard is a special character that is used as a placeholderThe * wildcard represents any group of characters in a file nameThe ? wildcard represents a single character in a file name
31 Creating and Removing Directories and Files mkdir (make directory) commandCreate a new directoryrmdir (make directory) commandDelete an empty directorycp (copy) commandCopy files from one directory to anotherrm (remove) commandDelete files
33 Configuring File Permissions for Security (continued) Owner has readwOwner has writexOwner has executeGroup has read-Group does not have writeGroup has executeOthers have readOthers do not have writeOthers have execute
34 Configuring File Permissions for Security (continued) chmod commandTo set file permissionsSettings are read (r), write (w), execute (x)The three types of users are owners, groups, and othersSetting permissions to directoriesUse the execute (x) to grant access
35 Chapter SummaryIn UNIX/Linux, a file is the basic component for data storage and UNIX and Linux consider everything a fileA file system is UNIX/Linux’s way of organizing files on mass storage devices and each file is referenced using a correct and unique pathnameThe section of the mass storage device that holds a file system is a partition
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 itemsThe ls command displays the names of files and directories contained in a directoryUse the chmod command to set permissions such as read (r), write (w), execute (x) for files that you own