Stopping the process. End process from command line

Instruction

All running processes are divided into those that are launched automatically at system startup and those that start when the user clicks on the shortcut of a particular program. The former, in turn, are divided into system ones, necessary for the operation of the OS, and user program processes, for which the autorun option is set.

To stop a process, you need to know its name. Open a command prompt: "Start - All Programs - Accessories - Command Prompt". Type tasklist command and press Enter. You will see a list of processes running on the system. If you cannot determine its ownership by the name of the process, use the Everest program. With it, you will get all the information about your computer, including information about running processes and paths to executable files.

There are several ways to stop a process. The easiest way is through the "Task Manager" (Ctrl + Alt + Del). Select the process you want to stop from the list of processes and right-click on it. In the context menu that opens, select End Process. Remember that you will not be able to stop critical system processes, the operating system will not allow you to.

You can also stop the process from the command line by typing taskkill /pid 1234 /f and pressing Enter. Instead of "1234" enter the process ID (PID), look for it in the last column of the list displayed by the tasklist command. The f parameter in the command determines the forced termination of the process. To see all the options for using the taskkill command, type taskkill /? and press Enter.

If you want to stop a running service, open: "Start - Control Panel - Administrative Tools - Services". Find the service you need and double-click it. In the window that opens, click the "Stop" button, the service will be stopped. Next, you can disable its launch by selecting the "Disable" option from the "Startup type" menu.

After stopping the service, you can restart it by clicking the "Start" button. The button is visible if the Startup Type menu is set to Auto or Manual. If "Disabled" is selected, the button will be disabled.

To start a process that is not a service and, accordingly, not displayed in the list of services, find and run its executable file. Look at the path to the file in the Everest program before stopping the process. You can also start the process from the command line - for example, to start Notepad, type notepad.exe at the command line and press Enter. To run the programs you installed, you must enter the full path to the executable file.

Despite the fact that Linux is more stable than Windows in terms of programs and various services, everything happens and sometimes it becomes necessary to terminate the Linux process. This may be necessary if the program crashed when you started the system service in the background through the terminal, and not the init system, and in many other cases, when it is easier to kill the Linux process, reboot the entire system.

In this article, we will look at some of the most common ways to end a Linux process. We will describe in detail how the process stops and how to do everything right.

Process control in the Linux operating system is carried out using signals. Including the completion of any process. Signals are sent by the system, but they can also be sent by the user using special commands or even keyboard shortcuts in the terminal. When a process is signaled to terminate, it must perform some preparatory work.

It is necessary to terminate child processes, delete temporary files, sockets, and so on. But depending on the complexity of the situation, the process may not respond to all signals. Consider the main signals that are used to terminate the process:

  • SIGINT- the most innocuous termination signal, means Interrupt. It is sent to a process launched from a terminal using the Ctrl+C keyboard shortcut. The process correctly completes all its actions and returns control;
  • SIGQUIT- this is another signal that is sent via a keyboard shortcut to a program running in the terminal. It tells it to terminate and the program can gracefully terminate or ignore the signal. Unlike the previous one, it generates a memory dump. Keyboard shortcut Ctrl+/;
  • SIGHUP- informs the process that the connection to the control terminal is broken, sent mainly by the system when the connection to the Internet is broken;
  • SIGTERM- immediately terminates the process, but is handled by the program, therefore allowing it to terminate child processes and release all resources;
  • SIGKILL- also immediately terminates the process, but, unlike the previous option, it is not transferred to the process itself, but is processed by the kernel. Therefore, resources and child processes remain running.

It is important to understand that you need to give the process a chance to complete gracefully. It is desirable that ports and sockets be freed, closed and temporary files removed. Therefore, never send a SIGKILL immediately. Send termination signals in sequence as listed above.

First ctrl+c, if possible, then SIGTERM - although it ends the process, it does this culturally, and only as a last resort SIGKILL. And now let's look at how to kill a process by pid Linux in practice. If you always use SIGKILL then this picture comes to mind:

How to kill a Linux process?

The kill utility is used to signal processes in Linux. Its syntax is very simple:

$ kill -pid_process signal

The signal is one of the above signals to terminate the process. By default, if this parameter is not specified, the SIGTERM signal is used, which is very correct. We also need to specify which process to terminate. For this, a unique process identifier is used - PID.

Let's say we have a ping utility running. We want to end it with kill. Then, first we find out its ID using the ps command:

ps aux | grep ping

The first line will display the ping utility itself, and the second line will display the ps program itself. We take the desired PID and terminate the process using SIGTERM:

