Download presentation
Presentation is loading. Please wait.
Published byImogen Imogene Quinn Modified over 9 years ago
1
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers the ability to locate files on a Linux system regardless of the distribution This allows them to create software that is not distribution specific Chapter 9 Part IV Linux Advanced Command Line
2
The Filesystem Hierarchy Standard (FHS) Table 5-1: Linux directories defined by FHS
3
The Filesystem Hierarchy Standard (FHS) Table 5-1 (continued): Linux directories defined by FHS
4
Linking Files Files may be linked to another in one of two ways: –One file may simply be a pointer or a shortcut to another file (known as a symbolic link or symlink) –The two files may share the same data (known as a hard link )
5
Linking Files To better understand how files are linked, you must understand how files are stored on a filesystem Structurally, a filesystem has three main sections: –Superblock: section of info: # of inodes & data blocks –inode table: each inode describes 1 file or directory and contains a unique inode number for identification Other info: file size, data block locations, last date modified, permissions, & ownership Since directories are files they have an unique inode also –Data blocks: filename & file contents (data) Also called allocation units Directories data blocks contain a list of files located within it
6
Hard Link Files are direct copies of one another, as they share the same inode & inode number. The structure of hard linked files
7
Linking Files ln (link) command –Command used to create hard and symbolic links To create hard link, you must use the ln command and specify two arguments: –The existing file to hard-link –The target file that will be created as a hard link to the existing file Try This: create file1 with touch or one of the editors $ ls -li(check parameters. i displays inode) $ ln file1 file2(file2 is direct copy) $ ls –li(have parameters changed?, what about the inode numbers)
8
Linking Files Figure 5-2: The structure of symbolically linked files Symbolic links are sometimes called soft links. Symbolic links do not share the same inode, they are merely a pointer to the other, thus will have different sizes. Create file3 $ ln –s file3 file4 (-s symbolic option) $ ls –li (what’s different, what’s the same?) $ ls –F (what’s different, what’s the same?)
9
Listing the Contents of a Folder The ls command is used to list the contents of a folder and information about files, by default the current directory. # ls –al total 109 drwxr-xr-x 18 root root 4096 Jun 9 21:12./ drwxr-xr-x 18 root root 4096 Jun 9 21:12../ drwxr-xr-x 2 root root 4096 Jun 9 21:14 bin/ drwxr-xr-x 3 root root 1024 Jun 9 20:32 boot/ File type, permissions, hard link count, file owner, group owner, size, mod date, directory name, filename or pointer.
10
File and Directory Permissions Recall that all users must successfully login with a username and password to gain access to a Linux system Once logged in, users are identified by their username and group memberships –All access to resources depends on whether their username and group membership have the required permission When a user creates a file or directory, that user’s name and primary group become the owner and group owner of the file, respectively Primary group –Default group to which a user belongs
11
File and Directory Ownership chown (change owner) command –Command used to change the owner and the group of a file or directory –Takes two arguments at a minimum: The new owner and the files or directories to change $ chown userx file1 chgrp (change group) command –Command to change the group owner of a file or directory –Takes two arguments at a minimum: The new group owner and the files or directories to change $ chgrp sys file1 Changing both with chown $ chown userx.sys file1
12
Managing File and Directory Permissions Mode –The section of the inode that stores permissions –Divided into three sections based on the user(s) that receive(s) the permission to that file or directory User (owner) permissions Group (group owner) permissions Other (everyone on the Linux system permissions
13
Managing File and Directory Permissions There are three regular permissions that you may assign to each of the user(s) referenced on the previous slide: –Read –Write –Execute –And – permission is unavailable
14
Interpreting the Mode Figure 5-3: The structure of a mode
15
Interpreting the Mode User or Owner –When used in the mode of a certain file or directory, it refers to the owner of that file or directory User –User whose name appears in a long listing of a file or directory and who has the ability to change permissions on that file or directory Group –Typically users in the same company department Other –When used in the mode of a certain file or directory, it refers to all users on the Linux system
16
Interpreting Permissions Table 5-4: Linux permissions
17
Changing Permissions chmod (change mode) command –Used to change the mode (permissions) of a file or dir –Takes two arguments at a minimum: The first argument specifies the criteria used to change permissions The remaining arguments indicate filenames to change -rw-r--r-- $ chmod u=rwx,g=rw,o=rw-rwxrw-rw- $ chmod u+x,g+w,o+w-rwxrw-rw- $ chmod 766 file1-rwxrw-rw-
18
Changing Permissions Figure 5-4: Numeric representation of the mode
19
Default Permissions Umask –Used to alter the permissions on all new files and directories by taking select default file and directory permissions away –Only applies to newly created files and directories Will never be used to modify the permissions of existing files and directories
20
Default Permissions Figure 5-5: Performing a umask 007 calculation
21
Special Permissions Read, write, and execute are the regular file permissions used to assign security to files Three more special permissions that you may optionally use on file and directories: –SUID (Set User ID) –SGID (Set Group ID) –Sticky bit
22
Defining Special Permissions The SUID has no special function when set on a directory –However, if the SUID is set on a file and that file is executed, then the person who executed the file temporarily becomes the owner of the file while it is executing The SUID can only be applied to binary compiled programs
23
Defining Special Permissions The SGID has a function when applied to both files and directories The SGID allows regular users to execute a binary compiled program and become a member of the group that is attached to the file during execution of the program The sticky bit was used on files in the past to lock them in memory –Today, the sticky bit performs a useful function only on directories
24
Setting Special Permissions The mode of a file that is displayed using the ls –l command does not have a section for special permissions Special permissions require execute –They mask the execute permission when displayed using the ls –l command
25
Setting Special Permissions Figure 5-7: Representing special permissions in the mode
26
Setting Special Permissions Figure 5-8: Representing special permissions in the absence of the execute permissions
27
Setting Special Permissions Figure 5-9: Numeric representation of regular and special permissions
28
The grep Command grep –Stands for Global Regular Expression Print –Used to display lines in a text file that match a certain common regular expression –Search is case sensitive unless –i used –-v reverse meaning of previous command $ grep “ CIS 130” file5 Use the egrep command to display lines of text that match extended regular expressions The fgrep command does interpret any regular expressions and consequently returns results much faster than the egrep command
29
Viewing Processes There are several Linux utilities that can view processes ps command –The most versatile and common Linux utility that can view processes –Without arguments, the ps command simply displays a list of processes that are running in the current shell
30
Viewing Processes top command –Most common command used to display processes aside from ps –Displays its interactive screen listing processes organized by processor time Processes that use the most processor time are listed at the top of the screen
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.