17 October, 2020
The group is nothing but a collection of users using which one can reduce the administration task in the o/s environment. Groups are divided into two types.
(a) primary group:- It is a group in which a user initially belongs in this group the user can access the resource with default permissions.
(b) Secondary group:- Apart from primary, if a user has an account in the other group i.e then it is called a secondary group to the user. ---> The group information is maintained by the two database files.
(i) /etc/group: This file maintains group related information.
Syn: <group name>: <password placeholder> : <GID> : <members>
(ii) /etc/gshadow: This file maintains group password related information.
Syn: <group name> : <password placeholder>: <group admin> : <members>
Groupadd: Creates a group
Syn: groupadd [options] group name
r creates a system group
Ex: ---> Let’s create a group called sales #groupadd sales
#usermod –G sales user1 #cat/etc/group/grep sales
---> To add another user to the sales group
#usermod -G sales user2
Syn: id [options] [username]
G shows the GID
n shows the name instead of the ID
u shows the UID
Ex: #id -Gn user1
Groupmod: Modifies the properties of a group
Syn: groupmod [options] groupname
# groupmod –g 888 sales
#groupmod -n <new-name> <Existing name>
Syn: g passwd [options] <arguments> <groupname>
|-a||Add a single user|
|-M||Add multiple users|
|-d||Removing a user from a group|
Ex: #g passwd –a user1 sales #g passwd –M user2, user3, user4 color #g passwd –A user3 color
Groupdel: Deletes a group
If the group has empty (or) secondary users you can delete the group. In case the group maintains a single primary user, then you can’t delete the group account.
Su: Enables you to run a command as another user or switch user accounts.
* Tip:- You can log in to the root user account using the SU command with no parameters. So what is the difference between using su and su the su command mover you into the root user’s account without initializing any of the root’s path or shell variables? When you use su -, everything is initialized as if you were logging in from the console.
When a user is created, everything from the /etc/skel directory is copied to the user’s newly created home directory (usually /home/ <username>).
(a) User-specific files: à After a user is created and his home directory is populated, that user can now customize those files to fit his own personal needs.
(b) Global user configuration: /etc/bashrc Defines functions an aliases /etc/profile sets environment variables /etc/profile.d specifies a directory that contains scripts that are called by the /etc/profile file.
#grep -˅ ˄# /etc/login.defs (or) #cat /etc/login.defs
Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training
Group collaboration is an essential part of any business and for any system administrator who deals with users. Here we look at three key features about file directory permissions;
(a) Setuid: This flag is used to allow multiuser access à For example if you have a script that generates reports for your company, but the script must be run as user1 to succeed, you can set the setuid bit to enable other users to run this command as though they were user1
#touch reporting- script
#chmod 4755 reporting-script
#chmod U+S reporting-script
#ls -l reporting – script
*Tip: à To find all setuid files: # find / -perm 4000
(b) Setgid: This flag is used to allow multi-group access. à which is similar to setuid but set at the group level instead. With this bit set, all users of the group can execute the file instead of just the user who owns it. The setgid bit allows users to collaborate on files.
Step 1: As root, create the directory:
# mkdir /tmp/oracle
Step 2: Create the group0 and add users to it.
# group add sales
# usermod -G sales user1
# usermod -G sales user2
Step 3: Assign the permissions for collaboration:
# chown root: sales /tmp/oracle
#chmod 2770 /tmp/oracle
Step 4: Verify # ls -ld /tmp/oracle
(c) sticky bit: This flag prevents accidental delete by users & groups
Step 1: Set the sticky bit on the /tmp directory:
# chmod 1777 /tmp
Step 2: Verify # ls -ld / tmp
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .