20250407 Flashcards

1
Q

What does the su command stand for?

A

Substitute User (or Switch User).

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

What happens when you run su without a username?

A

It switches to the root user (requires the root password).

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

How do you switch to a different user using su?

A

su username (e.g., su alice).

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

How do you execute a single command as another user using su?

A

su -c "command" username (e.g., su -c "ls /root" root).

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

What does the - (dash) option do in su -?

A

Starts a full login shell with the target user’s environment.

it switches to the root user and loads the root user’s full environment, as if you had logged in directly as root from a login screen or via SSH.

You can do su - fashouri the same as ssh fashouri@<same_machine>

A login shell is a session where your user environment is fully set up. That includes:

The user’s PATH settings (so commands work properly)

Environment variables (like HOME, USER, etc.)

Shell configs (~/.bash_profile, ~/.profile, etc.)

When you run su without the dash (-), it switches the user but keeps your original environment, which can cause confusing behavior.

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

What’s the main difference between su and sudo?

A

su asks for the other user’s password, sudo asks for your own.

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

Where are sudo permissions managed?

A

In the /etc/sudoers file.

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

Which command is safer in multi-user environments?

A

sudo, because it allows fine-grained permission control.

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

Why might sudo not work for a command?

A

You may not be in the sudoers list or lack permission for that command.

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