kill -TERM 20446

And only if after this command the process continued to hang, and you can check this by running ps. Only now you can SIGKILL:

kill -KILL 20446

Now we check again:

If the process is running as root, then naturally you need to use sudo. It is not always convenient to kill a process by its PID, at least because you still need to find out this PID. We could use xargs to make a lot of complex constructs to calculate the pid automatically from the process name and terminate it immediately, but this is not necessary. There are already special utilities.

How to kill a process with pkill

The pkill utility is a wrapper for kill, it behaves exactly the same and has the same syntax, only it needs to be passed the name of the process as the process ID. The utility scans the proc directory and finds the PID of the first process with that name, then sends it a SIGTERM. So you can kill a process called Linux. For example, if we want to terminate the same ping:

You can also manually set the signal type:

pkill -TERM ping

Instead of ps, you can use the pgrep utility to find the pid of the process, make sure our program is finished:

But if the program has created several processes for you, for example, the chromium browser or firefox create a separate process for each of the tabs, then this utility will not help much. Here is the next option.

How to stop a process with killall

killall works similarly to the two previous utilities. It also takes the process name as a parameter and looks for its PID in the /proc directory. But this utility will detect all processes with that name and terminate them. For example:

As you can see, there are several processes running, it remains to stop the Linux process with killall:

The command will terminate all running ping utilities, you can verify this by running pgrep again:

conclusions

In this article, we looked at how to kill a Linux process. Sometimes this task can be very useful, but it is important to understand that it must be done correctly. This is not to say that passing SIGKILL instead of SIGTERM is very dangerous, but you shouldn't do it. I hope this information was helpful to you.

Infrequently, of course, but sometimes you can find situations when, after closing the program in the Task Manager, the process responsible for its functioning does not end, or some additional (related) application services continue to work. In this case, the system, in addition to everything, can report that the user does not have enough rights to complete a certain process (access denied). Why this happens and how to stop unnecessary or freezing programs, read the material below.

The process does not end in the "Task Manager" (permission denied). Why?

In order to understand which solution to eliminate the problem that has arisen to use in each specific case, you first need to find out the reasons due to which they arise. Why does the process not end in the Task Manager indicating that there are no access rights?

Indeed, sometimes this may be due to the fact that the user is not logged in as an administrator and is trying to terminate a critical system service or process started by another user. However, the impossibility of stopping the operation of some application is mainly associated not even with system processes, but with programs that could be installed on the user's computer spontaneously (viruses, adware, etc.). Usually they are the ones that can block the shutdown. But it is quite easy to deal with such manifestations of behavior of both system and user programs or services.

System reboot

If the process does not end in the "Task Manager", what should I do first? As a rule, ordinary users act quite simply. If for some reason the process does not end in the Windows 10 Task Manager, they simply reboot the system. It is clear that a full restart leads to a stop of all services. But what if, after a reboot, the process is activated again? But some processes that run with the system cannot be tracked even in the standard startup section.

However, if the user is not logged in under an administrator account, but under his own account, as is already clear, you just need to change the user.

If you don’t want to constantly jump from one entry to another, you can disable the administrator account altogether by typing the command “net user Administrator active: no” (without quotes) on the command line. After that, all programs will start only with administrator rights (for some applications, even UAC security warnings, which annoy many users, will not be issued).

End active processes via command line

But the above actions may not always give a positive effect. What to do if a process does not end in the Task Manager, which, say, overloads the central processor or uses RAM too hard? In such a situation, the command console (cmd) will be the best tool among those that are available on Windows systems.

