CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage

Embed Size (px)

DESCRIPTION

Contents: User/ Group Management. Create, manage, suspend and delete users. Disk Quota. Concepts and factors. Enabling, creating and managing disk quota. 2015Qassim University, College of Computer, 9th level 3

Citation preview

CSC414 Introduction to UNIX/ Linux Lecture 6 Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage Structure. 4. Processes and Inter- Process Communication. 5. Shell Programming. 6. User Management and Disk Quota. 7. System Management. 8. Network Management. 9. Security. 10. Advanced System Administration. 2015Qassim University, College of Computer, 9th level 2 Contents: User/ Group Management. Create, manage, suspend and delete users. Disk Quota. Concepts and factors. Enabling, creating and managing disk quota. 2015Qassim University, College of Computer, 9th level 3 Creating a new User Account Add an entry in /etc/passwd and /etc/shadow file (use next uid and suitable gid). You will have to create the user directory and assign a password to the user. Use useradd or adduser command to create a new user (useradd g -d -c -s login-name) and groupadd to create a new group (groupadd group-name). You will have to assign a password (passwd login-name) In GUI: Applications System Settings Users and Groups 2015Qassim University, College of Computer, 9th level 4 User Management Commands su Single user login. (su -) useradd Create a new user or update default new user information. (useradd g -s -c d userdel Delete a user account and related files. (userdel ) usermod Modify a user account. users Print the user names of users currently logged in. wall Send a message to everybody's terminal. (wall text message) who Display the users logged in. whoami Print effective user id. passwd Set a user's pass word. (passwd, passwd ) 2015Qassim University, College of Computer, 9th level 5 6 2015Qassim University, College of Computer, 9th level 2015Qassim University, College of Computer, 9th level 7 The /etc/passwd file is a list of users recognized by the system. It can be extended or replaced by a directory service, so its complete and authoritative only on standalone systems. The system consults /etc/passwd at login time to determine a users UID and home directory, among other things. Each line in the file represents one user and contains seven fields separated by colons. /etc/passwd File /etc/passwd Holds user account info Included fields are: Login name User Id (uid) Group Id (gid) General Comment about the user Home Directory Shell 2015Qassim University, College of Computer, 9th level 8 Contd Encrypted passwords used to live in the second field, but that is no longer safe; with fast hardware, they can be cracked (decrypted) in minutes The passwd file contains an x in the encrypted password field on Linux, Solaris, and HP-UX and an ! or a * on AIX. The actual encrypted passwords are stored in /etc/shadow on Linux, Solaris, and HP-UX and in/etc/security/passwd on AIX. 2015Qassim University, College of Computer, 9th level 9 /etc/shadow File /etc/shadow Contains the encrypted password information for users' accounts and optionally the password aging information. Included fields are: Login name Encrypted password Days since Jan 1, 1970 that password was last changed Days before password may not be changed Days after which password must be changed Days before password is to expire that user is warned Days after password expires that account is disabled Days since Jan 1, 1970 that account is disabled 2015Qassim University, College of Computer, 9th level 10 Suspending a User Account Put a * as start of Password field in /etc/shadow Change login shell to /sbin/nologin Use GUI to suspend the user 2015Qassim University, College of Computer, 9th level 11 Removing a User Account Remove login id from /etc/passwd & /etc/shadow file and delete home directory userdel r Use GUI to Delete the user 2015Qassim University, College of Computer, 9th level 12 What is quota? Linux file systems implement the disk quota mechanism. Users can be allocated disk quotas on specific file systems and can be restricted by number of disk blocks and/or number of inodes. Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full. On Linux, you can setup disk quota using one of the following methods: File system base disk quota allocation User or group based disk quota allocation contd. On the user or group based quota, following are three important factors to consider: Hard limit For example, if you specify 2GB as hard limit, user will not be able to create new files after 2GB Soft limit For example, if you specify 1GB as soft limit, user will get a warning message disk quota exceeded, once they reach 1GB limit. But, theyll still be able to create new files until they reach the hard limit Grace Period For example, if you specify 10 days as a grace period, after user reach their soft limit, they would be allowed additional 10 days to create new files. In that time period, they should try to get back to the quota limit. Configuring Disk Quotas The quota RPM must be installed to implement disk quotas. To implement disk quotas, use the following steps: 1. Enable quotas per file system by modifying the /etc/fstab file. 2. Remount the file system(s). 3. Create the quota database files and generate the disk usage table. 4. Assign quota policies. Enabling Quotas As root, using a text editor, edit the /etc/fstab file. Add the usrquota and/or grpquota options to the file systems that require quotas. Remounting the File Systems: mount -o remount file-system Creating the Quota Database Files After each quota-enabled file system is remounted run the quotacheck command. The quotacheck command examines quota-enabled file systems and builds a table of the current disk usage per file system. The table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated. To create the quota files (aquota.user and aquota.group) on the file system, use the -c option of the quotacheck command. quotacheck -cug /home contd. After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled: # quotacheck -avug The options used are as follows: a Check all quota-enabled, locally-mounted file systems v Display verbose status information as the quota check proceeds u Check user disk quota information g Check group disk quota information Assigning Quotas per User The last step is assigning the disk quotas with the edquota command. To configure the quota for a user, as root in a shell prompt, execute the command: # edquota username Perform this step for each user who needs a quota. Assigning Quotas per Group to set a group quota for the devel group use the command: # edquota -g devel To verify that the group quota has been set, use the command: # quota -g devel Setting the Grace Period for Soft Limits If a given quota has soft limits, you can edit the grace period (i.e. the amount of time a soft limit can be exceeded) with the following command: # edquota -t Report the disk quota usage for users and group Use the repquota command as shown below to report the disk quota usage for the users and groups. # repquota /home *** Report for user quotas on device /dev/sda3 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace root nobody ramesh john Contd For each file system where a quota has been defined, the current user will receive a line of output with the following fields: Filesystem Mount point of the file system with quotas Usage Amount of blocks used Quota Number of blocks allowed (soft) Limit Blocks allowed (hard) Grace Applicable only if over quota Files Current number of files used Quota Number of blocks allowed (soft) Limit Blocks allowed (hard) Grace Applicable only if over quota Qassim University, College of Computer, 9th level Reading Chapter 6 from the textbook. Quota HOWTO from tldp site Qassim University, College of Computer, 9th level 23