If you only do occasional work in Linux, chances are that the work is related to processes. Processes are launched...
with the systemd service manager. You need Linux process management commands to effectively allocate compute power and keep track of jobs.
Systemd is the service manager for Linux. If you need services, you can deploy the systemctl command, which requires root privileges. To access these privileges add sudo to the systemctl stop sshd command, making it sudo systemctl stop sshd.
The systemctl command uses many variants, but for occasional Linux use, you'll only need a few. To start, use the systemctl list-units -t service command. This prompt gives you a list of all the currently running services. Use the arrow keys to navigate through the list and find the exact name of the service you want to run.
After finding the service you want to manage, there are several common Linux process management commands you can use. Here are a few, using the sshd service as an example:
- Systemctl status sshd will show the current status of your service. You'll get a large amount of detail in the output, as this command also shows relevant log information.
- Systemctl restart sshd restarts the service. This can be useful if the service doesn't work as expected and requires troubleshooting.
- Systemctl stop sshd stops the service. Systemctl start sshd will start it again.
Linux process management commands
In Linux, services start different processes. If you need more information about individual processes, use the ps command. With administrator privileges, the ps aux command lists all the active processes on your system. When going through the processes, know that the most recent ones are listed last.
Look for the process identification number (PID), which is useful to stop tasks with the right Linux process management commands. To do so, use the kill command. For instance, if your sshd process has PID 811, use kill 811 to stop it.
Start specific jobs by typing a command into a Linux terminal. If the task only takes a few seconds, there's hardly any need to perform specific process management for it. However, if you start a task and it takes several minutes to complete, it makes sense to move it into the background.
You can move any job you've started to the background. To do so, use the Ctrl + Z sequence to temporarily stop the task. Next, use the bg command to move the task to the background. The jobs command enables you to check if the task is still running.
It's also possible to move tasks that are running in the background to the foreground. To do so, look up the job number of the task with the jobs command and use the fg command. For instance, fg 2 will move task 2 from the jobs list to the foreground. Once a task is in the foreground again, you can apply any of the necessary Linux process management commands.