User and Groups Flashcards
Show all processes in the current session by the current user
ps -au
switch to the user02 account
su - user02
Switch to root
su -
Diff between su and su -
su: non-login shell (reads .bashrc)
su -: login shells, (reads .bash_profile)
su 4 properties
1) become new user
2) env vars from current user
3) New user password required
4) Privileges of new user
su - sudo recap
1) su -, sudo -i: root env, root login shell
2) su, sudo su: initiating user env, root non login shell
3) sudo -s: initiating user env, initiating user non-login shell
sudo
1) Simply execute command
2) env vars from initiating user
3) password of initiating user
4) Must be configured
configure the sudo command to allow the user01 user to run the usermod command as root
show information about the currently logged-in user
id
Diff between sudo -i and for su -
sudo -i requires initiating user password
su - requires target user password
Diff between sudo -i and sudo -s
First includes target user env variables. Second includes initiating user env variables.
How do you edit /etc/suroders
visudo
What are the benefits of visudo
1) Ensures there is no conflicts in multiuser environments
2) Parses the file before saving
In /etc/sudoers, how do you differentiate normal user from group
Groups start with %
General syntax of an sudoers entry
principal X=(Y:Z) T
X: hosts where this is applicable
Y: Users that X may assume
Z: Group that X may assume
T: Commands that X is permitted to execute when acting as X or Y
Enable full sudo access for user01
user01 ALL=(ALL:ALL) ALL
enable full sudo access for the group01 group
%group01 ALL=(ALL:ALL) ALL
enable users in the games group to run the id command as the operator user,
%games ALL=(operator) /bin/id
allow a user to run commands as another user without entering their password
ansible ALL=(ALL) NOPASSWD: ALL