User management

To check the users listing read the content of /etc/passwd file:

getent passwd | awk -F: '{ print $1}'

User accounts are used not only for actual, human users, but also to run system services and sometimes as owners of system files. This is done because the separation between human users' resources (processes, files, etc.) and the separation between system services' resources requires the same mechanisms under the hood.

Add a user

To add a user to the system execute the following command:

sudo adduser <username> 

To give administrator privileges:

sudo adduser <username> sudo    ## in debian based systems
sudo adduser <username> wheel   ## in RHEL based system

then to elude the need to insert the password each time you need to use super-user privileges, excute the command sudo visudo and change its configuration file:

...

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# Group without password
%nopwd  ALL=NOPASSWD: ALL

Concatenate inside this file the following statememt:

yourUsername ALL=(All) NOPASSWD:ALL

Users system login

Show who is logged into the machine and what they are doing

w

User ownership specification

chown -R admin /opt/script

Groups

To check how many groups are present:

groups

Group management

To add a user into one the above groups, execute:

sudo usermod -a -G <groupName> <username>

While to change the ownership of files/directories:

chgrp -R <groupName> <fileOrDirectory>