Chapter Two Exploring the UNIX File System and File Security.
-
Upload
benjamin-harper -
Category
Documents
-
view
218 -
download
1
Transcript of Chapter Two Exploring the UNIX File System and File Security.
Chapter TwoChapter Two
Exploring the UNIX File Exploring the UNIX File System and File SecuritySystem and File Security
22
Lesson ALesson A
Understanding Files and DirectoriesUnderstanding Files and Directories
33
ObjectivesObjectives
Discuss and explain the UNIX file systemDiscuss and explain the UNIX file system
Define a UNIX file system partitionDefine a UNIX file system partition
Use the mount command to mount a file Use the mount command to mount a file systemsystem
44
Objectives (cont.)Objectives (cont.)
Discuss relative and absolute path Discuss relative and absolute path addressingaddressing
Diagram the UNIX file system hierarchy Diagram the UNIX file system hierarchy
Navigate the file systemNavigate the file system
55
Understanding the UNIXUnderstanding the UNIXFile SystemFile System
A file is the basic component for data storageA file is the basic component for data storage– UNIX considers everything it interacts with a fileUNIX considers everything it interacts with a file
A file system is UNIX’s way of organizing files on A file system is UNIX’s way of organizing files on mass storage (disk) devicesmass storage (disk) devices– A physical file system is a section of the hard disk that A physical file system is a section of the hard disk that
has been formatted to hold fileshas been formatted to hold files
The file system is organized in a hierarchical The file system is organized in a hierarchical structure similar to an inverted treestructure similar to an inverted tree
66
77
Understanding the Standard Understanding the Standard Tree StructureTree Structure
The structure starts at the root levelThe structure starts at the root level– Root is the name of the file at this basic level and it is Root is the name of the file at this basic level and it is
denoted by the slash character (/)denoted by the slash character (/)
A directory is a file that can contain other files A directory is a file that can contain other files and directoriesand directories
A subdirectory is a directory within a directoryA subdirectory is a directory within a directory– The subdirectory is considered the child of the parent The subdirectory is considered the child of the parent
directorydirectory
88
Using UNIX PartitionsUsing UNIX Partitions
The section of the disk that holds a file The section of the disk that holds a file system is called a partitionsystem is called a partition– When installing UNIX, one of the first tasks is deciding When installing UNIX, one of the first tasks is deciding
how to partition a storage device, or hard diskhow to partition a storage device, or hard disk– Hard disks may have many partitionsHard disks may have many partitions
UNIX partitions are given namesUNIX partitions are given names– LINUX uses hda1 and hda2LINUX uses hda1 and hda2
99
Using UNIX PartitionsUsing UNIX Partitions
Storage devices are called peripheral Storage devices are called peripheral devicesdevices
Peripheral devices connect to the Peripheral devices connect to the computer through electronic interfacescomputer through electronic interfaces– IDE - Integrated Drive ElectronicsIDE - Integrated Drive Electronics– SCSI - Small Computer System InterfaceSCSI - Small Computer System Interface
1010
1111
Exploring the Root File System Exploring the Root File System
UNIX must mount a file system before any UNIX must mount a file system before any programs can access files on itprograms can access files on it
To mount a file system is to connect it to To mount a file system is to connect it to the directory tree structurethe directory tree structure
The root file system is mounted by the The root file system is mounted by the kernel when the system startskernel when the system starts
1212
Exploring the Root File Exploring the Root File System System
The root directory contains sub-directories The root directory contains sub-directories that contain files:that contain files:– /bin/bin contains binaries, or executables needed contains binaries, or executables needed
to start the system and perform system tasksto start the system and perform system tasks– /boot/boot contains files needed by the bootstrap contains files needed by the bootstrap
loader as well as kernel imagesloader as well as kernel images– /dev/dev contains system device reference files contains system device reference files
1313
1414
Exploring the Root File Exploring the Root File System System
Root subdirectories continued:Root subdirectories continued:– /etc/etc contains configuration files that the contains configuration files that the
system uses when the computer startssystem uses when the computer starts– /lib/lib contains kernel modules, security contains kernel modules, security
information, and the shared library imagesinformation, and the shared library images– /mnt/mnt contains mount points for temporary contains mount points for temporary
mounts by the system administratormounts by the system administrator– /proc/proc is a virtual file system allocated in is a virtual file system allocated in
memory onlymemory only
1515
Exploring the Root File Exploring the Root File System System
Root subdirectories continued:Root subdirectories continued:– /root/root is the home directory of the root user, or is the home directory of the root user, or
the system administratorthe system administrator– /sbin/sbin contains essential network programs contains essential network programs
used only by the system administrator used only by the system administrator – /tmp/tmp is a temporary place to store data during is a temporary place to store data during
processing cyclesprocessing cycles– /var/var contains subdirectories which have sizes contains subdirectories which have sizes
that often change, such as error logsthat often change, such as error logs
1616
Using the Mount Using the Mount CommandCommand
Users can access mounted file systems Users can access mounted file systems which they have permission to accesswhich they have permission to access
Additional file systems can be mounted at Additional file systems can be mounted at any time using the mount commandany time using the mount command
To ensure system security, only the root To ensure system security, only the root user uses the mount commanduser uses the mount command
1717
Understanding PathsUnderstanding Pathsand Pathnamesand Pathnames
To specify a file or directory, use its To specify a file or directory, use its pathname, which follows the branches of pathname, which follows the branches of the file system to the desired filethe file system to the desired file– A forward slash (/) separates each directory A forward slash (/) separates each directory
namename– The UNIX command prompt may indicate The UNIX command prompt may indicate
your location within the file systemyour location within the file system– Use the UNIX pwd command to display the Use the UNIX pwd command to display the
current path namecurrent path name
1818
1919
Navigating the File System Navigating the File System
To navigate the UNIX directory structure, To navigate the UNIX directory structure, use the cd (change directory) commanduse the cd (change directory) command
UNIX refers to a path as either:UNIX refers to a path as either:– Absolute - begins at the root level and lists all Absolute - begins at the root level and lists all
subdirectories to the destination filesubdirectories to the destination file– Relative - begins at your current working Relative - begins at your current working
directory and proceeds from there directory and proceeds from there
2020
Listing Directory ContentsListing Directory Contents
The ls (list) The ls (list) command displays command displays a directory’s a directory’s contents, including contents, including files and files and subdirectoriessubdirectories
2121
Listing Directory ContentsListing Directory Contents
The system The system normally uses normally uses hidden files to keep hidden files to keep configuration configuration information and for information and for other purposesother purposes
2222
Lesson BLesson B
Working with Files, Directories, and Working with Files, Directories, and Security Security
2323
ObjectivesObjectives
Create new directories to store filesCreate new directories to store files
Copy files from one directory to Copy files from one directory to anotheranother
Set file permissions for other user Set file permissions for other user access to directory and filesaccess to directory and files
2424
Managing Directories and Managing Directories and FilesFiles
mkdir (make directory) commandmkdir (make directory) command– Create a new directoryCreate a new directory
rmdir (make directory) commandrmdir (make directory) command– Delete an empty directoryDelete an empty directory
cp (copy) commandcp (copy) command– Copy files from one director to anotherCopy files from one director to another
rm (remove) commandrm (remove) command– Delete filesDelete files
2525
Setting File PermissionsSetting File Permissions
2626
Setting File PermissionsSetting File Permissions
File PermissionsFile Permissions
rr Owner has readOwner has read
ww Owner has writeOwner has write
xx Owner has executeOwner has execute
rr Group has readGroup has read
-- Group does not have writeGroup does not have write
xx Group has executeGroup has execute
rr Others have readOthers have read
-- Others do not have writeOthers do not have write
xx Others have executeOthers have execute
2727
Setting File PermissionsSetting File Permissionsfor Securityfor Security
chmod commandchmod command– To set file permissionsTo set file permissions– Settings are read (r), write (w), execute (x)Settings are read (r), write (w), execute (x)– The three types of users are owners, groups, The three types of users are owners, groups,
and othersand others
Setting permissions to directoriesSetting permissions to directories– Use the execute (x) to grant accessUse the execute (x) to grant access
2828
Chapter SummaryChapter SummaryIn UNIX, a file is the basic component for data In UNIX, a file is the basic component for data storage and UNIX considers everything a filestorage and UNIX considers everything a file
A file system is the UNIX system’s way of A file system is the UNIX system’s way of organizing files on mass storage devices and organizing files on mass storage devices and each file is referenced using a correct and each file is referenced using a correct and unique pathnameunique pathname
The standard tree structure starts with the root The standard tree structure starts with the root (/) directory(/) directory
The section of the mass storage device (or The section of the mass storage device (or disk) that holds a file system is a partitiondisk) that holds a file system is a partition
2929
Chapter SummaryChapter SummaryA path serves as as a map to access any file A path serves as as a map to access any file on the systemon the system
You may customize your command prompt to You may customize your command prompt to display the current working directory name, the display the current working directory name, the current date and time, and several other itemscurrent date and time, and several other items
The ls command displays the names of files The ls command displays the names of files and directories contained in a directoryand directories contained in a directory
Wildcard characters (i.e. *, ?) can be used in a Wildcard characters (i.e. *, ?) can be used in a command such as ls and take the place of command such as ls and take the place of other characters in a file nameother characters in a file name
3030
Chapter SummaryChapter Summary
Use the mkdir command to create a new Use the mkdir command to create a new directory, as long as you own the parentdirectory, as long as you own the parent
Use the chmod command to set Use the chmod command to set permissions such as read (r), write (w), permissions such as read (r), write (w), execute (x) for files that you ownexecute (x) for files that you own
Use the cp command to copy a source Use the cp command to copy a source file to a destination file and directoryfile to a destination file and directory
3131
3232