Howto add User to Group on Linux Redhat RHEL CentOS Fedora

Howto add User to Group on Linux Redhat RHEL CentOS Fedora

commands

1. Create group and add new user to that group

[root@localhost /]# groupadd webgroups
[root@localhost /]# useradd -G webgroups kevinuser
[root@localhost /]# cat /etc/group | grep kevinuser
webgroups:x:505:kevinuser

2. Add existing user to a Group

[root@localhost /]# usermod -g webgroups kevin.ngo

NOTE:

/etc/passwd – Contains user account

[root@localhost /]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
saslauth:x:498:76:”Saslauthd user”:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
pulse:x:497:496:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
user:x:500:500:user:/home/user:/bin/bash
kevin.ngo:x:502:505::/home/kevin.ngo:/bin/bash
clam:x:496:493:Clam Anti Virus Checker:/var/lib/clamav:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
kevin2:x:503:504::/home/kevin2:/bin/bash
kevinuser:x:504:506::/home/kevinuser:/bin/bash
[root@localhost /]#

/etc/shadow  – Contains the password information with encrypted format.

[root@localhost /]# cat /etc/shadow
root:$1$fHjBumL6$f3NOlULGExdkFd5DP5vJb/:15790:0:99999:7:::
bin:*:15628:0:99999:7:::
daemon:*:15628:0:99999:7:::
adm:*:15628:0:99999:7:::
lp:*:15628:0:99999:7:::
sync:*:15628:0:99999:7:::
shutdown:*:15628:0:99999:7:::
halt:*:15628:0:99999:7:::
mail:*:15628:0:99999:7:::
uucp:*:15628:0:99999:7:::
operator:*:15628:0:99999:7:::
games:*:15628:0:99999:7:::
gopher:*:15628:0:99999:7:::
ftp:*:15628:0:99999:7:::
nobody:*:15628:0:99999:7:::
dbus:!!:15790::::::
usbmuxd:!!:15790::::::
vcsa:!!:15790::::::
rtkit:!!:15790::::::
avahi-autoipd:!!:15790::::::
abrt:!!:15790::::::
haldaemon:!!:15790::::::
gdm:!!:15790::::::
saslauth:!!:15790::::::
postfix:!!:15790::::::
ntp:!!:15790::::::
apache:!!:15790::::::
pulse:!!:15790::::::
sshd:!!:15790::::::
tcpdump:!!:15790::::::
user:$1$fHjBumL6$f3NOlULGExdkFd5DP5vJb/:15790:0:99999:7:::
kevin.ngo:!!:15816:0:99999:7:::
clam:!!:15845::::::
mysql:!!:15845::::::
kevin2:$1$THqEmcH1$8tyKOi/dWZkveTizZrNOD/:15856:0:99999:7:::
kevinuser:!!:15887:0:99999:7:::
[root@localhost /]#

/etc/group  – Defines the groups on Linux.

[root@localhost /]# cat /etc/group
root:x:0:
bin:x:1:bin,daemon
daemon:x:2:bin,daemon
sys:x:3:bin,adm
adm:x:4:adm,daemon
tty:x:5:
disk:x:6:
lp:x:7:daemon
mem:x:8:
kmem:x:9:
wheel:x:10:
mail:x:12:mail,postfix
uucp:x:14:
man:x:15:
games:x:20:
gopher:x:30:
video:x:39:
dip:x:40:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
dbus:x:81:
usbmuxd:x:113:
utmp:x:22:
utempter:x:35:
desktop_admin_r:x:499:
desktop_user_r:x:498:
floppy:x:19:
vcsa:x:69:
rtkit:x:497:
avahi-autoipd:x:170:
abrt:x:173:
cdrom:x:11:
tape:x:33:
dialout:x:18:
haldaemon:x:68:haldaemon
gdm:x:42:
saslauth:x:76:
postdrop:x:90:
postfix:x:89:
ntp:x:38:
apache:x:48:
wbpriv:x:88:
pulse:x:496:
pulse-access:x:495:
fuse:x:494:
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
sshd:x:74:
tcpdump:x:72:
slocate:x:21:
user:x:500:
kevin.ngo:x:502:
vboxusers:x:503:kevin.ngo,root
clam:x:493:
mysql:x:27:
kevin2:x:504:
webgroups:x:505:kevinuser
kevinuser:x:506:

That’s all. Thanks for using IThelpblog.com.

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>