exploring the unix file system and file security understanding files and directories

19
Exploring the UNIX Exploring the UNIX File System and File File System and File Security Security Understanding Files Understanding Files and Directories and Directories

Post on 19-Dec-2015

228 views

Category:

Documents


0 download

TRANSCRIPT

Exploring the UNIX File Exploring the UNIX File System and File SecuritySystem and File Security

Understanding Files and Understanding Files and DirectoriesDirectories

22

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

33

44

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

55

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– Like hda1 and hda2Like hda1 and hda2

66

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

77

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

88

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

99

1010

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

1111

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

1212

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

1313

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

1414

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

1515

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

1616

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

1717

Setting File PermissionsSetting File Permissions

1818

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

1919

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