Users and Groups Management in Linux

Users and Groups Management in Linux (Redhat, CentOS, Fedora, etc)
Linux OS provides multiple user environment, so more than one users can work simultaneously. User account management is the process of organizing user accounts.Its necessory in a multiuser environment. 
User management
Show all built-In Users

View the file /etc/passwd to know the list of all user accounts in the OS.
[root@server ~#]cat /etc/passwd 
(from the output of the above command , you can view all the users and groups, their home directory, user id, group id, default shell, etc.)


[root@server ~#]id                    (displays userid and group id of currently logged in user)
[root@server ~#]id james -g -n      (displays primary group id of user james
Other parameters can be used with "id" command: 
Parameter                  Description.                   
-g                 Dispalys primary group id
-G                Displays all group id(s) with which the user linked
-n                 Displays the name of the user
-u                 Displays the user id of the specified user


Adding a Linux User
  the command "useradd" is used for creating a linux user, More parameters can be used with this command.
[root@server ~#]useradd james       (this command create a user with username james)
Some useful parameters can be used with useradd command
Parameter                  Description.                   
-c                     Add a description about the user
-d                    Specify the home directory of user
-e                    Define expiry date of user account
-f                    Specify the days which the user account remains active after password expiry                                                      
-g                    Specify the primary groupof user account
-G                   Specify the supplementary groups
-M                   Ensure that user's home directory is not created
-p                   Specify encrypted password
-s                    specify the default shell of user
-n                   specify user id
Usage:[root@server ~#] useradd -s /sbin/nologin james  (create user with nologin shell)


Modifying Linux User Account
Use "usermod" command to modify a linuc user account
Available Parameters
Parameter                  Description.                   
-c            Modify description of user account
-d            Modify home directory (use -m parameter to copy the files in old home   folder to new home folder)
-e            Modify account expiry date
-f            Modify the days which the user account remains active after password expiry
-g            Modify the primary group
-G           Modify the supplementary groups
-p           Modify encrypted password
-s            Modify default shell
-l            Modify the login name of an existing user account
-u           Modify a user-id of a user account
-L           Lock an existing user account
-U           Unlock a locked user account
Eg: [root@server ~#]usermod -c "Accounting section" -s /sbin/nologin acc
(Here the account acc's desctiption and default shell is modified)


Deleting a user account
[root@server ~#]userdel james            (home directory of user will not deleted)
[root@server ~#]userdel -r james          (Home directory will be removed)
(userdel cannot delete a user account if that user is currently logged in, So Kill or logout a user )


To kill and logout a user
[root@server ~#]skill -KILL -u james        (force logout the user- james) 


To STOP/PAUSE a user's activities

[root@server ~#]skill -STOP -u james

To RESUME a stopped user

[root@server ~#]skill -CONT -u james


To kill/logout a user in pts/1 or pts/*

[root@server ~#]skill -KILL -v pts/1

Groups management

View all Groups in OS
[root@server ~#]cat /etc/group



Add a Group
[root@server ~#]groupadd -g 888 guests             (create a group named guests with group-id 888)


Modifying Groups
[root@server ~#]groupmod -g 777 -n members guests          (rename the group name from guests to members and change the group-id to 777)


Deleting a group
[root@server ~#]groupdel members          (Delete a group named "members")

Was this helpfull ?

0 comments:

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons