Managing Local Linux Users and Groups

 

Topic : Managing Local Linux Users and Groups



Objective
TO manage Local Linux User and Groups and administer.

Topics
1. User and Groups
2. Gaining Superuser Access
3. Managing User Passwords

1 User and Groups

Objectives
In this session we have learn about Linux User and Group on a Linux system and how they are understood by the computer.

1.1 What is a user ?

A user is a person who utilizes a computer or network service. Every process (running program) on the system runs as a particular user. Every file is owned by a particular user. to access and any changes on that particular file, the user authentication is required. Linux system have provide good service as compare to other operating system, in Linux System Multiple user can logged simultaneously on different terminals. The user associate with a running process determines the files and directories accessible to that process.

How to Add user ?
root@batman:~# adduser codeworld19
Adding user `codeworld19' ...
Adding new group `codeworld19' (1000) ...
Adding new user `codeworld19' (1000) with group `codeworld19' ...
Creating home directory `/home/codeworld19' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for codeworld19
Enter the new value, or press ENTER for the default
 Full Name []: 
 Room Number []: 
 Work Phone []: 
 Home Phone []: 
 Other []: 
Is the information correct? [Y/n] y
To check Information about any user to enter command cat /etc/passwd.
The id command is used to show information about the current logged-in user. Basic information about another user can also be requested by passing in the username of the user as the first argument to the id command for example  
id <user_name>

Example :-
root@batman:~# id
uid=0(root) gid=0(root) groups=0(root)

root@batman:~# id root
uid=0(root) gid=0(root) groups=0(root)

root@batman:~# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
codeworld19:x:1000:1000:,,,:/home/codeworld19:/bin/bash

1.1.1 Explanation of passwd file :-

user and its parameters
username : Password : UID : GID : GECOS : /home/dir :shell
The Parameter are divide by : symbol, in the passwd file seven parameter are present.

1. user name
in the passwd file the first parameter is the name of user. and the length of user name should be in 1 to 32 character in length. in the given example the user name is root.

2. Password
The second parameter of the passwd file is password. but the password hear are not present on the place of password the x character is hold. the actual encrypted password is store in /etc/shadow file. in this example the password section is display as x character.

3. user ID (UID)
The third Parameter of passwd file is user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups.
and the 1000 and above are created by the user when the new user is added. in this example the user ID (UID) is 0.

4. Group ID (GID) 
The forth Parameter of passwd file is Group id.The primary group ID (stored in /etc/group file). in this Example the Group ID (GID) is 0. 

5. User ID info
The fifth Parameter of passwd file is User ID info. the user id show the name or number of user when the user login this field parameter is display. in this example the User ID is root.

6. Home directory
The six Parameter of passwd file is home directory. the sixth parameter is shows the home directory path of user. in this example the the user home directory is /root.

7. Command/shell
The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Please note that it does not have to be a shell.

1.2 What is Group ?

Like users, group have a name and a number(GID). Local group are define in /etc/group

Their are two types of group

1.2.1 Primary groups

- Every user has exactly one primary group.
- The primary group id of user is display in /etc/passwd on third field.
- The the primary group owns new files created by the user.
- The primary group of a newly created user is newly created group with the same name as the user. The user is the only member of this User Private Group(UGP).

1.2.2. Supplementary groups

- The user may have zero or more supplementary groups.
- The user supplementary member of local groups are listed in the field of the group's entry in etc/group.
- The Supplementary group membership is used to help ensure that users have access permissions to files and other resources on the system.

The Parameters of /etc/group file
groupname : password : GID : list of users in the group

Example :-
root@batman:~# cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
codeworld19:x:1000:Batman
Batman:x:1001:
in this example the Batman is the supplementary group of codeworld19



2. Gaining Superuser Access

in this section we have learn about how to get local user to execute the supperuser commands.

The root user
in the linux operating system the root user is by default superuser, a user that has all power over the system. This user has the power to override normal privileges on the file system, and is used to manage and administer the syatem.

Switching users with su command
if you want to swith the user use su command to swith user.
Example :-
codeworld19@batman:~$ su - root
Password: 
root@batman:~# 

if you have swith to other local user and try to execute the supper user command you will get error because you logged user is not supperuser. The solution of this problem to swith root user other wise get superuser permission to the logged user.
codeworld19@batman:~$ tail /var/log/syslog
tail: cannot open '/var/log/syslog' for reading: Permission denied
in this example the codeworld19 user is try to read syslog file but it show error because the codeworld19 is not superuser.


3. Managing User Passwords

The users passaword is store in /etc/shadow file but the password of all user you can't see because is encoded in HASH format. if you want to see this file then follow the following steps :-
codeworld19@batman:~# cat /etc/shadow
root:$6$yr5PkPIzoPdTeMZP$MCx2QADt2sR0D1PbFqb.CV2yO/X4Slt.lxxeH34QulpKfqipEIV8Hh92KjybeJa7N.nysjZ96pk108CDBNFxf1:18192:0:99999:7:::
 
if you want to change password then follow following steps
type command passwd <user_name> type user name which you want to change password.
root@batman:~# passwd hadoop 
New password: 
Retype new password: 
passwd: password updated successfully
root@batman:~# 
 
Next Post Previous Post
No Comment
Add Comment
comment url