Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Based Networks University of Education Instructor: Muhammad Amer Irshad.

Similar presentations


Presentation on theme: "Linux Based Networks University of Education Instructor: Muhammad Amer Irshad."— Presentation transcript:

1

2 Linux Based Networks University of Education Instructor: Muhammad Amer Irshad

3 Today’s Agenda

4 User Administration

5 User Accounts Because Linux is a multi-user system, the task of adding and maintaining user accounts is common in Linux system administration. Upon a successful installation of a Linux distribution, two user accounts are configured: the root user and a normal user. These two user accounts represent the two basic types of users that are configurable with Linux.

6 The first type The first type, the root user, is unique for several reasons. It is the only user account with system wide privileges. Other accounts can be set up as an exact clone of the root user account, but it is strongly discouraged.

7 System Accounts In your Linux distribution, you will see a number of accounts set up, like bin, daemon, adm, Ip, sync, shutdown, mail, operator, and others. They are called "system accounts" and are used for varying purposes, some self-explanatory, some not. These accounts do not have passwords because they are not designed for login. These special-purpose accounts are also called non-login accounts. They need to be in your password file. Do not delete them or some programs will not run.

8 Default Users

9 Default Groups

10 Privileges of a root user System administration tasks are performed from the root or superuser account. The following list summarizes some of the duties and privileges of a system administrator: Has complete access to all files and directories regardless of owner and permissions Controls user account administration Performs system maintenance Halts the system when necessary Sets up initial user passwords Changes passwords when necessary. Installs software on the system

11 The Second Type A normal user account, is the type of account that is set up for each individual user. This type of account differs only in respect to access privileges and home directories.

12 Important It is good system practice to have a separate account for each individual user. Avoid accounts that are shared, if possible.

13 Adding New Users Required steps: –Edit the /etc/passwd file to define the user's account. –Set an initial password. –Create the user's home directory. Extra steps (optional): –Copy default startup files to the user's home directory. –Add the user to the /etc/group file. –Set the user's mail home and establish mail aliases. –Enter the user in the site-wide user database (NIS). –Configure disk quotas. –Verify that the account is set up correctly. –Record accounting information.

14 User Accounts Utilities Managing users and groups has traditionally been tedious, Red Hat Linux has a few tools and conventions that make users and groups easier to manage. You can use useradd to create a new user from the shell prompt The easiest way to manage users and groups is through $ redhat-config-users

15 Account Setup Adding and deleting users is simple, but understanding the files involved with user account management is a bit more complex. The key to managing user accounts is to understand the underlying configuration files.

16 Key Configuration File The key file used in user account setup and configuration is the /etc/passwd file. This file is a simple ASCII text file.

17 /etc/passwd File Upon a successful installation, the contents of the /etc/passwd file resemble the following: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: adm:x:3:4:adm:/var/adm: lp:x:4:7:lp:/var/spool/lpd: sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail: news:x:9:13:news:/var/spool/news: uucp:x:10:14:uucp:/var/spool/uucp: operator:x:11:0:operator:/root: games:x:12:100:games:/usr/games: gopher:x:13:30:gopher:/usr/lib/gopher-data: ftp:x:14:50:FTP User:/var/ftp: nobody:x:99:99:Nobody:/: xfs:x:43:43:X Font Server:/etc/X11/fs:/bin/false apache:x:48:48:Apache:/var/www:/bin/false named:x:25:25:Named:/var/named:/bin/false gdm:x:42:42::/home/gdm:/bin/bash rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/bin/false rpc:x:32:32:Portmapper RPC user:/:/bin/false postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash mailnull:x:47:47::/var/spool/mqueue:/dev/null mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash nscd:x:28:28:NSCD Daemon:/:/bin/false pvm:x:24:24::/usr/share/pvm3:/bin/bash squid:x:23:23::/var/spool/squid:/dev/null

