103.5 Create, monitor and kill processes Flashcards
What is the command that kills processes based on a name provided as an argument?
#killalll Example: #sudo killall httpd
How do you kill a process based on its name and not process ID, only matching the name and nothing else?
pkill -x
How do you kill a process based on its name and not process ID?
sudo pkill
How do you kill a process gracefully?
- Find the PID with pgrep or top
- Issue #sudo kill
(kill alone will use -15)
How do you kill a process ungracefully or forcibly?
Find the process ID #kill -9
What command will list all the Signals that can be passed on to the kill command?
kill -l
How are stale PID files created?
When a process is killed ungracefully with SIGKILL (9).
What is the difference between SIGTERM(15) and SIGKILL(9)?
KILL 15 kills a process gracefully (SIGTERM)
KILL 9 kills it suddenly and ungracefully (SIGKILL)
How do you kill a process within #top?
Determine the PID from the list
Press the K key
Enter the PID
What is PID 1 called? What are the other processes that emerge from it called?
PID 1 : parent process
PID X: child processes
What command is used to display a listing of jobs that are in the background?
jobs
How do you send a command to the background?
You type the command and add the symbol at the end.
Also you can type at the end.
What command do you use to bring a command that was running in the background to the foreground?
fg and the job id (from the #jobs -l command)
What is the command called that when preceding a command, the command receives a signal 1 (NOHUP) so that should a terminal window close, the process will still run as long as the login session is not terminated.
nohup
What happens if you log out from a session and have commands running in the background still?
The commands get cancelled.
How do you exit or close a detached tmux session?
exit
How do you re-attach to a currently running session open with tmux?
#tmux ls Get the session number #tmux attach-session -t session#
How do you see how many sessions you have running with tmux?
tmux ls
How do you see how many screen sessions you have running?
screen -ls
How do you detach from a running tmux session to an original session?
Ctrl+b d
What does the screen command do?
It is a terminal window manager that allows you to run commands in an isolated session.
How do you create a new shell (other than the screen command)?
tmux
How do you exit or close a detached screen session?
exit (within the detached screen session)
How do you go back from an original session to a detached screen created with the command screen?
screen -r session# (#before the pts)
How do you go back the original session to an already created session made with the command screen?
screen -r
How do you go back from an isolated session created with the screen command to the original session?
Ctrl+a d
How do you start an isolated session with the screen command?
Using the screen command itself.
Which is the command that runs a command at a specified interval to monitor a command’s output?
watch
How do you modify the default 2 seconds of the watch command?
watch -n 5
How can you retrieve the process IDs that are related to a process name plus the full command line the process is using?
pgrep -a
How can you retrieve the process IDs that are related to a process name?
pgrep
How do you start a given process in a systemd system?
sudo systemctl start
How do you specify megabytes and gigabytes in the output of #free?
#free -m #free -g
In the output of #free, what would a high utilization of swap space mean?
It means the system needs more RAM installed.
What will the #free command show?
It displays the amount of RAM that is available, how much has been used, how much is still free and how much is available for other processes. It also shows the swap space.
What does load average 1 mean in the output of #uptime if you have 4 CPUs?
It means the processor is used up only 25% and 75% is idle.
What does load average 1 mean in the output of #uptime if you have one CPU only?
It means the processor is maxed out 100%
What does a process in an uninterruptible state mean?
A process in an uninterruptible state is waiting on some IO access such as network or HDD access.
What does a process in a runnable state mean?
A process in a runnable state is using the CPU or waiting to use the CPU
What is the load average in the output of #uptime?
It is the average number of processes in a runnable or uninterruptible state.
What is the timing for load average shown in the output of #uptime?
load average: 0.00 0.01 0.05 (last minute, last 5 and last 15 minutes respectively).
How do you determine how long a system has been up and running, number of users and load average?
uptime
What command will print information about processes in near real time?
top
Where does the #ps command get the information it prints to the screen?
From the /proc directory
What flag of the #ps command will give a full format listing with all arguments that a command is using while it is running?
-f
Ex: #ps -efH
What is the command to see all processes for all users in a tree -like fashion?
ps -e –forest
What command shows the processes running for every single user in a system in a hierarchical manner?
ps -eH
What is the command to see the processes running for a specific user?
ps -u
If you run the #ps command by itself with no flags, what will you see?
You will see only processes running in the current shell.
What command gives a snapshot of the current processes running in a hierarchical manner?
ps -eH | less
What is the area below PID 1 and PID 2 in the output of #ps called?
PID 1: user space
PDI 2: kernel space
What does the command #ps use to display a hierarchical order of the processes?
It uses indentations at the processes name columns.
What is PID 1 called in an init system? What is it called in a systemd system?
init and systemd
After a Linux system has been booted up, the Linux kernel hands over control to what process?
PID 1 (process ID 1)
What is a process priority?
It dictates how much time the cpu allottes the process.
What are some properties that a process has?
Memory context
Priority
Environment
What is a process?
A process is a set of instructions loaded into memory coming from a program that is running.