Linux – Users and Groups

Linux has users and groups. Groups are collections of accounts with shared permissions. /etc/group shows a list of groups and their members.  All users are assigned a unique user ID, uid, and one or more group ID, gid. Most distributions uid’s start at 1000 but fedora for example start at 500

part of /etc/passwd

, <span>Linux – Users and Groups</span>, KandZ

 

sudo useradd user2  # add user user2, with default directory /home/user2 and populates it with files from /etc/skel. Also a line in /etc/passwd will be added. Default shell will be /bin/bash

sudo userdel user2  # delete user user2, but the home directory will not be deleted. To delete the home directory also use -r option

id  #  displays information about the current user

, <span>Linux – Users and Groups</span>, KandZ

 

sudo groupadd newGroup  # add a new group

sudo groupdel newGroup  # delete the previous created group

groups user  # shows the groups the user belongs

, <span>Linux – Users and Groups</span>, KandZ

sudo usermod -G newGroup user  # add the user to group newGroup. This updates the /etc/group file

sudo usermod -G group user # this will keep user only in group and will be removed from the other groups



sudo groupmod -g groupname  newGID  # the group will get the newGID 

sudo groupmod -n group newgroupname  # change the group name

 

21240cookie-checkLinux – Users and GroupsLinux – Users and Groups

Related posts

Leave a Comment