Table of contents
3. Running processes in the background
A Linux process is an instance of a program running in the operating system. Each process has its own memory space and execution environment, which are isolated from each other to ensure security and stability. Managing processes in Linux is very important. Below I will teach you how to handle Linux processes in detail.
1. Check the process
To view running processes you can use the following command:
ps command: Display the processes in the current terminal.
ps
top command: displays the processes running in the system in real time, sorted by CPU and memory usage.
top
2. Start the process
To start a new process, just enter the command you want to run in the terminal. For example:
ls
The above command will start a new process to list the files and subdirectories of the current directory.
3. Running processes in the background
If you want to put the process into the background, you can use the & symbol:
command &
For example, to run an application called myapp in the background:
./myapp &
4. Pause and resume processes
To pause a running process, use the Ctrl+Z keyboard combination. You can then put it to run in the background using the bg command:
bg
To resume a process running in the background, use the fg command:
fg
5. Terminate the process
Use the kill command to kill the process, replacing the PID with the actual process PID:
kill PID
If you need to forcefully terminate a process, you can use the -9 option:
kill -9 PID
6. Find process information
To find more information about a specific process, you can use the ps command, providing the PID of the process:
ps -p PID