Processes Flashcards

1
Q

What are the different process states?

A

R: running
Z: Zombie (including Z, X)
T: Stopped
S: Sleeping (including S, D, K, I)

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

ps aux

A

displays all processes including processes without a controlling terminal

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

ps lax

A

long listing (lax options) provides more detail, and gives faster results by avoiding username lookup

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

display the processes in a tree format

A

ps –forest

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

display the list of jobs for the shell’s session

A

jobs

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

bring a background job to the foreground

A

fg %1

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

displays information about jobs.

A

ps j

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

when running the “ps j” command, one job has the + sign. explain

A

sign indicates that this job is the current default

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

when running the “ps j” command, one job has the - sign. explain

A

The - sign indicates the previous job that will become the default job when the current default job finishes.

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

List the signals available

A

kill -l

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

Common signals

A

1: HUP
3: QUIT
9: KILL
15: TERM (default)
18: CONT
19: STOP

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

List all processes related to user bob

A

pgrep -l -u bob

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

Kill all processes related to user bob

A

pkill -SIGKILL -u bob

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

Find all terminals that bob is logged in from

A

w -u

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

Kill all processes related to a given terminal

A

pkill -SIGKILL -t tty2

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

Which signals are recommended and in which order?

A

SIGTERM
SIGINT
SIGKILL

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

kill multiple processes, based on their command name

A

killall

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

To terminate background job

A

kill -SIGTERM %1

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

What is pts/1

A

1) pseudo-terminals
2) emulated terminals: xterm, Gnome, SSH etc.

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

What is tty/2

A

1) TTY: direct interfaces with the kernel.
2) Traditionally physical terminals,
3) Originally teletypewriters, connected directly to the system.
4) Nowadays, virtual consoles accessed typically through key combinations like Ctrl+Alt+F1 to F6.
5) multi-user.target, rescue.target, emergency.target

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

display the current load average

A

uptime, top

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

Show cpus

A

lscpu

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

lists active currently loaded service units

A

systemctl list-units --type=service

24
Q

lists all currently loaded service units

A
systemctl list-units --type=service --all
25
lists units that are both loaded and active
systemctl
26
View a unit's status with the systemctl
```systemctl status sshd.service```
27
verify whether a service unit is active
systemctl is-active sshd.service
28
verify whether a service unit is enabled to start automatically during system boot
systemctl is-enabled sshd.service
29
verify whether the unit failed during startup,
systemctl is-failed sshd.service
30
list all failed services
`systemctl --failed --type=service`
31
List all socket units, active and inactive
```systemctl list-units --type=socket --all```
32
Start service
systemctl start sshd
33
Stop service
systemctl stop sshd
34
Restart service
systemctl restart sshd
34
Reload service
systemctl reload sshd
35
Start or reload service
systemctl restart-or-reload service
36
displays the hierarchy of dependencies to start a service unit
systemctl list-dependencies sshd.service
37
Mask sendmail service
systemctl mask sendmail.service
38
Unmask a service
systemctl unmask sendmail
39
Configure a service to start at boot
systemctl enable sshd
40
Configure a service to start now and at boot
systemctl enable --now sshd
41
display a list of users that are currently logged in to the system
w
42
Where do you set StrictHostKeyChecking
in ~./ssh/config. or /etc/ssh/ssh_config
43
display a list of users that are currently logged in to the system while showing where user is logged in from
w --from
44
configure your account for passwordless access
```ssh-copy-id -i .ssh/key-with-pass.pub user@remotehost```
45
start ssh-agent
eval $(ssh-agent)
46
What is the use of ssh-agent
cache ssh keys passwords
47
How do you add keys to ssh-agent?
ssh-add
48
Trubleshoot ssh
ssh -v -i key user@remoteserver
49
risks of allowing direct login as the root user
1) root user exists on every Linux system, so attacker needs only to guess the password 2) root user has unrestricted privileges, so its compromise can lead to maximum damage 3) From an auditing perspective, it is hard to track which authorized user logged in as the root user
50
prohibit root user to ssh in
`echo 'PermitRootLogin no' >> /etc/ssh/sshd_config`
51
prevent password-based authentication but to allow private key-based authentication for root
`echo 'PermitRootLogin without-password' >> /etc/ssh/sshd_config`
52
Advantages of disabling password authentication
1) Prevent password-guessing attacks 2) Attacker needs both the passphrase and a c private key.
53
Disable password bassed login
`echo 'PasswordAuthentication no' > /etc/ssh/sshd_config`
54
Enable ssh authentication for user
ensure that the user's ssh key is in ~/.ssh/authorized_keys