Skip to content

kill Command on ChromeOS Linux Environment

The kill command is a powerful tool for terminating processes in Linux. It sends signals to processes, allowing you to manage their execution. On ChromeOS Linux (Crostini), kill is essential for troubleshooting and controlling running applications.


Syntax

The basic syntax of the kill command is:

kill [options] <pid>

Key Components:

  • <pid>: The Process ID (PID) of the process to terminate.
  • options: Modify the behavior or specify the signal to send.

Signals

The kill command sends signals to processes. Common signals include:

Signal NameSignal NumberDescription
SIGTERM15Gracefully terminate a process (default).
SIGKILL9Forcefully terminate a process immediately.
SIGHUP1Reload configuration or restart a process.
SIGSTOP19Stop (pause) a process.
SIGCONT18Continue a stopped process.

Examples of Usage

Terminate a Process

To terminate a process with a specific PID:

kill 1234

This sends the default SIGTERM signal, allowing the process to terminate gracefully.

Force Terminate a Process

If a process does not respond to SIGTERM, use SIGKILL:

kill -9 1234

This forcefully terminates the process.

Send a Specific Signal

To send a specific signal to a process:

kill -1 1234

This sends the SIGHUP signal, often used to reload a process’s configuration.

Kill Multiple Processes

You can terminate multiple processes by specifying their PIDs:

kill 1234 5678 91011

Use Process Name with pkill

Instead of using kill with a PID, use pkill to terminate processes by name:

pkill process_name

List All Signals

To see a list of available signals:

kill -l

Example Output:

 1) SIGHUP  2) SIGINT  3) SIGQUIT  4) SIGILL  ...

Finding Process IDs (PIDs)

Before using kill, you need to identify the PID of the process. Use one of the following methods:

Using ps

List all running processes:

ps aux

Filter for a specific process:

ps aux | grep process_name

Using top or htop

  • Run top or htop to view active processes and their PIDs interactively.
  • Use the arrow keys to navigate and note the PID of the desired process.

Using pgrep

Find the PID of a process by name:

pgrep process_name

Troubleshooting

Permission Denied

If you encounter a "Permission denied" error, the process may belong to another user or require elevated privileges. Use sudo:

sudo kill 1234

Process Not Terminating

If a process does not terminate with SIGTERM, force it using SIGKILL:

kill -9 1234

PID Not Found

Ensure the process is still running and verify the PID. Use ps, top, or pgrep to locate the correct PID.

Best Practices

  1. Use SIGTERM First: Always attempt graceful termination before using SIGKILL.
  2. Verify PIDs: Double-check the PID to avoid accidentally terminating critical processes.
  3. Use pkill or pgrep: Simplify process management by using these tools to work with process names.
  4. Combine with Other Tools: Pair kill with ps or grep to streamline process identification and termination.

The kill command is a critical tool for managing processes in Linux. By understanding its options and signals, ChromeOS users can effectively control and troubleshoot applications in their Linux environment.