chapter 4: understanding users and file systems
TRANSCRIPT
-
8/14/2019 Chapter 4: Understanding Users and File Systems
1/46
Chapter 4:
Understanding Users and FileSystems
The Complete Guide to Linux System
Administration
-
8/14/2019 Chapter 4: Understanding Users and File Systems
2/46
The Complete Guide to Linux System Administration 2
Objectives
Create and manage user and group accounts
View and set access permissions on files and
directories Understand how file systems are configured and
accessed
Perform basic file compression and archiving
tasks
-
8/14/2019 Chapter 4: Understanding Users and File Systems
3/46
The Complete Guide to Linux System Administration 3
Linux Users and Groups
Must first log in using valid user account name
and password
More user accounts on Linux system More work required to keep them running
smoothly
-
8/14/2019 Chapter 4: Understanding Users and File Systems
4/46
-
8/14/2019 Chapter 4: Understanding Users and File Systems
5/46
The Complete Guide to Linux System Administration 5
Types of User Accounts
(continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
6/46
The Complete Guide to Linux System Administration 6
Types of User Accounts
(continued)
su command
Temporarily changes access rights to those of
another user Without any parameters
Change to root account
Hyphen after su command
Causes command to run login scripts Places you in login directory of user
-
8/14/2019 Chapter 4: Understanding Users and File Systems
7/46
The Complete Guide to Linux System Administration 7
Types of User Accounts
(continued)
Preconfigured user accounts
Regular user accounts
Users who log in at keyboard and use Linux system Commonly associated with named individuals
Special user account
Used by Linux programs
Created during installation of Linux Vary depending on services installed
-
8/14/2019 Chapter 4: Understanding Users and File Systems
8/46
The Complete Guide to Linux System Administration 8
Linux Groups
Group
Collection of user accounts
Can be collectively granted access to files anddirectories
Each user in Linux is assigned to primary group
/etc/group file
Lists members of each defined group
-
8/14/2019 Chapter 4: Understanding Users and File Systems
9/46
The Complete Guide to Linux System Administration 9
Linux Groups (continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
10/46
The Complete Guide to Linux System Administration 10
User and Group Files /etc/passwd
Stores user account information
Password information not stored in this file
Contents include: User account name
Password
User ID number (UID)
Group ID number (GID)
Users real name
Home directory
Default shell
-
8/14/2019 Chapter 4: Understanding Users and File Systems
11/46
The Complete Guide to Linux System Administration 11
User and Group Files (continued)
/etc/group file
Defines groups on Linux system
vigr command Edit this file
Contents include:
Name of group
Group password GID number
Members of group
-
8/14/2019 Chapter 4: Understanding Users and File Systems
12/46
The Complete Guide to Linux System Administration 12
Shadow Passwords
/etc/shadow
Stores encrypted passwords
Can only be read by: Root user
Certain utilities
Shadow password suite
Collection of password-related programs Have been modified to recognize /etc/shadow file
-
8/14/2019 Chapter 4: Understanding Users and File Systems
13/46
The Complete Guide to Linux System Administration 13
Changing User Passwords
Can change password of any user account on
system
When logged in as root Use passwd command
Standard procedure
System administrator assigns initial password to
new account User immediately selects new password
-
8/14/2019 Chapter 4: Understanding Users and File Systems
14/46
The Complete Guide to Linux System Administration 14
Changing User Passwords
(continued)
To change users password
Use passwd without any parameters
Must enter current password
-
8/14/2019 Chapter 4: Understanding Users and File Systems
15/46
The Complete Guide to Linux System Administration 15
Changing User Passwords
(continued)
Good password characteristics
At least five characters long
Include digits or punctuation marks Mix uppercase and lowercase letters
Easy for account owner to remember
Hard for anyone else to guess
Not created from simple manipulation of: Word found in dictionary
Name of person or place
-
8/14/2019 Chapter 4: Understanding Users and File Systems
16/46
The Complete Guide to Linux System Administration 16
User Information Commands
id command
Shows effective UID
logname command View user name that you used to log in
whoami command
Shows user name of currently effective UID
groups command
Lists all groups you are a member of
-
8/14/2019 Chapter 4: Understanding Users and File Systems
17/46
The Complete Guide to Linux System Administration 17
User Information Commands
(continued)
who command
Lists all regular users on system
Shows location where they are logged in
w command
Information from who command, plus:
Time person logged in
Program they are running Information about system resources user is
consuming
-
8/14/2019 Chapter 4: Understanding Users and File Systems
18/46
The Complete Guide to Linux System Administration 18
File Permissions
Files and directories have
Owner
Group
Linux determines who can access file or directory
based on:
Who owner is
Which group is assigned to object File permissions define access granted to file or
directory
-
8/14/2019 Chapter 4: Understanding Users and File Systems
19/46
The Complete Guide to Linux System Administration 19
File Permissions (continued) Access mode
Permissions
Read permission (r) Write permission (w)
Execute permission (x)
Permissions can be assigned by:
User permissions Group permissions
Other permissions
-
8/14/2019 Chapter 4: Understanding Users and File Systems
20/46
The Complete Guide to Linux System Administration 20
File Permissions (continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
21/46
The Complete Guide to Linux System Administration 21
Changing Ownership chown command
Change user and group assigned to file ordirectory
Can only use when logged in as root Example: chown jtaylorManagers report.doc
Can use graphical file manager to change ownerof file
chgrp command Change group assigned to file or directory
Example: chgrp managers report.doc
-
8/14/2019 Chapter 4: Understanding Users and File Systems
22/46
The Complete Guide to Linux System Administration 22
Changing File Permissions
chmod (change mode) command
Change file permissions
Regular users can alter permissions assigned toany file or directory that you own
Example: chmod o+w reportDoc
System administrators normally use shortcut
syntax
-
8/14/2019 Chapter 4: Understanding Users and File Systems
23/46
The Complete Guide to Linux System Administration 23
Changing File Permissions
(continued)
Alternate syntax
Each of sets of three permissions is represented
by number from 0 to 7 Example: chmod 640 report.doc
Graphical environment provides easy method of
setting file permissions
Properties dialog box Permissions tab
-
8/14/2019 Chapter 4: Understanding Users and File Systems
24/46
The Complete Guide to Linux System Administration 24
Changing File Permissions
(continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
25/46
The Complete Guide to Linux System Administration 25
Changing File Permissions
(continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
26/46
The Complete Guide to Linux System Administration 26
Default File Permissions
rw-rw-rw-
umask command
Defines mask to stop certain permissions frombeing granted by default when files created
Executed automatically when you log in to Linux
Uses same three-digit permission codes as chmod
command
-
8/14/2019 Chapter 4: Understanding Users and File Systems
27/46
The Complete Guide to Linux System Administration 27
Introducing the File System
Managing file system is basic task for system
administrators
-
8/14/2019 Chapter 4: Understanding Users and File Systems
28/46
The Complete Guide to Linux System Administration 28
Partitions and File Systems
Partition
Distinct area of hard disk
Has been prepared to store particular type of data File system
Arrangement of information on device such as
hard disk
df command See status of all currently accessible file systems
-
8/14/2019 Chapter 4: Understanding Users and File Systems
29/46
-
8/14/2019 Chapter 4: Understanding Users and File Systems
30/46
The Complete Guide to Linux System Administration 30
Partitions and File Systems
(continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
31/46
The Complete Guide to Linux System Administration 31
Inodes and Links inode
Hold information about files
Within ext2 or ext3 file system
Has associated number
Controls file to which it points
Does not contain file name
File record contains:
File name
Inode number for file
-
8/14/2019 Chapter 4: Understanding Users and File Systems
32/46
The Complete Guide to Linux System Administration 32
Inodes and Links (continued) Directory record contains list of files with
corresponding inode numbers
Link allows two or more file records to refer to
same physical data stored in file system Symbolic link
File that refers to another file or directory, ratherthan containing data itself
Used when same data must be accessed from twolocations in directory structure
Takes only a few bytes of hard disk space
-
8/14/2019 Chapter 4: Understanding Users and File Systems
33/46
The Complete Guide to Linux System Administration 33
Inodes and Links (continued) ln command
Create symbolic link
Use -s option
Syntax: ln -s
Hard link
File record that includes file name and inode
Just like regular file record Refers to inode that already has file record
pointing to it
-
8/14/2019 Chapter 4: Understanding Users and File Systems
34/46
The Complete Guide to Linux System Administration 34
Inodes and Links (continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
35/46
The Complete Guide to Linux System Administration 35
Inodes and Links (continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
36/46
The Complete Guide to Linux System Administration 36
File Types
Different types of files are used to perform
different functions
Stat command Ties together file name with inode
Shows information about inode
-
8/14/2019 Chapter 4: Understanding Users and File Systems
37/46
The Complete Guide to Linux System Administration 37
File Types (continued)
-
8/14/2019 Chapter 4: Understanding Users and File Systems
38/46
The Complete Guide to Linux System Administration 38
Accessing Removable Media To use any file system
Must be mounted
Mount command Instruct Linux how to access file system
Mount point
Path in directory structure where you access data
in file system
umount command
unmount media
-
8/14/2019 Chapter 4: Understanding Users and File Systems
39/46
The Complete Guide to Linux System Administration 39
Accessing Removable Media
(continued)
fdformat command
Format 3.5-inch disk
/dev/fd0 Device name for 3.5-inch disk drive
-
8/14/2019 Chapter 4: Understanding Users and File Systems
40/46
The Complete Guide to Linux System Administration 40
Using find
find command
Helps find objects matching exact search criteria
Doesnt use prebuilt index Example: find /home -name "report.doc" -print
-
8/14/2019 Chapter 4: Understanding Users and File Systems
41/46
The Complete Guide to Linux System Administration 41
Managing File Archives
System administrators often work with files that
include:
Compressed data Multiple files in archival format
-
8/14/2019 Chapter 4: Understanding Users and File Systems
42/46
The Complete Guide to Linux System Administration 42
Compressing Files
Compressing files
Useful way to use less space for rarely accessed
data Makes files smaller before transmitting them over
network
gzip command
Compress any file gunzip command
Uncompresses file compressed using gzip
-
8/14/2019 Chapter 4: Understanding Users and File Systems
43/46
The Complete Guide to Linux System Administration 43
Using tar and cpio
for Archiving Files
tar archive
Single file that can contain other files and directory
structure tar command
Create tar archive
Specify files to be included in backup archive on
command line Writes data to file name or device
-
8/14/2019 Chapter 4: Understanding Users and File Systems
44/46
The Complete Guide to Linux System Administration 44
Using tar and cpio for Archiving
Files (continued)
cpio command
Copy in and out
Similar to tar Reads from STDIN channel for file names
Writes data back to STDOUT
tar and cpio
Help create incremental or multilevel backup
-
8/14/2019 Chapter 4: Understanding Users and File Systems
45/46
The Complete Guide to Linux System Administration 45
Summary
User accounts form basis of file system security
in Linux
Can change user that you are working as Each user can belong to multiple Linux groups
Encrypted passwords are stored in
/etc/shadow file
Linux file security is controlled by ninepermissions
-
8/14/2019 Chapter 4: Understanding Users and File Systems
46/46
The Complete Guide to Linux System Administration 46
Summary (continued) File systems
Organized collections of data
Created within partitions on hard disk
Hard and soft links
Refer to inode
Removable media must be mounted before it can
be accessed
Linux includes several utilities for compressing
files