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
Q

lists units that are both loaded and active

A

systemctl

26
Q

View a unit’s status with the systemctl

A
systemctl status sshd.service
27
Q

verify whether a service unit is active

A

systemctl is-active sshd.service

28
Q

verify whether a service unit is enabled to start automatically during system boot

A

systemctl is-enabled sshd.service

29
Q

verify whether the unit failed during startup,

A

systemctl is-failed sshd.service

30
Q

list all failed services

A

systemctl --failed --type=service

31
Q

List all socket units, active and inactive

A
systemctl list-units --type=socket --all
32
Q

Start service

A

systemctl start sshd

33
Q

Stop service

A

systemctl stop sshd

34
Q

Restart service

A

systemctl restart sshd

34
Q

Reload service

A

systemctl reload sshd

35
Q

Start or reload service

A

systemctl restart-or-reload service

36
Q

displays the hierarchy of dependencies to start a service unit

A

systemctl list-dependencies sshd.service

37
Q

Mask sendmail service

A

systemctl mask sendmail.service

38
Q

Unmask a service

A

systemctl unmask sendmail

39
Q

Configure a service to start at boot

A

systemctl enable sshd

40
Q

Configure a service to start now and at boot

A

systemctl enable –now sshd

41
Q

display a list of users that are currently logged in to the system

A

w

42
Q

Where do you set StrictHostKeyChecking

A

in ~./ssh/config. or /etc/ssh/ssh_config

43
Q

display a list of users that are currently logged in to the system while showing where user is logged in from

A

w –from

44
Q

configure your account for passwordless access

A
ssh-copy-id -i .ssh/key-with-pass.pub user@remotehost
45
Q

start ssh-agent

A

eval $(ssh-agent)

46
Q

What is the use of ssh-agent

A

cache ssh keys passwords

47
Q

How do you add keys to ssh-agent?

A

ssh-add

48
Q

Trubleshoot ssh

A

ssh -v -i key user@remoteserver

49
Q

risks of allowing direct login as the root user

A

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
Q

prohibit root user to ssh in

A

echo 'PermitRootLogin no' >> /etc/ssh/sshd_config

51
Q

prevent password-based authentication but to allow private key-based authentication for root

A

echo 'PermitRootLogin without-password' >> /etc/ssh/sshd_config

52
Q

Advantages of disabling password authentication

A

1) Prevent password-guessing attacks

2) Attacker needs both the passphrase and a c private key.

53
Q

Disable password bassed login

A

echo 'PasswordAuthentication no' > /etc/ssh/sshd_config

54
Q

Enable ssh authentication for user

A

ensure that the user’s ssh key is in ~/.ssh/authorized_keys