● add a user
# useradd name
or
# adduser name
example:
# adduser --system --no-create-home --group yourusername
The --system
flag (-r
) will create a system user – one which does not have a password, a home dir and is unable to login.
Q 1st: --no-create-home
is no need?
Q 2nd: --group
is for what?
● modify the username of a user:
usermod -l new_username old_username
● To change the password for a user:
# passwd username
● change the shell for a user:
# chsh username
● To change the details for a user (for example real name):
# chfn username
● remove/delete a user
# userdel username
Then to delete the home directory for the deleted user account:
# rm -r /home/username
Bonus: If you want to delete user’s home directory/mails as well
# deluser --remove-home username
and
# deluser --remove-all-files username
will remove the user and all files owned by this user on the whole system.
● list all the groups
cat /etc/group
● list all the groups of which the current user is a member
groups
● list the members of a group
getent group groupname
● add a user to a specific group use
# usermod -G groupname -a username
● remove a user from a specific group
# gpasswd -d username groupname
● delete a group
# groupdel groupname
#linux #adduser #removeuser #addgroup #removegroup
2015/3/15