Tuesday, September 15, 2015

User and Group

* Configuration files for user and group

1 . /etc/skel

2. /etc/default/useradd

3. /etc/login.def

4. /etc/passwd

5. /etc/shadow

6. /etc/shadow

7. /etc/gshadow
*************

I. "/etc/skel directory "

> The /etc/skel directory contains files and directories that are automatically copied over to a new user's home directory when such user is
created by the useradd program.

> /etc/skel allows a system administrator to create a default home directory for all new users on a computer or network and thus to make certain that all users begin with the same settings or environment.

> Several user configuration files are placed in /etc/skel by default when the operating system is installed. Typically they might include .bash_profile, .bashrc, .bash_logout, dircolors, .inputrc and .vimrc. The dots preceding the names of these files indicate that they are hidden files, i.e., files that are not normally visible in order to avoid visual clutter and help reduce the chances of accidental damage.

> The location of /etc/skel can be changed by editing the line that begins with SKEL= in the configuration file /etc/default/useradd. By default this line says SKEL=/etc/skel.


> The /etc/skel directory holds files that are copied automatically to individual usersâ home directories when their accounts are created. These files are known as skeleton files. Typically, theyâre hidden files that affect the user environment, such as .bash_history, which records each command you run and .bashrc, which sets the default values used with the bash shell.

> You can add files and directories to /etc/skel, and they will be copied to each new userâs home directory.

> NOTE â changes to /etc/skel affect only new accounts, not existing accounts. The files that are created under the /etc/skel directory are not copied
to the existing usersâ home directory.

[root@server2 ~]# ls -al /etc/skel/

total 44
drwxr-xr-x   3 root root  4096 May 30 05:17 .
drwxr-xr-x 101 root root 12288 May 30 05:33 ..
-rw-r--r--   1 root root    33 Sep 25  2014 .bash_logout
-rw-r--r--   1 root root   176 Sep 25  2014 .bash_profile
-rw-r--r--   1 root root   124 Sep 25  2014 .bashrc
drwxr-xr-x   4 root root  4096 Oct 29  2013 .mozilla
[root@server2 ~]#

> There are three default hidden files are in the /etc/skel directory. 

1. .bash_logout

II. "etc/default/useradd"

> When useradd command executed, it takes some of user property values form a file called /user/default/useradd from where it gets the following values:

GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

 Description : -

1. GROUP:       Maximum number of groups for which a user can be a member of.

2. HOME :       Directory where the user's home directory will be created.

3. INACTIVE:    Number of days the account should be inactive after creation.

   Note:                "-1" means never inactive i.e. always active

4. EXPIRE:      Date on which the account should expire. It is given in the form YYYY-MM-DD.

5. SHELL:       Default login shell for the user.

6. SKEL:                Directory from where the default user profile files will be copied to the user's home directory.

7. CREATE_MAIL_SPOOL: This option ensures that a new user will have a directory of its user name in /var/main where the mail process can store mail messages.

By editing this file from command line, you can change the default shell and directory containing home directories for new users on Linux Operating System.

III. "/etc/login.def"

Description

The /etc/login.defs file defines the site-specific configuration for the shadow password suite. This file is required.
Absence of this file will not prevent system operation, but will probably result in undesirable operation.

This file is a readable text file, each line of the file describing one configuration parameter. The lines consist of a
configuration name and value, separated by whitespace. Blank lines and comment lines are ignored. Comments are
introduced with a "#" pound sign and the pound sign must be the first non-white character of the line.

[root@server2 ~]# cat /etc/login.defs

# *REQUIRED*
#   Directory where mailboxes reside, _or_ name of file, relative to the
#   home directory.  If you _do_ define both, MAIL_DIR takes precedence.
#   QMAIL_DIR is for Qmail
#
#QMAIL_DIR      Maildir
MAIL_DIR        /var/spool/mail
#MAIL_FILE      .mail

# Password aging controls:
#
#       PASS_MAX_DAYS   Maximum number of days a password may be used.
#       PASS_MIN_DAYS   Minimum number of days allowed between password changes.
#       PASS_MIN_LEN    Minimum acceptable password length.
#       PASS_WARN_AGE   Number of days warning given before a password expires.
#
PASS_MAX_DAYS   99999
PASS_MIN_DAYS   0
PASS_MIN_LEN    5
PASS_WARN_AGE   7

#
# Min/max values for automatic uid selection in useradd
#
UID_MIN                   500
UID_MAX                 60000

#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN                   500
GID_MAX                 60000

#
# 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 overridden with the -m flag on
# useradd command line.
#
CREATE_HOME     yes

# The permission mask is initialized to this value. If not specified,
# the permission mask will be initialized to 022.
UMASK           077

# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes

# Use MD5 or DES to encrypt password? Red Hat use MD5 by default.
MD5_CRYPT_ENAB yes

[root@server2 ~]#

> There is two types of shells in the linux 

deo:x:500:500:Shankar deo:/home/deo:/bin/bash

A. Active shell

/bin/bash
/usr/bin/bash
/sbin/
/usr/sbin

B. Inactive shell

/sbin/nologin
/sbin/halt
/sbin/shutdown
/bin/false

GECOS Mode - full name of the user in the /etc/passwd 5th colon.

*The user in /etc/passwd has user ID (UID) less then 500 is a system user .

* The users have UID 500 = 500 or > 500 is called  - Normal user , local user or limited user.

* The process of runnig a application work like - Kernel > shell > OS > Application > User.

* User give the instruction to the OS > OS passes the instruction to the shell > Shell translate it in to the binary and send the instruction to the kernel .

* If we change any user's UID to "0" the user start acting like a root user. Because UID "0" is the root uid. So when a normal user has uid 0 send any
request to the kernel , kernel understand its root user because of the UID "0"


No comments:

Post a Comment