Terminal and shell

List and kill a process by name

Find a program that is stuck or still running in the background, then stop it by its name.

Fill these in once
  1. List the matching processes
    Terminal
    pgrep -fl node

    Each line shows the process number (PID) and the command. No output means nothing is running.

  2. Stop them
    Terminal
    pkill -f node

    -f matches the whole command line, so check the list above first: it stops everything that matched.

  3. Only if it won't stop: force it
    Terminal
    pkill -9 -f node

    This skips the program's own clean-up, so unsaved work in it is lost.

Check it worked

  1. Check it's gone
    Terminal
    pgrep -fl node

    No output means it has stopped.

  1. List the matching processes
    Terminal · Ubuntu / Debian
    pgrep -af node

    Each line shows the process number (PID) and the command. No output means nothing is running.

  2. Stop them
    Terminal · Ubuntu / Debian
    pkill -f node

    -f matches the whole command line, so check the list above first: it stops everything that matched. Add sudo if the process belongs to another user.

  3. Only if it won't stop: force it
    Terminal · Ubuntu / Debian
    pkill -9 -f node

    This skips the program's own clean-up, so unsaved work in it is lost.

Check it worked

  1. Check it's gone
    Terminal · Ubuntu / Debian
    pgrep -af node

    No output means it has stopped.

  1. List the matching processes
    PowerShell
    Get-Process *node*

    Use the name without .exe. The Id column is the process number.

  2. Stop them
    PowerShell
    Stop-Process -Name node

    Stops every process with exactly that name.

  3. Only if it won't stop: force it
    PowerShell
    Stop-Process -Name node -Force

    This skips the program's own clean-up, so unsaved work in it is lost. Programs started as administrator need an administrator PowerShell.

Check it worked

  1. Check it's gone
    PowerShell
    Get-Process node -ErrorAction SilentlyContinue

    No output means it has stopped.