Stop app on linux

Ubuntu Linux Stop a Process

H ow do I stop a process under Ubuntu Linux using command line and GUI tools?

You can use the following tools to stop a process under Ubuntu Linux:

  1. System Monitor application – A gui tools displays current active processes. it also provides detailed information about individual processes, and enables you to control active processes i.e. kill or end process.
  2. kill command – Send signal to a process such as kill or end a process.
  3. pkill command – Find processes or processes based on name and send end or kill singles to processes.
  4. killall command – Kill processes (including all its children) by name.

Gnome: System Monitor Application To Kill a Process

To start System Monitor GUI, click on System menu > Select Administration > System Monitor . Alternatively, open a command-line terminal (select Applications > Accessories > Terminal), and then type:
$ gnome-system-monitor
Click on Processes Tab:

Fig.01: A list of process and end Process button

How Do I End a Process?

  • First select the process that you want to end.
  • Click on the End Process button. You will get a confirmation alert. Click on “End Process” button to confirm that you want to kill the process.
  • This is the simplest way way to stop (end) a process.

kill Command Line Option

You can use the kill command to send a signal to each process specified by a process identifier (PID). The default signal is SIGTERM (15). See the list of common UNIX / Linux signal names and numbers for more information. In this example, ps command is used to find out all running processes in the system:
$ ps aux | grep firefox
To end a process, enter:
$ kill -s 15 PID-HERE
$ kill -s 15 2358
OR send signal 9 (SIGKILL) which is used for forced termination to PID # 3553:
$ kill -9 PID-HERE
$ kill -9 3553
See our previous FAQ “how to kill a process in Linux” for more information.

pkill Command Line Option

The pkill command allows you to kill process by its name, user name, group name, terminal, UID, EUID, and GID. In this example, kill firefox process using pkill command for user vivek as follows:
$ pkill -9 -u vivek firefox

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

killall Command Line Option

The killall command sends a signal to all processes. To terminate all httpd process (child and parent), enter:
$ sudo killall -9 httpd
OR
$ sudo killall -9 apache2
See sending signal to Processes wiki article for more information.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Use killall and kill Commands to Stop Processes on Linux

killall is a tool for terminating running processes on your system based on name. In contrast, kill terminates processes based on Process ID number (PID). kill and killall can also send specific system signals to processes.

Читайте также:  Почему uefi не видит загрузочную флешку windows 10

Use killall and kill in conjunction with tools including Process Status, ps , to manage and end processes that have become stuck or unresponsive.

Throughout this guide, replace [process name] in each example with the name of the process you wish to terminate.

Usage

How to Use killall

The killall command takes the following form:

killall will terminate all programs that match the name specified. Without additional arguments, killall sends SIGTERM , or signal number 15, which terminates running processes that match the name specified. You may specify a different signal using the -s option as follows:

This sends the SIGKILL signal which is more successful at ending a particularly unruly processes. You may also specify signals in one of the following formats:

How to Use kill

The kill command terminates individual processes as specified by their PID.

Commands take the following form:

Without options, kill sends SIGTERM to the PID specified and asks the application or service to shut itself down. This is discussed further in the following section.

Multiple PIDs and alternate system signals can be specified within a single kill command. The following examples all send the SIGKILL signal to the PID specified:

System Signals

The kill command does not terminate a process directly. Rather, a signal is sent to the process where the process will have instructions to follow if it receives a given signal. The man pages provide further reference of all available signals:

To simply list all available signals without their descriptions:

If you need to convert a signal name into a signal number, or a signal number into a signal name, use the following as examples:

Find Running Processes

Use a utility like htop or top to view a real time list of process and their consumption of system resources.

Use the ps command to view processes that are currently running and their PIDs. The following example filters the list of all processes that are currently running for the string emacs using grep:

The number listed in the second column from the left is the PID, which is 3896 in the case of the emacs process. The grep process will always match itself for a simple search, as in the second result.

Once you have obtained the PID or process name, use killall or kill to terminate the process as above.

Another option to find the PID is though pgrep .

Verify Process Termination

Adding the -w option to a killall command causes killall to wait until the process terminates before exiting. Consider the following command:

This example issues the SIGTERM system signal to a background process with a name that matches irssi . killall will wait until the matched processes ends. If no process matches the name specified, killall returns an error message:

This page was originally published on Monday, November 29, 2010.

Источник

Start and stop application from terminal in Linux Mint 19 / Ubuntu 18.04

In this article we will review several scenarios how to :

  • Start application from terminal — Ubuntu / Linux Mint
  • Schedule application start
  • Build script starting application
  • Stop application by id/name in Linux Mint / Ubuntu
  • Application stop with delay
  • Auto logout from Ubuntu / Linux Mint
  • Bonus tip: schedule application stop

Start application from terminal — Ubuntu / Linux Mint

In order to start application from terminal you need to know the name of the application which is used in the system. Sometimes the system name can differ from the application name. For example:

  • Chrome — google-chrome
  • Chromium — chromium-browser
  • Sublime — subl

You can find where a given application is installed by:

Also there you can search for applications.

In order to start give application you need to write it’s name in the terminal:

You can pass different parameters to the application which will be opened. For example which file to be opened for Libre office:

or what web sites to be opened with chrome:

Читайте также:  Как очистить поиск windows

Schedule application start

Sometimes you may want to schedule a script for opening a given application. In order to improve my performance and decrease the distractions I’m scheduling my mail to be opened two times per day: 10:00 and 16:00.

The scheduling in Linux usually is done with cron jobs:

  • Open terminal
  • Type: crontab -e — for current user only or sudo crontab -e
  • finally add your job:

