March 8, 2009

How to: Configure users on CentOS 5

To add user1

# useradd user1

This command will do the following:

  • Create a home directory,/home/user1, for user1
  • Add the configuration files from /etc/skel to the user home directory
  • Assign the /bin/bash shell

To list the hidden files

# ls -a /home/user1

To assign a password to user1

# passwd user1

To delete user1 and the user1's home directory

# userdel -r user1

To assign user1 to the admin group

# usermod -G admin user1

To allow user1 full administrative

  • Add user1 to the wheel group with this command
    # usermod -G wheel user1
  • # vi /etc/sudoers
  • Add the following line:
    user1    ALL=(ALL)       ALL

To add user2, user3 and user4 to the training group, and to allow them to share the /home/training directory:

  1. # mkdir /home/training
  2. # useradd user2; passwd user2
    # useradd user3; passwd user3
    # useradd user4; passwd user4
    
  3. # vi /etc/group
  4. Add the training group, give it a unique group id, and add user2, user3, and user4 to the group as follows:
    training,x,9999,user2,user3,user4
  5. # chmod 2770 /home/training
RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Spread the word

del.icio.us Digg Furl Reddit Help

Permalink • Print

Related Entries

Made with WordPress and a healthy dose of Semiologic • Sky Gold skin by Denis de Bernardy