Documente Academic
Documente Profesional
Documente Cultură
Unit 6
Managing
Users and Groups
Lecturer: V Tn Dng
votandung@yahoo.com
http://sites.google.com/site/votandungsg/
V TN DNG
V TN DNG
V TN DNG
Managing Users
via Command-Line Tools
V TN DNG
Creating Users
The useradd utility creates new users and adds them to the
system. Following the short procedure below, you will
create a default user account with its UID, automatically
create a home directory where default user settings will be
stored, /home/username/, and set the default shell to
/bin/bash.
Command Format
useradd username
By setting a password unlock the account to make it
accessible. Type the password twice when the program
prompts you to.
Command Format
passwd
V TN DNG
robert:x:502:502::/home/robert:/bin/bash
V TN DNG
V TN DNG
V TN DNG
useradd -d home_directory
V TN DNG
V TN DNG
useradd -r username
V TN DNG
V TN DNG
passwd -l username
passwd -u username
V TN DNG
V TN DNG
V TN DNG
V TN DNG
passwd -e username
V TN DNG
V TN DNG
V TN DNG
V TN DNG
V TN DNG
V TN DNG
V TN DNG
su switching-username
If no switching-username, then the default switchingusername, user root, is used.
When you use the su command, the system will ask to
enter the password of switching-username.
who command: show who are logged in your Linux system.
V TN DNG
id [options] username
Some options for this command:
-g: show the main group that contains this user.
-u: only display the UID of the this user.
-G: displays all groups that the user is a member.
V TN DNG
Deleting Users
If you want to remove a user account from the system, use
the userdel command on the command line as root.
userdel username
Combining userdel with the -r option removes files in the
user's home directory along with the home directory itself.
userdel -r username
V TN DNG
Managing Groups
via Command-Line Tools
V TN DNG
Creating Groups
Groups are a useful tool for permitting co-operation
between different users.
There is a set of commands for operating with groups such
as groupadd, groupmod, groupdel, or gpasswd.
The files affected include /etc/group which stores group
account information and /etc/gshadow, which stores
secure group information.
To add a new group to the system with default settings,
the groupadd command is run at the shell prompt as root.
Command Format
V TN DNG
friends:x:505:
Automatically, the group friends is attached with a unique
GID (group ID) of 505 and is not attached with any users.
Optionally, you can set a password for a group by
running: .
gpasswd groupname
V TN DNG
V TN DNG
groupadd -r group_name
V TN DNG
V TN DNG
V TN DNG
gpasswd groupname
~]# gpasswd crowd
Changing password for group crowd
New password:
Re-enter new password:
The password for the group crowd has been changed.
You can also remove the password from the named group by
using the -r option.
gpasswd -r schoolmates
V TN DNG
V TN DNG
Deleting Groups
The groupdel command modifies the system account files,
deleting all entries that refer to the group. The named group
must exist when you execute this command.
groupdel groupname
V TN DNG
END OF UNIT 6
remember to do your homework
(see http://sites.google.com/site/votandungsg/)
V TN DNG