Users & Groups

Create User (usermod):

  • Note: useradd cannot be used to modify an existing user
useradd <username>
 -c comment, any text, usually user's name
 -d home-directory
 -g primary group; must exist, if not specified a default group is created
 -G group-list (secondary; must exist), definitive not additive (-a)
 -m create home dir
 -M do not create home dir
 -s login shell

passwd <username>

useradd:

  • low level binary compiled into system

adduser:

  • perl script which uses the useradd binary
  • adduser & addgroup are friendlier front end to the low level tools like useradd, groupadd and usermod programs
  • By default gives each user a corresponding group name with same name
  • creates home directory, can be overwritten with –home option, overwrite shell with –shell
  • copies skeleton files into home directory
  • prompts for password
adduser --home ... --shell ... --add_extra_groups username

Modify User (usermod):

usermod [options] <username>
-g primary group
-a append to supplementary groups, use with -G
-G list of groups, comma-separated, must exist
-s login shell (also see chsh)
-d / -m move home director

usermod -a -G secondarygroup username

gpasswd:

gpasswd groupname -a john

Check Groups:

groups username

Create Group:

groupadd - create new group

Files:

  • /etc/passwd – user login information primary group
    • username
    • password(x)
    • uid
    • guid
    • comment-field
    • home-dir
    • login-shell
  • /etc/group – supplementary groups
    • group_name
    • password (blank) :
    • guid :
    • group-list (users who are members)
  • /etc/shadow – stores encrypted passwords + password expiration details

Reference:

Advertisements
Posted in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: