User and Group management command

  • Create a new user account
[root@server ~]# useradd uddika
[root@server ~]# passwd uddika
Changing password for user uddika.
New UNIX password: ******
Retype new UNIX password: *****
passwd: all authentication tokens updated successfully.

  • Multisession Login(Users can login same time)
Alt+F2
Then give a username and password

Count the login users
[root@server ~]# who

  • Changing your own password as a normal user
Login the account
[uddika@server ~]$ passwd
Changing password for user uddika.
Changing password for uddika.
(current) UNIX password: ******
New UNIX password: *******
Retype new UNIX password: *******
passwd: all authentication tokens updated successfully.

  • How to change the password properties of a user
View the current password properties
[uddika@server ~]$ chage -l uddika

Change the current password properties
[root@server ~]# chage uddika

  • The things that happened automatically once you create a user account
Every user will get a private home folder
[root@server ~]# ls -l /home

Every user will get a private group account
Username = Uddika Private Group name = Uddika

Every user will get a user id (uid) and group id (gid)
[root@server ~]# id Uddika

The user account database and the group account database will be automatically updated

  • User account database
View the user account database
[root@server ~]# cat /etc/passwd |more

Display last 10 records
[root@server ~]# tail /etc/passwd

Display last 5 records
[root@server ~]# tail –n5 /etc/passwd

  • Group account database
View the group account database
[root@server ~]# cat /etc/group |more
[root@server ~]# tail /etc/group

  • How to delete user account
View the current account
[root@server ~]# tail /etc/passwd

Delete with home folder
[root@server ~]# userdel –r username

Delete without home folder
[root@server ~]# userdel username

Verify the account
User account - [root@server ~]# tail /etc/group
Home folder - [root@server ~]# ls -l /home

  • Deleting Groups
View current groups
[root@server ~]# tail /etc/group

Delete the group
[root@server ~]# groupdel groupname

Verify group
[root@server ~]# tail /etc/group

------------------------------------------------------------------------------------------



0 comments: