1.4 Given a scenario, configure and use the appropriate processes and services Flashcards
Command to start daemon/service
systemctl start [service]
Command to stop daemon/service
systemctl stop [service]
Command to restart daemon/service
systemctl restart [service]
Command to get status of daemon/service
systemctl status [service]
Command to automatically start service on system boot
systemctl enable [service]
Command to remove service from automatically starting on system boot
systemctl disable [service]
Command to stop a service from being started at all, either manually or automatically
systemctl mask [service]
What does the top command do?
Shows an abbreviated, dynamic list of processes and their mem & cpu usage
What does the ps command do? What is the default if no options are added to it?
- Shows a static list of processes
- Default behavior only shows active “user” processes for the current shell
What does ps command option “A” or “e” do?
Shows all processes
What 2 ps command options show more detailed info about processes?
-l and -f
What ps command option shows the state (i.e. running, sleeping, zombie, etc) of processes?
-l
What ps command option shows processes for a specific user?
-u
What ps command option shows processes that are started during system boot?
-x
What are the 4 state letter codes for processes?
- “R” running
- “S” sleeping
- “T” traced
- “Z” zombie
What does the pgrep command do?
Combines functionality of ps & grep command into an easier to use command
What are the 3 most common pgrep options and what do they do?
- -f search for the specified process name
- -u show all processes owned by a specific user
- -p show all processes with PPID specified
How can a process be started to run in the background?
[command] followed by [space] &
What does the jobs command do?
Lists the processes running in the background with JobID and state (i.e. running, stopped)
In the shell, how can a process running in the foreground be moved to the background? (3)
- Press Ctrl + z to stop the current process and assign it a JobID
- Run jobs command to see a list of the processes and JobIDs
- To start the job in the background, use command: bg [JobID]
In the shell, how can a process be moved from running in the background to the foreground? (2)
- Use jobs command to list the processes running in the background
- command fg [JobID] to move the program to the foreground
What does Ctrl + z do?
Stops the currently running (foreground) app/process/command and assigns JobID for it as a background process
How does the priority value affect a process’ access to CPU time?
Inversely, The higher the value, the less CPU time the process gets
How can the priority of a process be changed?
Although the priority can’t be directly modified, a nice level can be set which adjusts the priority assigned by the system
What does the nice command do? What is the syntax?
- Starts a process and specifies the nice level which affects the priority the process will run with
- nice -n [nice_level] [command]
What does the renice command do? What is the syntax?
- Modifies the nice level, or priority, of a currently running process
- renice -n [nice_level] [PID]
What is the range that can be specified for a nice level?
-20 to 19
What restriction exists when setting nice level?
Unless executed with root privilege, user can only be values from 0 to 19
Only root can assign a negative nice level
What 3 commands can be used to terminate a process?
- kill
- killall
- pkill
What does Ctrl+c do?
Interrupts and stops a process by sending the SIGINT signal
What does the SIGHUP signal do?
Shuts down and restarts a process
What does the SIGKILL signal do?
Forces a process to stop, without releasing resources allocated to it, when it is unresponsive all other options to stop it fail
What does the SIGTERM signal do?
Stops a process cleanly and releases resources allocated to it
In what order should signals be sent to try to kill a process?
- SIGINT (Ctrl+c)
- SIGTERM
- SIGKILL
What are the alternative numeric values for the 4 signal types sent with kill command(s)?
SIGHUP - 1
SIGINT - 2
SIGKILL - 9
SIGTERM - 15
Syntax of kill command
kill [signal] [PID]
Syntax of killall command
killall [signal] [process name]
Syntax of pkill command
pkill [signal] -f [search term for proc name]
What is the default signal, if none is specified, for all 3 kill commands?
SIGTERM
What does htop command do?
Shows a graphical view of system processes and real-time memory & cpu usage, kind of like task manager does in Windows