How to Kill All Python Processes in Ubuntu

Running multiple instances of Python makes finding each individual instance difficult if you want to stop them. In Ubuntu Linux, each instance of an application or process has a unique ID. You can stop all instances of a particular process, such as Python, without knowing the ID of each process by using the "pkill" command, which locates all the processes that match your criteria and kills each one. The "pgrep" command outputs the process IDs based on the criteria given.

Step

Right-click the desktop and choose the Terminal option to open a terminal window.

Step

Type the command sudo pkill python to kill all the Python processes running, regardless of the user who started the process. Type your password when prompted.

Step

Type the command sudo pgrep python to ensure all Python processes have stopped. This command should not produce an output, and you will not be prompted for a password.