Processes and Job Control Flashcards
What command should we use to display current running processes?
ps
root@CentOS # ps -ef | tail -10 ec2-user 3750 3736 0 14:40 ? 00:00:00 sshd: ec2-user@pts/0 ec2-user 3751 3750 0 14:40 pts/0 00:00:00 -bash root 3774 2 0 14:45 ? 00:00:00 [kworker/u30:0-events_unbound] root 3775 2 0 14:45 ? 00:00:00 [kworker/0:0-events] root 3779 3751 0 14:48 pts/0 00:00:00 sudo su - root 3781 3779 0 14:48 pts/0 00:00:00 su - root 3782 3781 0 14:48 pts/0 00:00:00 -bash root 3806 2 0 14:52 ? 00:00:00 [kworker/0:1-events] root 3817 3782 0 14:56 pts/0 00:00:00 ps -ef root 3818 3782 0 14:56 pts/0 00:00:00 tail -10
-e
= for all process from all user-f
= for details with all column
How can we see all the processes (not only the ones for the current session) with ps?
ps -ef
What command should we use for seeing the processes in a tree like view?
pstree
root@CentOS # pstree systemd─┬─NetworkManager───2*[{NetworkManager}] ├─2*[agetty] ├─auditd───{auditd} ├─chronyd ├─crond ├─dbus-broker-lau───dbus-broker ├─rngd ├─rsyslogd───2*[{rsyslogd}] ├─sshd───sshd───sshd───bash───sudo───su───bash───pstree ├─systemd───(sd-pam) ├─systemd-journal ├─systemd-logind └─systemd-udevd
What command should we use for an interactive process viewer?
top or htop (htop is not present in some Linux Systems)
Which command should we use to run a command in the background?
command &
How can we kill a process that’s currently running in the foreground?
CTRL+c
How can we suspend a process that’s currently running in the foreground?
CTRL+z
What command should we use to activate a suspended process in the background?
bg
What command should we use to bring a process from the background to the foreground?
fg
What command should we use to kill a process?
kill
What command should we use to list all the current jobs?
jobs
What is the kill signal number?
-15 is the kill signal, -9 is a force kill signal.
root@CentOS # top & [1] 3838 root@CentOS # kill -15 3838 [1]+ Stopped top