1. Home
  2. Linux
  3. How to suspend and resume apps on linux

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.

Feature image for suspend-resume.

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.”

The ps aux process ID information.

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:

The user is using the kill command to stop the Vbox process found in ps aux.

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.

The htop utility filtering out a specific process.

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 Htop utility stopping a process.

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.

The Htop utility continuing a previously suspended process.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.