User and Groups Flashcards

1
Q

Show all processes in the current session by the current user

A

ps -au

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

switch to the user02 account

A

su - user02

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Switch to root

A

su -

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Diff between su and su -

A

su: non-login shell (reads .bashrc)

su -: login shells, (reads .bash_profile)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

su 4 properties

A

1) become new user
2) env vars from current user
3) New user password required
4) Privileges of new user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

su - sudo recap

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

sudo

A

1) Simply execute command
2) env vars from initiating user
3) password of initiating user
4) Must be configured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

configure the sudo command to allow the user01 user to run the usermod command as root

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

show information about the currently logged-in user

A

id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Diff between sudo -i and for su -

A

sudo -i requires initiating user password
su - requires target user password

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Diff between sudo -i and sudo -s

A

First includes target user env variables. Second includes initiating user env variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you edit /etc/suroders

A

visudo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the benefits of visudo

A

1) Ensures there is no conflicts in multiuser environments
2) Parses the file before saving

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In /etc/sudoers, how do you differentiate normal user from group

A

Groups start with %

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

General syntax of an sudoers entry

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Enable full sudo access for user01

A

user01 ALL=(ALL:ALL) ALL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

enable full sudo access for the group01 group

A
%group01 ALL=(ALL:ALL) ALL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

enable users in the games group to run the id command as the operator user,

A

%games ALL=(operator) /bin/id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

allow a user to run commands as another user without entering their password

A

ansible ALL=(ALL) NOPASSWD: ALL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

sudo su

A

start a root non-login shell .
User must be sudoer
No root password required

21
Q

Similarity between su and sudo su

A

Both result in non-login shells

22
Q

sudo su vs sudo s

A

sudo s: 1) user env vars, 2) SHELL from user,

sudo su: 1) user env VARS, 2) SHELL from root

23
Q

Where do you set range of valid UID numbers and default password aging rules

A

/etc/login.defs

24
Q

usermod -aG user1 group3

A

add group3 to user1 list of supplementary groups

25
Q

usermod -c

A

change the comment in the user profile

26
Q

usermod -L

A

locka user’s password. preventing him from loggin in.

27
Q

usermod -G

A

add a comma separated list of groups as supplementary groups to a user

28
Q

usermod -d

A

change user home dir

29
Q

usermod -s

A

change user shell

30
Q

usermod -U

A

unlock a user

31
Q

Delete user user01 without deleting hom dir

A

userdel user01

32
Q

Delete user user01 along with home dir

A

userdel -r user01

33
Q

find all unowned files and directories

A
find / -nouser -o -nogroup
34
Q

Create user with specified uid

A

useradd -u 1000 user02

35
Q

Add group with specific id

A

groupadd -g 10000 group01

36
Q

Create a system group

A

groupadd -r group02

37
Q

Change the name of group

A

groupmod -n group0022 group02

38
Q

Change the group id of a group

A

groupmod -g 20000 group0022

39
Q

Where are password stored

A

/etc/shadow

40
Q

What does chage stand for?

A

change age

41
Q

What are password aging parameters?

A

-d: last change date
-m: min days
-M: max days
-W: warn days
-I: inactive days
-E: expiration day
-l: display aging policy

Every moon day, Max warns Isaac: End laziness.

42
Q

Print date in format 2022-03-10

A

date +%F

43
Q

You want a user to change password immediately. what do you do?

A

chage -d 0 cloudadmin10

44
Q

set the default maximum and minimum age of the password respectively.

A

PASS_MAX_DAYS and PASS_MIN_DAYS

45
Q

sets the default warning period of the password

A

PASS_WARN_AGE

46
Q

lock and expire the account from a certain date

A

usermod -L -e 2022-08-14 cloudadmin10

47
Q

How do you prevent a user with valid account to log in

A
usermod -s /sbin/nologin newapp

Used for service accounts

48
Q

What is typical content of .bashrc

A

alias
functions
shell prompt appearance,
settings for command-line tools

49
Q

What is typical content of .bashrc_profile

A

user’s environment (PATH, EDITOR, etc.)
.bash_profile sometimes sources .bashrc