It must be run as an administrator (if the superuser account is not disabled), and then use the taskkill command (all information about additional attributes can be viewed by entering the line "taskkill /?".

Of the entire list, we are most interested in the "/F" and "/IM" attributes, which are added after the main command. What does it look like? Let's suppose that the Google Chrome process does not end in the Task Manager. The command to force stop the application will look like this: "taskkill /F /IM Chrome.exe" (again, without quotes). As is already clear, such a solution is acceptable for program executable files. If you use the additional key "/T", when you enter the main command to shut down the selected application, all child processes will be automatically terminated as well.

Stopping processes with IDs

If the process that was selected by the user does not end in this way in the Task Manager, for example, if the name of the executable file of the problematic program or service is entered incorrectly, the process can be stopped by specifying an identifier.

It can be viewed in the "Task Manager" itself, additionally activating the display of the column with the process ID. The main command in this case will take the following form: “taskkill / F PID 0000”, where 0000 is the process ID defined in the “Task Manager”.

In principle, the problem associated with the fact that the process of a program does not end in the Task Manager can be solved by following the advice of Microsoft specialists, which are published on the support page. The bottom line is to download a special archive from the site containing the PSTools toolkit, then unzip it to your hard drive and move the PsExec.exe file or the PsExec64.exe object, depending on the system architecture, to the root of the system partition (drive "C" ), and then through the command console run the command "c:\psexec -i -d -s taskmgr.exe" (without quotes). After that, in the "Task Manager" you will need to perform all the necessary actions related to stopping certain processes, then close the "Manager" and delete the original PsExec file from the system partition.

Note: it is recommended to use this method even on the corporate website only at your own peril and risk.

Using Process Explorer

It is much easier to use a small application that is an alternative to Task Manager, but with advanced features. The advantage of this program is that you do not need to install it on your hard drive, since the application is initially portable and runs from a single executable file. After starting the program, it is enough to select the desired non-terminating process in it or even the whole process tree with child applets by selecting the Kill Process or Kill Process Tree commands from the RMB menu.

In addition to "killing" unnecessary processes and tasks, this utility also provides additional information. So, for example, if this is required, it is quite easy to find out which program is running this or that process.

Unblocking access to process files

Finally, if it is impossible to terminate certain processes only because access to the file responsible for it is blocked, it may very well be possible to correct the situation by using the Unlocker utility.

First, as it is already clear, access to the original file is restored (you can find it directly in the "Task Manager" by selecting the view file location from the RMB menu), and then the process ends in the usual way.

Problems of viral exposure

Viruses, unfortunately, can also restrict access to stop processes and services. And this is not always directly related to the virus applets themselves. If this situation is observed, it is recommended to first check the system with some portable antivirus, and if it is impossible to neutralize threats, turn to the Kaspersky Rescue Disk program, with which you can boot even before the system starts from removable media, and then perform a deep scan, which includes even RAM itself.

Summary

That, in fact, is all that concerns the forced termination of processes in the Task Manager. As for the best tool, the simplest one seems to be the Process Explorer alternative manager. If there is no such program at hand, the command line will do. The only condition for executing all the above commands is to start the console itself with administrator rights.

Not up to the task.

Sometimes it becomes necessary to manually end a process that is not responding. In most cases, this can be done using the Windows Task Manager, but sometimes it cannot cope with an out of control application. I often encountered this when trying to terminate the Acronis process. In such a situation, I usually use a more powerful tool - the taskkill command.

To use taskkill, you need to open a command prompt window. To do this, call the “Run” window from the “Start” menu (Start) or use the key combination + [R] and enter “cmd” (without quotes) in the “Open” field (Fig. A).

Figure A Open a command prompt window.

Using the taskkill command

The general command syntax is as follows:

taskkill [OPTIONS] [PROCESS ID]
Of course, a wide range of options are available for taskkill. I will list only the most useful of them:

/s COMPUTER, where COMPUTER is the IP or address of the remote computer. By default, the operation is performed on the local system. If this is what you are interested in, this option can be omitted.

/u DOMAIN\USER, where DOMAIN is the name of the domain and USER is the name of the user to run the command against. This option allows you to run taskkill with the rights of a specific account or domain.

/p- must be used in combination with the /u option to specify the password for the user account.

/fi- allows you to execute the taskkill command with certain filters.

/f- terminates the command forcibly.

/IM- allows you to use the application name instead of the process ID.

And of course, one of the most useful options is the help switch (Fig. B):

taskkill /?


Figure B. Taskkill command help output when using the help switch.

End a process by application name

The easiest way to kill a runaway process is to use the taskkill command with the /IM option. It will look like this:

Taskkill /IM APP_NAME
Where APP_NAME is the name of the process to terminate. For example, if Outlook fails to close, you can use the following command:

taskkill /im outlook.exe
Terminate a process by ID

If you don't know the process name, but you do know its process ID (PID) - for example, 572 - you can use the following command:

Taskkill /PID 572
End all processes for a specific account

There is also an option to end all processes for a specific account. This is especially true if you know for sure that the problem is related to a specific account, or if the user has already logged out and the processes he started have stopped responding. In this case, you can use the following command:

Taskkill /F /FI "USERNAME eq username"
Here username is the name of the account under which the unwanted processes are running. Be sure to include the USERNAME option in the command to specify the appropriate username.

End processes on a remote computer

Another handy feature is terminating processes remotely. Let's say you know for sure that the system is not responding due to a certain process (let's take the same Outlook as an example). In this case, you can use another computer and run the following command:

