How to suspend and resume apps on Linux
If you need to suspend or resume a program on Linux, there are several methods available. The kill
command is a widely used option, and the htop
terminal-based task manager is another. In this guide, we’ll demonstrate how to utilize both tools to suspend and resume running applications on Linux.
How to find an application’s Process ID (PID)
Before you can suspend or resume a running application on your Linux system, you need to identify its process ID (PID). To accomplish this, the ps aux
command is invaluable.
For instance, to locate the PID for the “VirtualBox” application on your Linux desktop, execute the ps aux
command. Then, sift through the list for “VirtualBox” and identify the number in the “PID” column that corresponds to VirtualBox.
ps aux
Alternatively, to avoid manually searching through an extensive list of all active applications, you can streamline the process by piping ps aux
into the grep
command to specifically isolate “VirtualBox.”
ps aux | grep "VirtualBox"
It’s important to note that the “PID” column is the very first column in the ps aux
output. Thus, in this example, if VirtualBox’s PID were “10868”, that’s the number you’d be looking for.
How to suspend a running application – kill command
The kill
command allows you to suspend any running application using the -STOP
command modifier. To effectively use this modifier, you must first identify the process ID (PID) of your application. Let’s use VirtualBox as our example.
You can find the PID by running:
ps aux
Or, to narrow down the search:
ps aux | grep "VirtualBox"
Focus on the number in the very first column of the output, as this represents the PID. After determining the PID of your application, use the kill -STOP PID
command to suspend it. For instance, if the PID for Firefox is “10868”, you would suspend the app as follows:
kill -STOP 10868
Executing the command above suspends the program, rendering it unresponsive to interactions while consuming no CPU resources. The application remains open and visible, but it’s effectively paused until resumed.
How to resume a running application – kill command
To resume a process you’ve previously suspended with the-STOP,
do the following. Again, run the ps aux | grep APPNAME
command to find the process ID for the suspended program. In this example, we’ll resume previously suspended VirtualBox.
ps aux | grep "VirtualBox"
Find the number in the first column and keep it in mind as this is the process ID (PID). When you’ve located the process ID, you can use it with the -CONT
command to resume the process you previously suspended. For example, if VirtualBox is “10868,” use it with the kill -CONT
command to resume it.
kill -CONT 10868
With the command executed, your program will be resumed and operate as it was before it was suspended with kill -STOP
.
How to suspend and resume a running application with HTOP
Using the kill
command with -STOP
is pretty quick, but it isn’t very intuitive. It requires you to remember a number, and then execute a few commands. If you want an easier, more elegant solution, consider using Htop to suspend running applications.
To start, ensure you have the htop
application installed. If you don’t, you can install it on your system with the following terminal command. Note that many Linux operating systems include the Htop application by default. Before you attempt to install it, consider running the htop
command to see if you have it installed already.
Ubuntu/Debian
sudo apt install htop
Arch Linux
sudo pacman -S htop
Fedora
sudo dnf install htop
OpenSUSE
sudo zypper in htop
Once you’ve installed the Htop application, launch it in the terminal.
htop
When you’ve got the htop
app running, use the UP / DOWN keys on your keyboard to find the program you wish to suspend. Alternatively, press F3 on the keyboard to search for the program via typed text.
With the program located, press the F9 key on the keyboard. Doing this will bring up the “kill” menu. In this menu, use UP / DOWN arrow keys to navigate to “19” (SIGSTOP,) and select it by hitting the Enter key.
The instant you select option “19” in the menu, your program will suspend. If you wish to resume the program, press F9 to open up the “kill” menu, and choose “18” (SIGCONT,) to resume the suspended process with the htop
application.