Академический Документы
Профессиональный Документы
Культура Документы
Linux is a multiuser operating system, where multiple users can work simultaneously in their own operating environment.Thus user management is an important concept Even if the system is only used by a single user it is still important to create a user account besides the administrative (root) account root has unlimited privileges, many of which are not required for day to day activities Groups allow the grouping of individual users under a single name for file access control
Three kinds of users are at work in the typical Fedora Core Linux system environment:
the superuser (root): UID 0 the regular user: UIDs beginning with 500 the system user: UID 1 through 499 and 65,534
/etc/passwd stores user account information /etc/group stores group and membership information /etc/shadow shadows the password file and stores encrypted passwords and password expiry information Password file contains the following entries (one line peruser):
username:password:uid:gid:gecos:homedir:shell
User ID: system assigned number Group ID: ID of the user's default group Comment: a descriptive string, usually user's name Home directory: full path to user's home directory Default shell
Add default files to be part of every users home directory to /etc/skel directory Create home directory for all users Configure default settings for all users Create groups Create user account for each person Create valid password for each user
system-config-users utility
System-config-users
User name Full name Password and confirm password Home directory Login shell Enable account expiration Lock local password ???
Experts recommend changing password every 30 to 60 days User Properties dialog, Groups tab
Lists groups from /etc/group file Each user assigned primary group
Used by Red Hat Linux and Fedora Users primary group has same name as user Contains only user as member
system-config-users utility Add User button Enter information on dialog Utility creates home directory based on user name
/etc/login.defs file
Delete user
Select user name on Users tab Click delete button Some administrators prefer to permanently disable, not delete
-c comment: comment stored in password file, usually user's name -d directory: home directory name -s shell: shell for the account -g initial_group: user's initial login group
Examples:
useradd joe (add user joe with default values) useradd -s /bin/bash -c 'Joe Smith' joe (add user joe with supplied values)
useradd utility
Create new users Must be logged in as root Example: useradd -g sales -c Raley Solomon" rsolomon -D option displays the default settings Edit /etc/default/useradd to change defaults
Creates user ID and assigns it to one or more groups -g option specifies initial group -G option specifies additional groups
passwd command
Change users password Lock user account: passwd -l thomas Unlock account: passwd -u thomas
Change Password
To change your password, type the command passwd at a shell You will be prompted for a new password, and a confirmation - after confirming your current password Bad passwords are disallowed passwords should be at least 6 characters long, contain both letters and digits or punctuation and must not be based on dictionary words There is usually a graphical utility for changing passwords accessible from the application menu (this is desktopspecific)
groupadd command
groupadd command creates new group ID and makes group available for use
Assign unique ID number to each group Does not automatically assign access rights
File Permissions
usermod command
groupmod command
Change password
passwd command
-r: deletes files in the user's home directory userdel joe (delete joe, preserving his home directory) To delete an existing group: Users must be removed from a primary group before that group can be deleted
Example:
userdel command
Delete user account permanently Does not remove users home directory or contents
Remove group Be careful deleting groups
groupdel command
Assignment
Try out following commands chgrp Changes the group ownership of a file or directory. chown Changes the owner of a file or directory. chmod Changes the access permissions of a file or directory.
Compression and archiving are useful for backups and transferring multiple files across a network (via ftp, http, email attachments, etc.) Compression utilities include gzip (.gz extension), bzip2 (.bz2 extension) and zip (.zip extension MS compatible) Archiving utilities include tar (.tar extension most common Linux format) and zip (.zip extension MS compatible)
-d: decompresses instead of compressing -l: lists compression information -t: tests the file's integrity gzip somefile.txt (compresses the file and renames to somefile.txt.gz) gzip -d tarfile.tar.gz (uncompresses the file and renames to tarfile.tar)
Examples:
-c: creates a new archive -f tarfile: uses the specified tar filename (instead of stdin / stdout) -t: lists the contents of an archive -v: lists files as they are processed -x: extracts files from an archive -z: filters the archive through gzip -j: filters the archive through bzip2
Examples:
tar -cvf docbackup.tar *.doc (creates a tar file containing all .doc files) tar -zxf somearchive.tar.gz (extracts files in the archive compressed with gzip) tar -jtf somearchive.tar.bz2 (lists files in the archive compressed with bzip2)
Assignment