MANAGE USERS AND GROUPS IN REDHAT


MANAGE USERS AND GROUPS

id            -              gives the info about the user u logged in.
+++++++++++++++++
uid=0(root) gid=0(root) groups=0(root)
++++++++++++++++
Root user always having user id 0
1-200 user id – system users for specific redhat process’s /for redhat file owned process’s.
201-999 - system users for specific redhat process’s but they won’t files on the system.
Ex: apache (/usr/sbin/nologin)
From 1000 : id’s will be assigned when we create new user accounts.
You can see users in /etc/passwd
neelu:x:1001:1001::/home/neelu:/bin/bash
ntp:x:38:38::/etc/ntp:/sbin/nologin  ##user can’t ssh because /sbin/nologin
<user_name>:<pwd linked to some where /etc/shadow>:uid:gid:<arbitrary field,user defined>:<home_dire>:<shell to use>
Each user exactly have 1 primary group. Whenever user created in the system primary group is same as user name by default.
Whenever user creates a new file/directory, group owner of that file/dir is that the primary group of that user.
User belongs to supplementary groups.
To see groups
                groups  <root> <username>
                cat /etc/group
                +++++++++++++++++++++++
                [root@cloudpro2 home]# groups test
test : test
[root@cloudpro2 home]# groups root
root : root
+++++++++++++++++++++++
Password file located in /etc/shadow. it includes password hash(encrypted password) for each user.
Create a new user
                useradd <flags> <username>
to check different flags usage
                useradd –help
                man useradd
                info useradd
for ex: useradd –M neelu
it doesn’t create user home directory still user can ssh because he has permissions for /bin/bash
FILES (default ones)
       /etc/passwd
           User account information.

       /etc/shadow
           Secure user account information.

       /etc/group
           Group account information.

       /etc/gshadow
           Secure group account information.

       /etc/default/useradd
           Default values for account creation.

       /etc/skel/
           Directory containing default files (for all users those are newly created).

       /etc/login.defs
           Shadow password suite configuration.


In users home directory there are specific bash configurations.
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  instruct( file in /etc/skel –common for every newly user created)
To create/update password for user
                passwd  <user_name>
password hashes are changed when you are changing passwords for users and  When you lock user then !<password hash> will be created in /etc/shadow file.
To modify user / certain things like chage primary group(g), add/append user to supplementary groups(G,a (a has to be used with G)), lock/unlock user(L,U), add commants/arbitrary fields(c), change home directory(d) etc..
                usermod <flags mentioned above>  <specify value/path/string etc>  <user>
usermod -aG sg0 neelu
some useful commands
                userdel                 it does not remove home directory
                userdel –r <username>                                removes home directory
                groupdel
for help
                userdel –help
                groupdel –help
                info groupdel     which also displays the associated files


Comments

Popular posts from this blog

Power Broker

zabbix-introduction

variables in shell scripting