
Linux process commands: Inspect and manage Linux processes with ps, top, pgrep and signals. The guide explains graceful termination and why force-killing should be a last resort. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.
Before you start
Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.
Syntax at a glance
Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.
Quick command reference
| Command | What it does | Example | Useful options |
|---|---|---|---|
ps | Show a process snapshot | ps aux | -ef is another widely used listing format |
top | Monitor processes interactively | top | Press q to quit; sorting keys vary by implementation |
pgrep | Find process IDs by name or pattern | pgrep -a nginx | -f matches full command lines; -a prints commands on common systems |
kill | Send a signal to a process ID | kill -TERM 4321 | TERM requests graceful shutdown; KILL should be a last resort |
nice | Start a process with adjusted scheduling priority | nice -n 10 ./batch-job | More positive niceness generally lowers scheduling priority |
Command syntax and examples explained
1. ps
Purpose: Show a process snapshot.
Syntax
ps [OPTIONS]Example
ps auxOptions and notes: -ef is another widely used listing format.
Process-list arguments differ slightly between Unix variants.
2. top
Purpose: Monitor processes interactively.
Syntax
topExample
topOptions and notes: Press q to quit; sorting keys vary by implementation.
Use it to spot processes consuming CPU or memory.
3. pgrep
Purpose: Find process IDs by name or pattern.
Syntax
pgrep [OPTIONS] PATTERNExample
pgrep -a nginxOptions and notes: -f matches full command lines; -a prints commands on common systems.
Patterns can match more than one process; review IDs before stopping anything.
4. kill
Purpose: Send a signal to a process ID.
Syntax
kill -SIGNAL PIDExample
kill -TERM 4321Options and notes: TERM requests graceful shutdown; KILL should be a last resort.
Confirm the PID first; PIDs can change after a process exits.
5. nice
Purpose: Start a process with adjusted scheduling priority.
Syntax
nice [OPTION] COMMANDExample
nice -n 10 ./batch-jobOptions and notes: More positive niceness generally lowers scheduling priority.
Priority adjustment is not a hard CPU limit and may not solve resource bottlenecks.
Common mistakes and troubleshooting
- Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
- Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
- Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
- Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.
Safety tips
Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.
Frequently asked questions
Do these commands work on every system?
Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.
Can I copy and run every example exactly?
Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.
Conclusion
Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.