Every running program on Linux gets a unique number called a Process ID (PID). Sometimes programs freeze or consume excessive resources. You need to stop them manually.

Learning how to kill PID entries helps you manage your system effectively. The kill command sends signals to processes, telling them to stop.

By default, it requests programs to close gracefully. However, stubborn applications may need stronger measures. This guide shows you the proper way to terminate processes on your Linux system.

How To Kill PID?

Find the Process ID

Before terminating anything, you must identify the target process number. Several methods work for this task.

The ps utility displays active programs with their assigned numbers. Run this command:

ps -e

For easier navigation, combine it with grep to filter results:

ps -e | grep firefox

The pgrep utility directly returns process numbers by name. Much simpler than manual filtering:

pgrep chrome

The top utility shows live system activity. You can observe resource consumption alongside process numbers.

Choose the Right Signal

Different signals produce different results when stopping processes. SIGTERM (signal 15) requests graceful shutdown. SIGKILL (signal 9) forces immediate termination.

Always start with SIGTERM. This allows programs to save data and release resources properly.

Use SIGKILL only when programs refuse to close. This prevents cleanup operations, so use it sparingly as a final resort.

Execute the Kill Command

Once you identify your target number, stopping it becomes straightforward. The basic structure looks like this:

kill 5678

This sends the default SIGTERM signal. For explicit signal specification:

kill -15 5678

When programs refuse to close, use the forceful method:

kill -9 5678

You can view all available kill command options using:

kill -L

Verify the Process Stopped

After attempting termination, confirm your action worked. Check if the process still exists:

ps -e | grep 5678

Empty output means success. The program no longer runs on your system.

Sometimes identical programs spawn several instances. You can terminate them using pkill or pgrep in a loop:

for pid in $(pgrep nginx); do kill $pid; done

For processes bound to specific ports, you might need to kill process on port directly. This helps when encountering “address already in use” errors.

FAQs

What does kill -9 do?

Kill -9 sends SIGKILL signal for immediate termination. It forces the process to stop without cleanup. Use only when graceful termination fails.

Can I kill multiple PIDs at once?

Yes, you can specify multiple process numbers. Use kill 1234 5678 9012 to stop three processes simultaneously. Each receives the same signal.

Why won’t my process die?

Zombie processes or system-critical tasks may resist termination. Check if you need root privileges. Some processes require sudo kill -9 PID for forceful removal.

How do I kill all processes by name?

Use pkill command followed by the process name. Example: pkill firefox stops all Firefox instances. Add -9 flag for forceful termination if needed.

What happens after killing a process?

The operating system releases all resources held by that process. Memory gets freed, file handles close, and network connections terminate. Child processes may become orphaned.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.