>
Home

登龙(DLonng)

选择大于努力

Linux 系统基础 - 用户管理命令


版权声明:本文为 DLonng 原创文章,可以随意转载,但必须在明确位置注明出处!

This blog introduce some manage user command.

passwd

Using passwd to modify user password :

sudo passwd user_name

useradd / adduser

Using useradd or adduser to add user :

sudo useradd -m username

or :

sudo adduser -m username

usermod

Using usermod to modify user attributes :

# Modify user group to 134
sudo usermod -g134 username

Note : Using man usermod to show how to modify other attributes.

userdel / deluser

Using userdel or deluser to delete a user :

# [-r]: delete work dir.
sudo userdel -r username

or :

sudo deluser -r username

groupadd

Using groupadd to add a new group :

sudo groupadd new_group

# more /etc/group: new_group:x:1001:
more /etc/group

groupmod

Using groupmod to modify group :

# more /etc/group: new_group:x:NEW_GID:
sudo groupmod -gNEW_GID new_group

groupdel

Using groupdel to delete a group :

sudo groupdel new_group

id

Using id to show current user id :

# uid=1000(orange) gid=1000(orange) groups=1000(orange),4(adm)
# 24(cdrom),27(sudo),30(dip),46(plugdev),121(lpadmin),132(sambashare)
id

groups

Using groups to show the group to which the current user belongs.

# orange adm cdrom sudo dip plugdev lpadmin sambashare
groups

who

Using who to show current login user :

# orange   tty7         2017-06-10 12:36 (:0)
who 

whoami

Using whoami to show current user :

# orange
whoami

DLonng at 07/03/17