Process management Flashcards

1
Q

List processes

A

ps -aux/ ps -ef[H] hierarchy
ps -u- list user processes
first process will get id=1

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

List processes with their state

A
ps -el 
states:
S -sleep
T- terminated (ctrl+z)
X- dead (should not be seen)
Z- zombie
I -idle
R -running
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Set priority of processes

A

nice [from -20 to 19]
nice -n 10 ping google.com
(The higher the number the higher the priority)

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

Alter priority of running process

A

renice -n -15 2345 [PID]

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

Display processes in real time

A
top
keys:
k-kill process
r-renice process
Sorting:
M- %MEM
N- PID
P- %CPU
T- TIME+
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Look for process based on name

A

pgrep -a ssh- lists pids and service paths
pgrep httpd only lists pids related to httpd
pgrep -u- list pids of current user

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

Check how long takes a process to run

A

time ping -n 10 google.com

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

Kill a process based on name

A

pkill ping

pkill -x httpd -to kill processes match exactly to httpd

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

List open files

A

lsof

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

Location in pseudo FS related to cpu and memory

A

cat /proc/cpuinfo

cat /proc/meminfo

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

Tell how long the system has been running

A

uptime (1m, 5m, 15 m)

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

Report system activity info

A

sar -u for CPU utilization
sar -A -report for all devices
sar -b -IO stat
sar -d -for each block device

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

Configure kernel params in runtime

A

sysctl -a (display all values available)

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

Kill process

A

kill -9 1234 [pid]
kill 1234
kill -l- get the list of signal to be passed to kill command

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

Amount of RAM available+swap

A

free -m

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

Kill all processes based on name

A

killall httpd

killall -s 9 httpd

17
Q

Run a command at specified intervals

A

watch date

watch -n 10 date

18
Q

Terminal window managers that allows to run commands in an isolated session

A
  1. screen
    1.1. screen
    1.2. watch date
    1.3. ctlr+a d -detach from the session
    1.4. screen -r 2 [session screen id] -to re-attach
    screen -ls -to show screen session
  2. tmux
    2.1. ssh kenny@1.2.3.4 …
    run commands
    2.2. ctrl+b d-detach from tmux session
    2.3. tmux ls - list sessions
    2.4 tmux attach-session -t 0-
    attach back to the session 0
19
Q

nohup

A
  1. nohup ping google.com &
  2. jobs -to see processes running on the background
  3. tail -f nohup.out
  4. fg 1 (job id) - back the job to fg
  5. ctrl+z - to stop the job
  6. bg % 1 (job id)-force to send the job to the background again
  7. jobs -l => the nohup ping google.com is running again