How to Add Remove Rename a User and User Group in Linux
20:54
In this blog we are going to see the see Let's jump into the List of Commands. The user name is efxx Top 6 command-line based browsers read more...
Note: Basic difference "adduser, useradd". "adduser" will create home directory and add skeleton(directory where you can place the default files and all the folders) files to that directory where "useradd" wont create any home directory and files !
How to Add or Remove a User and User Group in Linux
- How to Add, Remove and Modify Users in Linux
- Create and modify a Group in Linux
- Check list of user Groups in Linux
Note: Basic difference "adduser, useradd". "adduser" will create home directory and add skeleton(directory where you can place the default files and all the folders) files to that directory where "useradd" wont create any home directory and files !
Check list of all Users and Access Linux
List of users in Linux
$ cut -d: -f1 /etc/passwd
or
$ awk -F: '{ print $1," \t" $NF," \t",$(NF -1)}' /etc/passwd|sed 's#$#\n------------------------------------------------------------------------#g'
List of users has Root access
$ awk -F: '{ print $1," \t" $NF," \t",$(NF -1)}' /etc/passwd|grep "/bin/bash"
List of user don't have login access
$ awk -F: '{ print $1," \t" $NF," \t",$(NF -1)}' /etc/passwd|grep "nologin"
How to Add, Remove and Modify Users in Linux
$ sudo adduser newusername or $ sudo useradd -m newusernameAdd user without password
$ sudo adduser --disabled-password --gecos "" USERNAMERemove password from existing user account and disable it untill add new password from sudo user
$ passwd -d linuxtechiRename user
$ sudo usermod -l new-user-name old-user-nameView users UID using command
$ id -u newusernamePID for all the groups for efx
$ id efxTo change UID of user efxx
$ usermod -u [New-user-id] [username]View all PID (process id) for programs
$ ps -u efxxAdd user in sudo user
$ sudo usermod -aG sudo usernameKill the process other user process
$ pkill -u username 1532Kill all the process owned by the user
$ pkill -9 -u usernameDelete a User in Linux
$ sudo deluser username or $ sudo userdel usernameDelete user with files
$ sudo userdel -r usernameChange user password
$ passwd username
Create and modify a Group in Linux
Create a new group (view the group file /etc/groups)
$ sudo addgroup groupname or $ sudo groupadd groupnameAssign a password to group
$ sudo gpasswd groupnameView all the group list
$ getent groupDelete the group with group name
$ sudo delgroup groupname or $ sudo groupdel groupname
Check list of user Groups in Linux
To check a user group
$ groups efxxCheck owner groups
$ groupsAdd a User to a Group in Linux(postgress service to sudo group)
$ usermod -aG postgres efxxRemove a User from a Group in Linux
$ gpasswd -d efxx postgresRemove user form specific group
$ sudo deluser efxx postgresMust check related posts...