Taskkill /s IP ADDRESS /u DOMAIN\USER /IM Outlook.exe
Here IP ADDRESS is the address of the remote computer (you can also use the host name if the computers are able to recognize each other in this way), DOMAIN is the domain name (if required), and USER is the username under which the remote computer was logged in.

Finally

The taskkill command is a very powerful and functional tool that can eliminate the need to force a computer restart. Skillful use of this command in combination with the Task Manager extends the uptime of the system and even allows you to fight viruses, rootkits or Trojans.

If your computer is running slowly and your hard disk space is overloaded, clean it of unnecessary programs and components, and disable unnecessary processes and services. This can be done using standard Windows tools or using third-party programs.

Where do extra programs come from?

What programs and processes in Windows 7 can be removed

Windows 7 has three categories of data that boots the system - programs, processes, and services. The program is installed on the computer to perform the function required by the user. The process can be a system process, necessary for the correct operation of Windows 7, and a user process, launched along with the program. Services in the system are started by default and disabled through "Computer Management".

Processes can be disabled through the "Task Manager" (instructions are given below).

Table: what processes can be disabled without harm to the system

Process Description
sofficeResponsible for the operation of Open Office.
reader_slAccelerator Adobe Reader.
hkcmdThe Intel process accompanies the computer hardware.
adobeARMChecks for updates to Adobe Reader.
RAVCpl64Audio manager from Realteck.
CCCControl center for ATI graphics cards, only needed if you play games.
neroCheckLooks for conflicting drivers.
jqsSpeeds up Java programs.
juschedLooking for Java updates.
wmpnetwkWindows Media Player search engine.
osppsvcProtection of MS Office 2010 programs.
sidebarResponsible for the operation of Windows 7 gadgets.
nwizResponsible for the actions of nVidia NView.
atiptaxxOpens access to the settings of ATI video cards.

Do not stop the Explorer.exe process - stopping it will remove the desktop icons and the Windows taskbar.

Table: processes that cannot be disabled

Process Description
taskshothost file.
msdtcNetwork systems transaction coordinator.
smsWindows session management.
wininitAutorun programs.
winlogonLogin to Windows.
servicesStarting Windows services.
explorerDesktop, shortcuts.
spoolsySupports print queue.
lsmManages session state.
taskmgrResponsible for the task manager.
searchindexerSearch indexing.
csrssResponsible for console applications.
sppsvcWindows platform protection.
svhostResponsible for network communication.
conhostFor handling console windows.
lsassPreserves local user security.

If you are unsure whether the process can be terminated, open the location of the executable file. If it is located in the Windows system folder, you should not stop it.

Windows 7 prevents the user from completing certain critical processes. When you reboot, the system starts them again.

In addition to processes, services run in the Windows system, some of which can be closed using the "Computer Management" menu without compromising the security of the PC. List of services that can be stopped:

  • Fax;
  • Windows remote control;
  • remote registry;
  • remote desktops;
  • Bluetooth support;
  • remote desktop server;
  • secondary login;
  • smart card;
  • remote access autoconnect manager;
  • distributed transaction coordinator (DTC);
  • ktmrm for KRT.

If you are not using a local network, disable the NetBIOS Helper service and set the Computer Browser service to manual mode.

The image download service cannot be disabled when a scanner or webcam is connected.

How to Erase Programs and Stop Processes on Windows 7

You can remove utilities and stop processes in several ways: through the Start menu, using the Control Panel and Task Manager, as well as using specially designed programs.

How to uninstall programs and disable services from the start menu

By opening the "Start", you can view the list of programs and remove some:

The disadvantage of this method is that after deleting the program by means of Windows, its files and residual entries in the registry are saved.

You can also stop services from the Start menu. For this:


Do not disable all services in a row - some of them are responsible for the correct operation of Windows.

Video: disable unnecessary processes and services

How to delete an application from the "Control Panel"

To uninstall the utility, it is not enough to erase the folder where it is located, or the icon from the desktop. From the standard Windows tools, you can use the uninstaller.

  1. Click on "Start" and select "Control Panel".
  2. Open "Uninstall a program".
  3. The computer will open a list of programs running on the computer in alphabetical order.
  4. Click on the name of the utility you will be uninstalling and click Uninstall/Change at the top of the window.
  5. Confirm the deletion in the pop-up window.

After the uninstall is complete, you may need to restart your computer.

Video: uninstall from the "Control Panel"

How to stop processes through the "Task Manager"

To stop processes running by Windows, launch the Task Manager by pressing Ctrl+Alt+Del.


