10. User Creation
10. User Creation
# /etc/passwd --> it contains all users general information. such as user id, gid, shell, home
directory etc.
# /etc/shadow --> It contains all users password information. such as encrypted password,
password expiry, account expiry, warning period etc..
# /etc/group --> It contains all groups general information. such as group id, group members list.
# /etc/gshadow --> It contails all groups password information. such as encrypted password,
group admin, group members list.
# /etc/default/useradd --> THis is the default user administration configuration file. you can
specify shell, skel, home directory, mail etc...
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
# /etc/login.defs --> This is main configuration file for user administration, group adminitration,
password management.
#
# Please note that the parameters in this configuration file control the
# tools uses the PAM mechanism, and the utilities that use PAM (such as the
# *REQUIRED*
#QMAIL_DIR Maildir
MAIL_DIR /var/spool/mail
#MAIL_FILE .mail
# UMASK is also used by useradd(8) and newusers(8) to set the mode for new
# 022 is the default value, but 027, or even 077, could be considered
# for increased privacy. There is no One True Answer here: each sysadmin
UMASK 022
# HOME_MODE is used by useradd(8) and newusers(8) to set the mode for new
# home directories.
# If HOME_MODE is not set, the value of UMASK is used to create the mode.
HOME_MODE 0700
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
UID_MIN 1000
UID_MAX 60000
# System accounts
SYS_UID_MIN 201
SYS_UID_MAX 999
#
GID_MIN 1000
GID_MAX 60000
# System accounts
SYS_GID_MIN 201
SYS_GID_MAX 999
#USERDEL_CMD /usr/sbin/userdel_local
CREATE_HOME yes
USERGROUPS_ENAB yes
ENCRYPT_METHOD SHA512
# /etc/skel/ --> This is skeleton directory this provides user login program, user profile program ,
logout program
# /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# Prevent doublesourcing
if [ -z "$BASHRCSOURCED" ]; then
BASHRCSOURCED="Y"
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*|vte*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
PROMPT_COMMAND="__vte_prompt_command"
else
fi
;;
screen*)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
fi
;;
*)
;;
esac
fi
shopt -s histappend
history -a
# Turn on checkwinsize
shopt -s checkwinsize
# if [ "$PS1" ]; then
# fi
fi
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
# By default, we want umask to get set. This sets it for non-login shell.
umask 002
else
umask 022
fi
SHELL=/bin/bash
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
fi
fi
# vim:ts=4:sw=4
[root@localhost ~]#
# /var/spool/mail/<username> --> Local users mail box
# eg: /home/jack
# User Administration
cmd: useradd or # adduser
syntax:
# useradd <username>
# adduser <username>
# eg:
jack:x:1004:1005::/home/jack:/bin/bash
jerry:x:1005:1006::/home/jerry:/bin/bash
jerry:x:1005:1006::/home/jerry:/bin/bash
jerry:x:1005:1006::/home/jerry:/bin/bash
1 2 3 4 5 6 7
field1: username
field3: userid
field4: groupid
field5: comment
jack:!!:18900:0:99999:7:::
jerry:!!:18900:0:99999:7:::
[root@localhost ~]#
jack:x:1005:
jerry:x:1006:
jack:!::
jerry:!::
[root@localhost ~]#
[root@localhost ~]# id jack
[root@localhost ~]#
[jack@servera ~]$
[jack@servera ~]$
/home/jack
[jack@servera ~]$ ls
abc
[jack@servera ~]$
[jack@servera ~]$ ls
abc
[jack@servera ~]$ ls -a
[jack@servera ~]$
[jack@servera ~]$ ls
abc
logout
abc
[root@localhost ~]#