Linux Unit 4
Linux Unit 4
Linux user
A user or account of a system is uniquely identified by a numerical number
called the UID (unique identification number). There are two types of users –
the root or super user and normal users. A root or super user can access all the
files, while the normal user has limited access to files. A super user can add,
delete and modify a user account. The full account information is stored in
the /etc/passwd file and a hash password is stored in the file /etc/shadow.
Some operations on a user account are discussed below.
[root@localhostbhargab]# useraddanirban
[root@localhostbhargab]# passwdanirban
Changing password foruser anirban.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
The system automatically assigns a UID, creates the home directory
(/home/<username>) and sets the default shell to /bin/bash.
Creating a user with the UID: You can create a user with a custom UID with the –
u option, as follows:
Linux group
Linux group is a mechanism to organise a collection of users. Like the user ID, each
group is also associated with a unique ID called the GID (group ID). There are two types
of groups – a primary group and a supplementary group. Each user is a member of a
primary group and of zero or ‘more than zero’ supplementary groups. The group
information is stored in /etc/group and the respective passwords are stored in
the /etc/gshadow file. Some operations such as creating, deleting and modifying on a
group are discussed below.
Creating a group with default settings: To add a new group with default settings, run
the groupadd command as a root user, as shown below:
or from a terminal:
The sudo group exists in 11.10 and earlier, it's just not used (by default).
The admin group doesn't exist on a freshly installed 12.04 system, but it continues to exist
(and its members continue to have administrative abilities) on Ubuntu 12.04 systems
upgraded from previous releases.
Therefore, here are some reasonable guidelines for how to make a user an administrator in
Ubuntu:
If you're running Ubuntu 11.10 or earlier, just put the user in the admin group.
If you're running Ubuntu 12.04 LTS (or later), put the user in the sudo group, and if
the admin group exists, put the user there too.
are running Ubuntu Server, or some other Ubuntu system with no GUI, or
just prefer to use command-line utilities, or
are running some weird desktop environment that doesn't come with a graphical utility to
manage users and groups
...then you can manage users and groups from the command-line.
The recommended utility for adding a user from the command-line (in Ubuntu, and also in
Debian and other Debian-based OSes) is adduser. The simplest way to use it is just to run:
sudo adduser --add_extra_groups username
You may be prompted for your password first (that's how sudo works).
Then you're asked a series of questions. Besides their real name and password, if you don't
have an answer to any of the questions, just press Enter.
The user is made a member of the default groups for user accounts that do represent real
human beings, but do not have administrative powers.
Click here to read as text.
To make a user an administrator from the command-line, just add them to the appropriate
group. usermod is an excellent utility for this purpose. The -G flag means you're specifying one
or more new groups, and the -a flag means you're adding these to whatever groups the user is
already a member of, rather than replacing the old list of groups with a new one.
Depending on what version of Ubuntu you're running (as detailed above), use one or both of
these commands:
You can edit users by going under System Settings (either search for it in the Dash, or select it
as the first entry under the power cog) and selecting User Accounts.
Alternatively, you may search the Ubuntu Software Center or use apt-get to install the gnome-
system-tools package, then run users-admin afterwards to get to working with groups (source).
Introduction to SSSD
7.1.1. How SSSD Works
The System Security Services Daemon (SSSD) is a system service to access remote
directories and authentication mechanisms. It connects a local system (an
SSSD client) to an external back-end system (a provider). This provides the SSSD
client with access to identity and authentication remote services using an SSSD
provider. For example, these remote services include: an LDAP directory, an
Identity Management (IdM) or Active Directory (AD) domain, or a Kerberos realm.
Users on the local system are then able to authenticate using the user accounts
stored in the external back-end system.
SSSD does not create user accounts on the local system. Instead, it uses the
identities from the external data store and lets the users access the local system.
SSSD can also provide caches for several system services, such as Name Service
Switch (NSS) or Pluggable Authentication Modules (PAM).
Offline authentication
SSSD optionally keeps a cache of user identities and credentials retrieved
from remote services. In this setup, users can successfully authenticate to
resources even if the remote server or the SSSD client are offline.
Remote users often have multiple user accounts. For example, to connect to
a virtual private network (VPN), remote users have one account for the local
system and another account for the VPN system.
SSSD works with NSS as a provider services for several types of NSS maps:
Passwords (passwd)
Groups (groups)
Netgroups (netgroups)
Services (services)
2. The services map is not enabled by default when SSSD is enabled with authconfig.
To include that map, open the nsswitch.conf file and add the sss module to
the services map:
3. ~]# vim /etc/nsswitch.conf
4.
5. ...
...
1. Open the sssd.conf file.
2. Make sure that NSS is listed as one of the services that works with SSSD.
3. [sssd]
4. config_file_version = 2
5. reconnection_retries = 3
6. sbus_timeout = 30
9. filter_groups = root
11. reconnection_retries = 3
entry_cache_nowait_percentage = 75
Advantages of PAM
o auth — This module interface authenticates use. For example, it requests and
verifies the validity of a password.
o account — This module interface verifies that access is allowed. For example, it
may check if a user account has expired or if a user is allowed to log in at a
particular time of day.
Control Flag
All PAM modules generate a success or failure result when called. Control flags tell PAM
what do with the result. Modules can be stacked in a particular order, and the control
flags determine how important the success or failure of a particular module is to the
overall goal of authenticating the user to the service.
Module Name
The module name provides PAM with the name of the pluggable module containing the
specified module interface. In older versions of Red Hat Enterprise Linux, the full path to
the module was provided in the PAM configuration file. However, since the advent
of multilib systems, which store 64-bit PAM modules in
the /lib64/security/ directory,
Module Arguments
PAM uses arguments to pass information to a pluggable module during authentication
for some modules.
1. Ownership
2. Permission
User
Group
Other
Any other user who has access to a file. This person has
neither created the file, nor he belongs to a usergroup
who could own the file. Practically, it means everybody
else. Hence, when you set the permission for others, it is
also referred as set permissions for the world.
Permissions
The first part of the code is 'rw-'. This suggests that the
owner 'Home' can:
The second part is 'rw-'. It for the user group 'Home' and
group-members can:
The third part is for the world which means any user. It
says 'r--'. This means the user can only:
1. Absolute mode
2. Symbolic mode
Absolute(Numeric) Mode
1 Execute --x
2 Write -w-
4 Read r--
Symbolic Mode
Operato Description
r
User Denotations
u user/owner
g group
o other
a all
What is ACL ?
Access control list (ACL) provides an additional, more flexible permission
mechanism for file systems. It is designed to assist with UNIX file
permissions. ACL allows you to give permissions for any user or group to
any disc resource.
Use of ACL :
Think of a scenario in which a particular user is not a member of group
created by you but still you want to give some read or write access, how
can you do it without making user a member of group, here comes in
picture Access Control Lists, ACL helps us to do this trick.
Basically, ACLs are used to make a flexible permission mechanism in Linux.
From Linux man pages, ACLs are used to define more fine-grained
discretionary access rights for files and directories.
setfacl and getfacl are used for setting up ACL and showing ACL
respectively.
For example :
getfacl test/declarations.h
Output:
# file: test/declarations.h
# owner: mandeep
# group: mandeep
user::rw-
group::rw-
other::r--
List of commands for setting up ACL :
1) To add permission for user
setfacl -m "u:user:permissions" /path/to/file
3) To allow all files or directories to inherit ACL entries from the directory
it is within
setfacl -dm "entry" /path/to/dir
Example :
setfacl -m u:mandeep:r-x test/declarations.h
See below image for output :
change permissions
If you compare output of getfacl command before and after using setfacl
command with -b option, you can observe that there is no particular entry
for user mandeep in later output.
You can also check if there are any extra permissions set through ACL
using ls command.
check set acl with ls
Observe the first command output in image, there is extra “+” sign after
the permissions like -rw-rwxr–+, this indicates there are extra ACL
permissions set which you can check by getfacl command.
Using Default ACL :
The default ACL is a specific type of permission assigned to a directory,
that doesn’t change the permissions of the directory itself, but makes so
that specified ACLs are set by default on all the files created inside of it.
Let’s demonstrate it : first we are going to create a directory and assign
default ACL to it by using the -d option:
$ mkdir test && setfacl -d -m u:dummy:rw test