When you restart your computer, some processes and services start automatically. Therefore, for a permanent shutdown, remove the program using the process from autorun (“Task Manager”, tab “Autostart”) and disable the corresponding service.

The "Startup" tab displays a complete list of programs that start automatically when you start Windows 7. Select the programs that you do not need open, and uncheck the boxes next to them, and then click "OK". After rebooting the computer, autorun will be disabled.

Other Options for Removing Unused Programs

Almost all installers offer users to select a folder where the program files will be placed. By default, they install to the C:\Program files folder. When you open the folder, you will see the software folders. To uninstall the program directly:

  1. Go to the folder of the utility you will be erasing.
  2. Inside, find the Uninstall.exe file.
  3. Double click on the file with the mouse.
  4. The uninstaller window will open. Confirm the deletion and wait for the process to finish.

A more complicated method is uninstalling applications from the command line. To perform an uninstall:

  1. Go to command line. To do this, press Win+R and type cmd in the Run box. Click OK.
  2. Write the WMIC command and press the Enter key. You will see the inscription: wmic: root\cli.
  3. Write a product get name request. After a while, you will see a list of installed programs.
  4. Write: product where name = "name of the program exactly" call uninstall. Be case sensitive when writing the program name. If the name is entered incorrectly, by pressing the Enter key, you will notice the error information.
  5. Press "Y" to confirm the procedure and wait for the inscription Method Execution successful.

Third-party programs to remove unnecessary files

Using Windows tools, it is difficult to erase a program without "tails". And developers come up with third-party applications - uninstallers. Instructions for working with some of them are given below.

PC Decrapifier

  1. Click "Check for updates".
  2. In the window that opens, you will see the question "Are you using a new computer"? Answer without embellishment.
  3. Create a Windows Restore label and click Next.
  4. The program will automatically search for unused applications and present them as a list.
  5. Check the boxes for the programs to remove and click the Remove button.
  6. PC Decrapifier will prompt you to manually uninstall other programs. Execute as needed.
  7. In the last window, uncheck the Submit feedback box and click Finish.

PC Decrapifier copes well with third-party software, toolbars and applications imposed when loading other programs.

Video: PC Decrepifier Review

CCleaner - comprehensive cleaning

The program cleans hard disk space and the Windows registry. Functionality is provided to control startup and remove previously installed software. Additional functionality is located in the "Service" menu.

CCleaner finds more installed applications than the standard Windows 7 uninstaller. And after uninstallation, it “cleans up” residual files and registry entries. To uninstall a program:

  1. Launch CCleaner.
  2. Select "Service" on the left.
  3. Find the sub-item "Uninstall programs".
  4. Select the program to uninstall from the list and click Uninstall. The "Delete" button is required to remove the name of the utility only from the list - it will not be possible to uninstall the application from the PC using it.

To disable/enable startup programs:

  1. Information about programs that start automatically with Windows will open.
  2. Highlight the program for which you want to disable autoload, and click "Turn off".

CCleaner allows you to manage startup not only for Windows, but also for browser add-ons.

Video: CCleaner review

IObit Uninstaller

IObit Uninstaller is a simple program uninstaller with a registry cleaning function. The utility offers the user a list of applications to uninstall. It is divided into categories, you can switch between them in the left menu. IObit Uninstaller works in two modes - standard and forced removal.

To uninstall the utility from IObit in standard mode:

  1. Select it from the list.
  2. Click "Delete" at the bottom of the window.
  3. The program will create a restore point, uninstall the unwanted application, and then scan the system and registry for residual files and entries.
  4. After scanning, you will see a list of found components and you can remove them permanently.

How to uninstall the program in forced mode (required when files are protected from deletion):

  1. Select an application that cannot be uninstalled in standard mode and click Force Uninstall.
  2. Confirm the uninstall.

Forced uninstallation mode can be used for any files. But be careful! After deleting a file, the program will check the folder in which it was located and clear it of other files.

Video: IObit Uninstaller overview

Revo Uninstaller

Revo Uninstaller is a program that allows you to erase software from your computer without leaving any residue. To uninstall an application:

  1. Enable Revo Uninstaller.
  2. Highlight the program you don't need and click on the Uninstall icon.
  3. Select "Yes" in the confirmation window.
  4. Select a method for uninstalling the program: built-in, safe, medium, or advanced. Experienced users should use the advanced method.
  5. Click next. Revo Uninstaller will remove the program and scan Windows.
  6. The window that opens will display the entries left in the registry. Mark them with checkboxes and click Remove.
  7. The next window will display a list of folders and files saved after uninstallation. Check the ones you don't need and click Remove.
Share