When a program stops responding in Windows, most users know how to stop it by pressing Ctrl + Alt + Delete on their keyboard, clicking the Task Manager option and closing it from there. This approach is not entirely suitable for Linux distributions such as Ubuntu, but that does not mean that you are lacking options if the program crashes.
On the contrary, there are several ways to close a program in Ubuntu using CMD. If you’re comfortable using the terminal, you can use commands such as killall or xkill to force the problematic programs to close, or you can use the System Monitor app instead.
Use System Monitor to force close the running Ubuntu process
While it is quite easy to close an open process in Ubuntu using the terminal, it may be inconvenient for beginners. But the Ubuntu user doesn’t have to go near the terminal to force close the crashing program – you can use the System Monitor app instead.
System Monitor works in much the same way as the Task Manager for Windows PCs. It lists all running processes on your PC and also provides you with real-time information about your CPU, RAM and disk usage. It also allows you to forcibly close any crashing software that doesn’t respond or doesn’t close directly.
- To force quit a program in Ubuntu using Performance Monitor, click the Show Applications button at the bottom of the window. docking station Ubuntu. In the list of applications, click the System Monitor icon to launch it.
- The Performance Monitor application will start with the Processes tab visible by default. If not, click the Processes tab at the top. In the list of processes, find and locate the process (or processes) for your program that crashed, right-click the entry, then click the Kill button. Alternatively, select a process and click the End Process button at the bottom of the Performance Monitor window.
- System Monitor will ask you to confirm that you really want to end the running process. Press the “End Process” button to confirm.
If successful, the process should disappear from the system monitor process list. If the program had an open window, it should also close at this stage.
If System Monitor was unable to close the program, you need to try using the terminal.
How to close an open window using the xkill command
In most cases, the performance monitor software will forcefully close the program in Ubuntu. If it doesn’t, you need to switch to the terminal to close any non-responding programs.
Fortunately, there is an easy-to-use command called xkill that will allow you to force close any program with an open window.
- Most modern Ubuntu versions should come with the xkill package installed, but if you find it is not installed, you need to install xkill first before you can use it. Open a terminal and type sudo apt install xorg-xkill to do this. After installing it, just type xkill or sudo xkill to start using it.
- In the terminal output, you will be prompted to select the window whose client you want to kill using button 1. In other words, use the mouse to click on the open window – xkill will close it for you. After killing, the terminal output before completing will respond with a message to kill the creator.
This will only work for programs that are clearly not responding, including any programs with a GUI window that you can interact with.
Force close a program on Ubuntu with the pkill, kill, or killall commands
Using xkill requires you to be using Ubuntu with a GUI. If you are running a standalone version of Ubuntu without a GUI installed, such as Ubuntu Server, you will need to use the pkill, kill or killall commands instead.
The kill and pkill commands will terminate any individual process running on your computer, and killall will kill all associated processes. Some programs (like Google Chrome) use multiple system processes, so using kill or pkill may not necessarily kill them if the program stops responding.
- To use kill, you need to know the process ID (PID) assigned to it – open a terminal and type top to see a list of currently running processes. You will find the process ID number in the PID column and the process / program name in the Command column.
- To stop a terminal using kill, enter kill pid, replacing pid with your process ID (for example, kill 582). If that doesn’t work, type sudo kill pid instead. Successful completion of the process should not produce additional terminal output, but you can type top again to double-check.
- The pkill command does not require a process ID, but a package name. You can check this using top first on the Command column. When you’re ready, type pkill process replacing the process with the package name (or sudo pkill process if the process does not exit). As with kill, a successful pkill command will return no messages or output.
- If there are multiple processes in a program, you can use the killall command to kill them all at once. Like pkill, this uses the package name – use top to find it in the Command column. To use killall, enter killall process or sudo killall process, replacing process with your package name. Like pkill, no messages will be returned to the terminal if the command is successful.
Effective Ubuntu Maintenance
Even when running software stops responding, Ubuntu gives you the tools to keep things in check. Now you know how to close a process in Ubuntu using the terminal, you can use other cool Linux terminal commands to back up your PC, pause commands instead of exiting, etc.
A program crash should be rare, but if it happens more often than it should, it could indicate a problem with your Ubuntu installation. You will need to investigate some of the common causes of Ubuntu crashes in order to (hopefully) resolve your problems.