Posted on

Linux User Management

How to create and manage users on a Linux box.

These notes assume you have an initial login for a privelaged user such as root.

Creating A Group Of Users

  1. Login to the linux command line via an SSH session
  2. Add the group
  3. Create a directory for the users to “live in”
  4. Set the directory so members of the group can read/write/execute the info
  5. Add a user and attach to the group
  6. Set the user password
    • Repeat as necessary
groupadd dev
mkdir /home/users
chgrp dev /home/users
chmod 774 /home/users
useradd -d /home/users/<username> -g dev -m <username>
passwd <username>
...<enter password>
...<enter password again>

Modifying a User’s Primary Group

A user has a single “primary” group (defined at creation)

 usermod -g<maingroup> <username>

Adding Users To Secondary Groups

  1. Create the other group
  2. Modify an existing user to add to the group
groupadd othergrp
usermod -Gothergrp <username>

Change Defaults for useradd

Note: You should not do this unless you want to change systemwide settings. This can affect multiple scripts on your server.

  1. Look at the defaults
  2. Set new defaults
useradd -D
useradd -D -g100 -e60 -f0 -s/bin/bash

Changing Your Password

  1. Login as yourself
  2. Issue the password command
 passwd
 ...<enter your password>
 ...<enter your password again>
  1. Login as root
  2. Issue the password command for another user
 passwd otheruser
 ...<enter the otheruser password>
 ...<enter the otheruser password again>