This guide provides essential Linux commands to manage processes, monitor system performance, and work with services.
Displays active processes running for the current user in the terminal.
Fields:
-
PID: Process ID.
-
TTY: Terminal associated with the process.
-
TIME: CPU time consumed by the process.
-
CMD: Command used to run the process (e.g., bash, su).
Lists all processes in the system, including system and background tasks.
a: Shows processes of all users.
u: Includes user-related information.
x: Displays processes not attached to a terminal.
Task Status:
- S: Sleeping.
- I: Idle.
provides a detailed view of the currently running processes on the system
l: This option tells ps to display the processes in "long format". The long format includes additional fields such as priority, parent process ID (PPID), and more.
a: This option shows processes of all users (not just the current user).
x: This option shows processes without a controlling terminal (background processes or daemons).
Pauses the terminal for the specified number of seconds. Example: sleep 5 pauses for 5 seconds.
When combined with the & operator, it runs in the background, allowing the terminal or script to continue with other tasks without waiting for the sleep duration to finish. Example: sleep 10000 &.
jobs: Lists active jobs in the background.
Brings a background job to the foreground.
ctrl+z Suspends a foreground process.
Resumes a suspended job in the background.
Sends a signal to a process to terminate or control it.
Some Signals:
-15: Terminate gracefully.
-19: Stop the process.
-18: Restart a stopped process.
-9: Forcefully kill.
-2: Interrupt (Ctrl+C equivalent).
-3: Quit.
killall -9
Forcefully terminates all processes of the specified command. Example: killall -9 sleep.
Displays how long the system has been running, along with the load average.
Explanation of Each Component:
-
22:54:42:
- The current system time in 24-hour format.
-
up 1:05:
- The system uptime, i.e., how long the system has been running since the last boot.
- In this case, the system has been running for 1 hour and 5 minutes.
-
2 users:
- The number of users currently logged into the system (via terminal or remote sessions).
-
load average: 0.19, 0.39, 0.24:
- The system's load averages over the last 1, 5, and 15 minutes.
- Load average represents the average number of processes that are in the runnable or waiting state.
Shows real-time information about running processes, including CPU and memory usage.
Graphical interface for monitoring processes and system performance.
Systemctl is a command-line utility in Linux used to interact with and manage the systemd system and service manager. It allows you to control services, manage system states, and configure system settings
Displays the status of the service (e.g., httpd,sshd).
Explanation of Component:
- Loaded: Indicates that the sshd.service file is loaded, meaning the system has successfully located and read the service unit file for the SSH daemon (sshd).
- /usr/lib/systemd/system/sshd.service: This is the path to the unit file for the sshd service, which defines how the SSH daemon should be started and managed.
- enabled: This means that the SSH service is set to start automatically when the system boots.
- preset: ena: Indicates that the service has been enabled by default according to the system's preset configuration.
- Active: The service is currently running. In this case, SSH is actively serving connections.
- active (running): This means that the SSH service is actively running without any issues.
- since Sat 2024-11-30 21:49:43 IST: This is the timestamp of when the SSH service was started.
- 1h 42min ago: This indicates that the SSH service has been running for 1 hour and 42 minutes since it was started.
Stops or starts the service.
Configures the service to start automatically on boot or not.
Restarts the service.
Reloads the service configuration without restarting.
The systemctl -t slice command in Linux is used to list all slice units managed by systemd. In systemd, a slice is a concept used to group system resources and organize services into hierarchies for better resource management and control
Checks if the service is active.
Checks if the service is enabled on boot.
Displays the dependencies of the service.
Lists all failed services.
Prevents or allows the service from being started manually or automatically