rc-status (with examples)

rc-status (with examples)

Summary of services and their status

rc-status

Motivation:

When managing a system, it is essential to have an overview of the services and their current status. The rc-status command provides a summary of all services along with their statuses.

Explanation:

The rc-status command without any additional arguments displays a summary of services and their status. It shows whether each service is running (started), stopped (inactive), crashed (failed), or provides other status information.

Example Output:

Runlevel: default
 syslog-ng [ started ]
 cron [ inactive ]
 apache2 [ started ]
 nginx [ inactive ]

This output shows the services syslog-ng, cron, apache2, and nginx along with their current status. syslog-ng and apache2 are currently running, while cron and nginx are inactive.

Include services in all runlevels in the summary

rc-status --all

Motivation:

By default, rc-status displays the summary only for the current runlevel. However, including services from all runlevels can provide a comprehensive overview of the system’s overall status.

Explanation:

Passing the --all argument to the rc-status command extends the summary to include services from all runlevels. This allows detecting issues or inconsistencies across different runlevels.

Example Output:

Runlevel: default
 syslog-ng [ started ]
 cron [ inactive ]
 apache2 [ started ]
 nginx [ inactive ]

Runlevel: single
 wpa_supplicant [ inactive ]
 sshd [ inactive ]

In this example, the output includes services from both the default and single runlevels. This helps identify if a service is active in one runlevel but inactive in another.

List services that have crashed

rc-status --crashed

Motivation:

Crashed services can impact the stability and functionality of a system, so it is crucial to identify them promptly. By listing only the crashed services, administrators can focus on resolving critical issues.

Explanation:

The --crashed argument filters the output of rc-status to display only services that have crashed. This allows administrators to quickly identify and address problematic services.

Example Output:

 apache2 [ failed ]

In this example, only the apache2 service is shown because it has crashed. The output helps pinpoint the problematic service without including unnecessary information.

List manually started services

rc-status --manual

Motivation:

It is common for system administrators to manually start certain services when they are needed. Identifying these manually started services provides insights into the manual management of the system’s services.

Explanation:

The --manual argument filters the output of rc-status to list only the services that were manually started by the administrator. This can be helpful in understanding the manual configurations and interventions in the system.

Example Output:

 cron [ started ]

In this example, the cron service is shown as it was started manually. The output indicates that the administrator previously started this service rather than relying on automatic startup during boot.

List supervised services

rc-status --supervised

Motivation:

Supervised services are those that are managed by a supervision program, typically installed to ensure services remain running. Identifying these supervised services can provide insights into the overall management of the system.

Explanation:

The --supervised argument filters the output of rc-status to list only the supervised services. This allows administrators to determine which services are under the control of a supervision program.

Example Output:

 apache2 [ started ]
 nginx [ inactive ]

In this example, the apache2 service is shown as it is supervised. However, the nginx service is not supervised. The output indicates that apache2 is managed by a supervision program, while nginx is not.

Get the current runlevel

rc-status --runlevel

Motivation:

Knowing the current runlevel can be helpful when troubleshooting or managing the system. It allows administrators to understand which set of services is active and running at a given moment.

Explanation:

The --runlevel argument instructs rc-status to display only the services for the current runlevel. This information reflects the state of the system at that specific runlevel.

Example Output:

Runlevel: default
 syslog-ng [ started ]
 cron [ inactive ]
 apache2 [ started ]
 nginx [ inactive ]

In this example, the output displays the current runlevel as default. The services shown are the ones defined for this runlevel, indicating their current status.

List all runlevels

rc-status --list

Motivation:

Understanding the available runlevels can help administrators comprehend how the system’s services are organized and which services are active in each runlevel.

Explanation:

The --list argument provides a list of all available runlevels and their associated services. This allows administrators to determine the structure and configuration of the system.

Example Output:

Runlevel: sysinit
 fsck [ started ]
 sysfs [ started ]

Runlevel: single
 wpa_supplicant [ inactive ]
 sshd [ inactive ]

Runlevel: multiuser
 syslog-ng [ started ]
 cron [ inactive ]
 apache2 [ started ]
 nginx [ inactive ]

In this example, the output includes the runlevels sysinit, single, and multiuser, along with the services defined in each runlevel. The services listed under each runlevel represent the configuration of the system at that particular runlevel.

Related Posts

How to use the command `astyle` (with examples)

How to use the command `astyle` (with examples)

The command astyle is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages.

Read More
How to use the command xdotool (with examples)

How to use the command xdotool (with examples)

The xdotool command is a command-line automation tool for X11, which allows users to simulate keyboard input, mouse activity, and manipulate windows in the X Window System.

Read More
How to use the command swaybg (with examples)

How to use the command swaybg (with examples)

Swaybg is a wallpaper tool specifically designed for Wayland compositors. It allows users to set their wallpaper to an image or a static color, as well as choose from different wallpaper modes such as stretch, fit, fill, center, tile, or solid color.

Read More