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 vishal
- create home directory
- a
login name of vishal
In Detail :- useradd -gusers -Gmgmt -s/bin/shell -pxxxx -d/home/vishal -m vishal
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 vishal
Userdel - Deleting a user
Options:
- -r (remove home directory)
Example: To remove the user 'vishal' and his home directory
userdel -r vishal
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)
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 vishal
Enter existing password (can be either vishal's password or root's password)
Enter new password
Enter new password again (to validate)
Enter existing password (can be either vishal's password or root's password)
Enter new password
Enter new password again (to validate)
su - Switch User
To switch to another user, use the su command. This
is most commonly used to switch to the root account.
Example: To switch to root account...
su
Enter root's passwd
su
Enter root's passwd
Example: To switch to the user 'vishal'...
su roger
Enter vishal's or root's passwd
su roger
Enter vishal's or root's passwd
To return to original user, enter exit