460 likes | 567 Views
Chapter 4: Understanding Users and File Systems. The Complete Guide to Linux System Administration. 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
E N D
Chapter 4:Understanding Users and File Systems The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Types of User Accounts • Preconfigured user accounts • Root • Administrative account • Also called superuser • Can perform any operation on Linux system • Do not log in as root for normal work • Change temporarily to root user The Complete Guide to Linux System Administration
Types of User Accounts (continued) The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Linux Groups • Group • Collection of user accounts • Can be collectively granted access to files and directories • Each user in Linux is assigned to primary group • /etc/group file • Lists members of each defined group The Complete Guide to Linux System Administration
Linux Groups (continued) The Complete Guide to Linux System Administration
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) • User’s real name • Home directory • Default shell The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Changing User Passwords (continued) • To change user’s password • Use passwd without any parameters • Must enter current password The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
File Permissions (continued) The Complete Guide to Linux System Administration
Changing Ownership • chown command • Change user and group assigned to file or directory • Can only use when logged in as root • Example: chown jtaylorManagers report.doc • Can use graphical file manager to change owner of file • chgrp command • Change group assigned to file or directory • Example: chgrp managers report.doc The Complete Guide to Linux System Administration
Changing File Permissions • chmod (change mode) command • Change file permissions • Regular users can alter permissions assigned to any file or directory that you own • Example: chmod o+w reportDoc • System administrators normally use shortcut syntax The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Changing File Permissions (continued) The Complete Guide to Linux System Administration
Changing File Permissions (continued) The Complete Guide to Linux System Administration
Default File Permissions • rw-rw-rw- • umask command • Defines mask to stop certain permissions from being granted by default when files created • Executed automatically when you log in to Linux • Uses same three-digit permission codes as chmod command The Complete Guide to Linux System Administration
Introducing the File System • Managing file system is basic task for system administrators The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Partitions and File Systems (continued) • Linux typically uses one of two default file system types: • ext3 • Reiserfs The Complete Guide to Linux System Administration
Partitions and File Systems (continued) The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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, rather than containing data itself • Used when same data must be accessed from two locations in directory structure • Takes only a few bytes of hard disk space The Complete Guide to Linux System Administration
Inodes and Links (continued) • ln command • Create symbolic link • Use -s option • Syntax: ln -s <existing file> <symbolic link to be created> • 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 The Complete Guide to Linux System Administration
Inodes and Links (continued) The Complete Guide to Linux System Administration
Inodes and Links (continued) The Complete Guide to Linux System Administration
File Types • Different types of files are used to perform different functions • Stat command • Ties together file name with inode • Shows information about inode The Complete Guide to Linux System Administration
File Types (continued) The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
Accessing Removable Media (continued) • fdformat command • Format 3.5-inch disk • /dev/fd0 • Device name for 3.5-inch disk drive The Complete Guide to Linux System Administration
Using find • find command • Helps find objects matching exact search criteria • Doesn’t use prebuilt index • Example: find /home -name "report.doc" -print The Complete Guide to Linux System Administration
Managing File Archives • System administrators often work with files that include: • Compressed data • Multiple files in archival format The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration
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 nine permissions The Complete Guide to Linux System Administration
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 The Complete Guide to Linux System Administration