Skip to content

Overview

Linux provides commands to monitor processes, manage system resources, and control services. These are essential for:

  • System monitoring

  • Performance tuning

  • Troubleshooting

  • Cybersecurity and incident response


Process Monitoring Commands

top — Real-Time Process Viewer

top

Explanation

  • Displays running processes in real time

  • Shows CPU usage, memory usage, and system load

Key Information Displayed

  • PID (Process ID)

  • User

  • CPU and memory usage

  • Running time


htop — Interactive Process Viewer

htop

Explanation

  • Advanced version of top

  • User-friendly interface

  • Allows scrolling, searching, and killing processes interactively


free — Memory Usage

free -h

Explanation

  • Displays total, used, and free memory

  • -h → human-readable format (MB/GB)

Example Output

              total   used   free   shared   buff/cache   available
Mem:           8.0G   2.5G   3.0G     200M        2.5G        5.0G

ps — Process Snapshot

ps aux

Explanation

  • Displays a snapshot of all running processes

Breakdown

  • a → all users

  • u → detailed format

  • x → include background processes


kill — Terminate Process

kill PID

Example

kill 1234

Explanation

  • Sends a signal to terminate a process

  • Default signal is SIGTERM (graceful stop)


Force Kill Process

kill -9 PID

Explanation

  • -9 → SIGKILL (forcefully terminates process)

  • Use only if normal kill fails


Systemd — Service Management

systemctl — Control Services

systemctl <action> servicename

Common Actions

Action Description
start Start service
stop Stop service
status Show status
restart Restart service
reload Reload configuration

Example

systemctl start tor

Check Service Status

systemctl status ssh

Services at Startup

Check if Service is Enabled

systemctl is-enabled servicename

Enable Service at Startup

systemctl enable servicename

Disable Service at Startup

systemctl disable servicename

Reload Systemd Configuration

systemctl daemon-reload

Explanation

  • Reloads service configuration files

  • Required after modifying service files


System V — Legacy Service Management

service Command

service servicename <action>

Example

service apache2 start

Available Actions

Action Description
start Start service
stop Stop service
status Check status
restart Restart service

Practical Examples

Monitor System Processes

top
htop

Check Memory Usage

free -h

Find and Kill Process

ps aux | grep apache
kill 1234

Manage Services

systemctl start nginx
systemctl status nginx
systemctl enable nginx

Important Notes

  • htop may need installation (sudo apt install htop)

  • Always verify PID before killing a process

  • Prefer systemctl over service in modern systems

  • Use kill -9 only when necessary


Summary Table

Command Purpose
top Real-time process monitoring
htop Interactive process viewer
free -h Memory usage
ps aux Process snapshot
kill Terminate process
systemctl Manage services
service Legacy service control

Conclusion

Process and service management commands are essential for:

  • Monitoring system performance

  • Managing applications and services

  • Troubleshooting issues

Mastering these tools provides complete control over Linux system operations and is crucial for system administrators and cybersecurity professionals.