Saturday, December 13, 2008

Manage users in linux

useradd - Adding a new user


Options:
  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)
  • -m (Create the user's home directory

Example: To add a new user with

  • a primary group of users
  • a second group mgmt
  • starting shell /bin/bash
  • password of xxxx
  • home directory of roger
  • create home directory
  • a login name of roger

useradd -gusers -Gmgmt -s/bin/shell -pxxxx -d/home/roger -m roger


usermod - Modifying existing user

Options:

  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)

Example: To add the group 'others' to the user roger

usermod -Gothers roger


userdel - Deleting a user

Options:

  • -r (remove home directory)

Example: To remove the user 'roger' and his home directory

userdel -r roger


passwd - User's Password

Options:
  • user's name (Only required if you are root and want to change another user's password)

Example: To change the password for the account you are currently logged in as...

passwd
Enter existing password
Enter new password
Enter new password again (to validate)

Example: To change the password for the user 'roger' (only you are logged in as root)...

passwd roger
Enter existing password
(can be either roger's password or root's password)
Enter new password
Enter new password again (to validate)

No comments:

Post a Comment