Some application can be started by their name but others will need some settings. For example in order to start thunderbird and display it you need to add this line in your crontab file:

the same way if you are using bash script to start another application. For example starting LibreOffice calc:

where libre office will be started after a csv file with data is downloaded from a website.(I’ll add new article on this topic).

Build script starting application

Building special scripts to start application can be helpful in order to automate boring stuff. I have 10 scripts which are helping me to do boring stuff like:

  • reporting
  • getting information from the web
  • sending mails
  • analysing data
  • starting and stoping application — obviously from the article 🙂

Below you can find several examples below:

  • the first row is going to «log» each time this scripted is executed
  • the second one is opening thunderbird

A more complex example where:

this example is more complex. Here is what is done:

  • activate special python virtual environment
  • change to a special folder
  • run a web spider in order to get information from Google
  • analyze and change the data
  • load the download data in calc

this script is run with a cron job every day and retrieves important information for me. If I need to do the same thing I’ll need to spend 10 to 30 minutes per day.

Stop application by id/name

To stop application from the terminal by id you will need to find the id first. This can be done by this command:

10882 10869 10831 10784 10781

Another alternative is:

10882 10869 10831 10784 10781

or the more verbose one:

user 2315 0.0 0.0 15648 1152 pts/1 S+ 18:38 0:00 grep —color=auto google-chrome
user 10781 0.3 0.4 1379564 151624 ? SLl 14:57 0:47 /usr/lib/..

and then you can extract the pid-s.

After that in order to stop the application you can use:

both do similar things but the one with -9 is more «aggressive» and forcing.

In order to stop/kill application by name you can use:

this is going to kill multiple processes by name.

Application stop with delay

Now let say that you want to stop a given application with some delay: 10 minutes, 1 hour or something else. You can do with by several different ways: cron job, script, third party software. In this case we will use simple script:

this script will wait for 1 hour and then will stop the application. So you can use a script to start a given application. This application to be executed for 1 hour and finally to be stopped.

Other times examples:

Note: You can’t use:

Auto logout from Ubuntu / Linux Mint

The final problem which we are going to cover in the article is about log out of inactive users. There is application for Ubuntu / Linux Mint which can be used — autolog. You can search in the software center and install it. Or you can install it by:

Bonus tip: schedule application stop

Let say that you work a lot google chrome, slack, zoom, pycharm or any other application in Linux Mint, Ubuntu. Most of the time is really difficult to end up your working day and leave your workplace. Automation to the rescue! Below you can find a simple script and how to use in order to schedule stop for your applications in Linux:

The script will show the current date and time. Then will wait for a given period of time ( in this case 30 minutes ) and finally will kill the application.

Читайте также:  Оценка графики производительность рабочего стола для windows

now you can schedule this script as a cronjob by:

Источник

How to kill a process or stop a program in Linux

Here are several options for terminating a program in Linux using the command line or a graphical interface.

Subscribe now

Get the highlights in your inbox every week.

When a process misbehaves, you might sometimes want to terminate or kill it. In this post, we’ll explore a few ways to terminate a process or an application from the command line as well as from a graphical interface, using gedit as a sample application.

Using the command line/termination characters

Ctrl + C

One problem invoking gedit from the command line (if you are not using gedit & ) is that it will not free up the prompt, so that shell session is blocked. In such cases, Ctrl+C (the Control key in combination with ‘C’) comes in handy. That will terminate gedit and all work will be lost (unless the file was saved). Ctrl+C sends the SIGINT signal to gedit . This is a stop signal whose default action is to terminate the process. It instructs the shell to stop gedit and return to the main loop, and you’ll get the prompt back.

Ctrl + Z

This is called a suspend character. It sends a SIGTSTP signal to process. This is also a stop signal, but the default action is not to kill but to suspend the process.

It will stop (kill/terminate) gedit and return the shell prompt.

Once the process is suspended (in this case, gedit ), it is not possible to write or do anything in gedit . In the background, the process becomes a job. This can be verified by the jobs command.

jobs allows you to control multiple processes within a single shell session. You can stop, resume, and move jobs to the background or foreground as needed.

Let’s resume gedit in the background and free up a prompt to run other commands. You can do this using the bg command, followed by job ID (notice [1] from the output of jobs above. [1] is the job ID).

This is similar to starting gedit with &, :

Using kill

kill allows fine control over signals, enabling you to signal a process by specifying either a signal name or a signal number, followed by a process ID, or PID.

What I like about kill is that it can also work with job IDs. Let’s start gedit in the background using gedit & . Assuming I have a job ID of gedit from the jobs command, let’s send SIGINT to gedit :

Note that the job ID should be prefixed with % , or kill will consider it a PID.

kill can work without specifying a signal explicitly. In that case, the default action is to send SIGTERM , which will terminate the process. Execute kill -l to list all signal names, and use the man kill command to read the man page.

Using killall

If you don’t want to specify a job ID or PID, killall lets you specify a process by name. The simplest way to terminate gedit using killall is:

This will kill all the processes with the name gedit . Like kill , the default signal is SIGTERM . It has the option to ignore case using -I :

To learn more about various flags provided by killall (such as -u , which allows you to kill user-owned processes) check the man page ( man killall )

Using xkill

Have you ever encountered an issue where a media player, such as VLC, grayed out or hung? Now you can find the PID and kill the application using one of the commands listed above or use xkill .

xkill allows you to kill a window using a mouse. Simply execute xkill in a terminal, which should change the mouse cursor to an x or a tiny skull icon. Click x on the window you want to close. Be careful using xkill , though—as its man page explains, it can be dangerous. You have been warned!

Refer to the man page of each command for more information. You can also explore commands like pkill and pgrep .

Источник

Оцените статью