Usergroup
Usergroup
02/28/24
02/28/24
02/28/24
02/28/24
To be able to log in as the newly created user,
you need to set the user password. You can
do that by running the passwd command
followed by the username:
02/28/24
02/28/24
Login in into ae
02/28/24
User groups
groups are collections of users
02/28/24
Linux Primary Groups
02/28/24
You can find a user’s primary group ID by
viewing the contents of the your system’s
/etc/passwd file.
cat /etc/passwd
02/28/24
Secondary
Once a user has been created with their primary
group, they can be added to secondary
groups. Linux system users can have a
maximum of 15 secondary groups. A Linux
system’s groups are stored in the /etc/group
file.
02/28/24
To add a user to a secondary group use the
example command. Replace
second_example_group with the group name
and example_user with the name of the user
to add to the group.
02/28/24
You can also add a user to multiple groups. The example
command adds the user example_user to the groups
second_example_group, third_example_group, and
fourth_example_group. The -a and -G options ensure that the
user is not removed from any group that the user already
belongs to.
sudo usermod -a -G
second_example_group,third_example_group,fourth_example
_gro
02/28/24
Linux File Ownership
Every Linux system have three types of owner:
1.User: A user is the one who created the file.
By default, whosoever, creates the file
becomes the owner of the file. A user can
create, delete, or modify the file.
02/28/24
1.Group: A group can contain multiple users.
All the users belonging to a group have same
access permission for a file.
2.Other: Any one who has access to the file
other than user and group comes in the
category of other. Other has neither created
the file nor is a group member.
02/28/24
User accounts are of the following main types:
the superuser, system users, and regular
users.
02/28/24
The system user accounts are used by processes
that provide supporting services. These
processes, or daemons, usually do not need to
run as the superuser. They are assigned non-
privileged accounts to secure their files and
other resources from each other and from
regular users on the system. Users do not
interactively log in with a system user account.
02/28/24
Most users have regular user accounts for their
day-to-day work. Like system users, regular
users have limited access to the system.
02/28/24
Use the id command to show information about
the currently logged-in user:
02/28/24
02/28/24
A group is a collection of users that need to
share access to files and other system
resources. Groups can grant access to files to a
set of users instead of to a single user.
02/28/24
Like users, groups have group names for easier
recognition. Internally, the system distinguishes
groups by the unique identification number,
the group ID or GID, which is assigned to them.
The mapping of group names to GIDs is defined
in identity management databases of group
account information. By default, systems use
the /etc/group file to store information about
local groups.
02/28/24
Each line in the /etc/group file contains
information about one group. Each group
entry is divided into four colon-separated
fields.
02/28/24
02/28/24
The Superuser
02/28/24
Users and groups can be locally managed
in /etc/psswd or /etc/group
02/28/24
02/28/24
If you want to create a group with a specific
group ID (GID), use the --gid or -g option:
02/28/24
02/28/24
Change the group ID
You can change the group ID of any group with
the groupmod command and the --gid or -g
option:
02/28/24
Rename a group
You can rename a group using groupmod with
the --new-name or -n option:
02/28/24
02/28/24
For security reasons, in some cases system
administrators configure the root user not to
have a valid password. Thus, users cannot log
in to the system as root directly with a
password. Moreover, you cannot use su to get
an interactive shell. In this case, you can use
the sudo command to get root access.
02/28/24
Unlike the su command, sudo normally requires
users to enter their own password for
authentication, not the password of the user
account that they are trying to access. That is,
users who use the sudo command to run
commands as root do not need to know the
root password. Instead, they use their own
passwords to authenticate access.
02/28/24
02/28/24
view the owner of a file
Use the ls -l command to view the owner of a
file. Use the ls -ld command to view the owner
of a directory, rather than the contents of that
directory. In the following output, the third
column shows the username.
02/28/24
02/28/24
processes in the current shell
Use the ps command -a option to view all
processes with a terminal. Use the ps
command -u option to view the user that is
associated with a process. In the following
output, the first column shows the username.
02/28/24
02/28/24
02/28/24