18 The /etc/passwd file root:*:0:3:The Big Guy,143 MSB:/:/bin/sh daemon:*:1:5::/:/bin/sh farrell:*:100:15:Paul Farrell:/users/research/farrell/:/bin/csh stacke:*:101:15:Olaf P. Stackelberg:/users/fac/stack:/bin/csh pwang:*:102:15:Paul S. Wang:/users/research/wang:/usr/local/bin/tcsh abaqus57:x:53:13:License Manager:/var/log/abaqus57:/usr/bin/csh matlab:x:54:13:Matlab License Manager:/usr/local/matlab5:/usr/bin/csh catadm:x:55:13::/usr/local/abaqus:/bin/csh … root:*:0:3:The Big Guy,143 MSB:/:/bin/sh daemon:*:1:5::/:/bin/sh farrell:*:100:15:Paul Farrell:/users/research/farrell/:/bin/csh stacke:*:101:15:Olaf P. Stackelberg:/users/fac/stack:/bin/csh pwang:*:102:15:Paul S. Wang:/users/research/wang:/usr/local/bin/tcsh abaqus57:x:53:13:License Manager:/var/log/abaqus57:/usr/bin/csh matlab:x:54:13:Matlab License Manager:/usr/local/matlab5:/usr/bin/csh catadm:x:55:13::/usr/local/abaqus:/bin/csh … login_name : password : user_id : group_id : user info : home : shell /etc/passwd zEach entry in /etc/passwd must be on one line. zEach field within each user's entry is separated from the next by a colon. Note

19 The /etc/passwd file contents Login name –case sensitive and unique for users. –no more than 8 chars long, may include numbers, except in position 1. (for some old system only) –/etc/aliases can be used to set the alias of user name for most mail system like sendmail. –Pseudo-Logins execute the corresponding commands as their shells. Eg daemon, bin. Encrypted password –Look like Xv8Q981g71oKK requ, encrypted by MD5 or DES algorithms. –If null, no password is required, ie Press Enter directly! –change user's password with passwd. –/etc/passwd is world readable -> no security. (refer to the /etc/shadow section)

20 The /etc/passwd file contents User ID –uid is the ID for the user, which must be unique. –UID 0 is reserved for root, and traditionally the lower number are kept for systems programs. –It is recommended that human users start at 500. –uid is a value between 0 and 65536. –It is a good idea to avoid reusing UIDs, since this avoids confusion when backups are restored. Group ID –gid is the ID of the group that the user belongs to. –gid is generally a value between 0 an 65536. GID 0 is reserved for root and 1 is usually reserved for daemon. –Groups' info are defined in /etc/groups. User Info (GECOS field) –No particular format, can be Full name, Address, Contact number, etc. –The finger command expects one to have comma delimited. –Can be modified by the chfn command.

21 The /etc/passwd file contents Home directory –Users are placed in their home directory when they log in. Eg. /home/staff/zahid. –Home directories are usually named with the user's login name, and should be read, write and executable by the user. –If it is missing or invalid, a message such as "no home directory" will be printed or login disabled or login to the root directory. # mkdir/home/staff/zahid # chownzahid /home/staff/zahid # chgrpzahid /home/staff/zahid # chmod700 /home/staff/zahid # mkdir/home/staff/zahid # chownzahid /home/staff/zahid # chgrpzahid /home/staff/zahid # chmod700 /home/staff/zahid  Shell  Specify a standard shell (sh, csh, bash, ksh, etc.), but can be a restricted shell, or a program.  Can be changed by chsh commands.  If the shell field is null, Bourne Shell is used.

22 Important Users daemon: Owner of Unprivileged Software –Usually has uid 1. –Controls the files that belong to UNIX system. bin: Owner of System Commands –Owns directories that contain the system's command and most of the executable files. sys (kmem): Owner of the Kernel and Memory Images –Owns special files such as /dev/kmem (kernel's address space), /dev/mem (the physical memory of system), and /dev/swap (image of the system's swap space). nobody: Owner of Nothing –The owner of software that doesn't need or shouldn't have special permissions, eg fingerd.

23 The /etc/group file root:X:0:root daemon:X:1: bin:X:2:root,bin,daemon sys:X:3:root,bin,sys,adm adm:X:4:root,adm,daemon … root:X:0:root daemon:X:1: bin:X:2:root,bin,daemon sys:X:3:root,bin,sys,adm adm:X:4:root,adm,daemon … /etc/group zEach line has, 4 colon separated fields, Group name password - never used GID - group ID number list of members zIn practice, users are in the group given in the password file whether or not they are entered in that group in /etc/group.

24 /etc/shadow File bin:*:11458:0:99999:7::: daemon:*:11458:0:99999:7::: adm:*:11458:0:99999:7::: lp:*:11458:0:99999:7::: sync:*:11458:0:99999:7::: shutdown:*:11458:0:99999:7::: halt:*:11458:0:99999:7::: mail:*:11458:0:99999:7::: The /etc/shadow password file looks similar to the following: root:$1$d5.gDvSX$nyQhvBgUGbw0GcNTxAdKR1:11507:0:99999:7:::

25 Secure Password Files Modern UNIX systems like Linux and Solaris, place the passwords in a secure file (commonly called a shadow password file) or files elsewhere. The format and location differs between systems, as does the entry in the password section of the normal password file. The /etc/shadow file: –Its access permissions are much more restricted, only view by the root. –Provides also Password Aging, like password expiration.

26 Much like the /etc/passwd file, the /etc/shadow file consists of single-line entries with colon-delimited fields. root:$1$d5X$nyQBgUGbw0GcNTxAdKR1:11507:0:99999:7::: username:password:lastchg:min:max:warn:inactive:expire:flag usernameThe user's login name (UID). passwordAn encrypted password for the user, a lock string to indicate that the login is not accessible, or no string, which shows that there is no password for the login. lastchgThe number of days between 1/1/70 and the date that the password was last modified. minThe minimum number of days required between password changes. maxThe maximum number of days the password is valid. warnThe number of days before password expires that the user is warned. inactiveThe number of days after password expires until the a/c is permanently disable. (- 1 for disable the feature) expireA date, YYYY-MM-DD, specifying when the user will be disabled. (-1 for disable) flagReserved for future use.

27 Adding Users User accounts can be added by directly editing the /etc/passwd file or by using a utility such as useradd, available in all Linux distributions. Default characteristics for each user account are defined by the settings in the /etc/login.defs file, as follows

28 /etc/login.defs #QMAIL_DIRMaildir MAIL_DIR/var/spool/mail #MAIL_FILE.mail # Password aging controls: #PASS_MAX_DAYSMaximum number of days a password may be used. #PASS_MIN_DAYSMinimum number of days allowed between password changes. #PASS_MIN_LENMinimum acceptable password length. #PASS_WARN_AGENumber of days warning given before a password expires. # PASS_MAX_DAYS99999 PASS_MIN_DAYS0 PASS_MIN_LEN5 PASS_WARN_AGE7 # # Min/max values for automatic uid selection in useradd # UID_MIN 500 UID_MAX60000 # # Min/max values for automatic gid selection in groupadd # GID_MIN 500 GID_MAX60000 # # If defined, this command is run when removing a user. # It should remove any at/cron/print jobs etc. owned by # the user to be removed (passed as the first argument). # #USERDEL_CMD/usr/sbin/userdel_local # # If useradd should create home directories for users by default # On RH systems, we do. This option is ORed with the -m flag on # useradd command line. # CREATE_HOMEyes

29 When we create a new home directory A new directory, /home/username, is created and populated with copies of the default files in the /etc/skel and /etc/skel.d directories (in that order).

30 Managing Users with Command Line Tools Creating a new user account To create a user from your command line you can run the useradd command. This will add a new entry in /etc/passwd and in /etc/shadow if you use shadow passwords using system defaults. #useradd newuser

31 Creating a new user account When I run the preceding command on my Red Hat system, /etc/passwd shows a new line such as the following: newuser:!!:506:506::/home/newuser:/bin/bash If you remember the /etc/passwd fields from earlier discussion, You will see that the password field (the second field) is set to !!. This means that this password is not set and the user cannot log in just yet. So you will need to create a password for this user by running the passwd command as follows: #passwd newuser

32 Default Settings The UID and the GID values will be automatically selected by useradd. The home directory is created in the default top-level home directory The login shell is also selected from a system default. You will learn to set these defaults in a later section.

33 Overriding System Default If you would like to override a system default, you can specify a command line option To override the default home directory, use the -d new directory option #useradd newuser -d /www/newuser Note: useradd will create only the final directory and not the entire path.

34 Private Group The useradd that comes with Red Hal Linux creates a private group for the user with the same name as the username.

35 Overriding System Default You can override the idea of private group by using the -g group option For example: This will make useradd create the new user (mjkabir) with the default group set to the users. #useradd mjkabir -g users

36 Assigning user an additional group You can use the -G comma-separated list of groups option. For example: Here the new user (mjkabir) will be added to the wheel and admins groups in the /etc/group file. #useradd mjkabir -G wheel,admins

37 To Find Out which groups user belong to You can use the command to find out which user belongs to what group. #groups username

38 Creating a new group To create a new group, use the groupadd command. For example: #groupadd mygroup

39 To change or set a user's password, use the passwd command. For example: Note: When an ordinary user runs the passwd program, no username argument is required, because it will allow her to change only her own password. #passwd zahid CHANGING A PASSWORD

40 CHANGING THE SHELL If the default shell is not appropriate for a user, you may change it to any shell you list in /etc/shells. Use the chsh command to change a user's shell. For example: Note that a user can change her own shell using this command as well. You can also use the usermod command to modify the shell information as follows: #chsh zahid #usermod -s new shell path username

41 CHANGING THE HOME DIRECTORY To change the home directory of an existing user, run the usermod command as follows: For example, you can run the command as follows: However, if you would like to move the home directory contents to the new location, use the -m option as follows: #usermod -d new home directory username #usermod -d /home2/zahid zahid #usermod -d /home2/zahid -m zahid

42 CHANGING A DEFAULT GROUP To change the default group for a user, use the usermod command as follows: For example: This command will change the default group for user zahid to 512. #usermod -g group name or GID username #usermod -g 512 zahid

43 CHANGING ACCOUNT EXPIRATION DATE If you are using shadow passwords, you can change the expiration date of a user account using the usermod command as follows: For example: This command will reset the account expiration date for user zahid to 12/31/2005. #usermod -e MM/DD/YY username #usermod -e 12/31/2005 zahid

44 CHANGING FINGER INFORMATION You can also change the finger information, such as the full name and phone numbers. Run the chfn command to change a user's finger information. For example: #chfn zahid

45 Modifying an existing group To modify an existing group name or GID, use the groupmod command. To rename a group to a new name, use the following syntax: For example: Here the existing novices group is renamed to experts. #groupmod -n new group current group #groupmod -n experts novices

46 Deleting a user account To delete an existing user use the userdel command. For example: This deletes a user called snake. If you would like to remove the user's home directory and all the contents within the directory, use the -r option. # userdel snake

47 Caution!! userdel will not delete the user if the user is currently logged in.

48 Disabling a user account If you would like to temporarily disable a user account, you can do one of the following: Use the usermod -s new shell username' command to change the shell to /bin/false (make sure it is in your / etc/shells). This will disallow the user from logging into the system If you are using the shadow passwords, you can use the usermod -e MM/DD/YY username command to cause the user account to expire. If you would like to disable all user account access for a temporary reason, you can create a file called /etc/nologin with a message explaining why you arc not allowing access.


Download ppt "Linux Based Networks University of Education Instructor: Muhammad Amer Irshad."

Similar presentations


Ads by Google