Commands that system administrators of Linux service management need to master

Source: Internet
Author: User
Tags comparison table

The main command-line tool for SYSTEMD is systemctl. Most Linux system administrators should already be familiar with system services and INIT system management, such as the use of Service,chkconfig and Telinit commands. SYSTEMD also accomplishes the same management tasks, but the syntax of the command tool Systemctl is different.

1. Sysvinit and Systemd's command comparison list

The following table helps system administrators understand the commands in SYSTEMD that can replace the original Sysvinit workflow. Note: Both the service and Chkconfig commands are still available in the SYSTEMD environment. Here is an example of the SSHD service:

Sysvinit command
SYSTEMD command
Note
Service sshd Start
Systemctl Start Sshd.service
Used to start a service (does not restart the existing service)
Service sshd Stop
Systemctl Stop Sshd.service
Used to stop a service (does not restart the existing service)
Service sshd Restart
Systemctl Restart Sshd.service
Used to stop and start a service
Service sshd Reload
Systemctl Reload Sshd.service
When supported, reloads the configuration file without interrupting the wait operation
Service sshd Condrestart
Systemctl Condrestart Sshd.service
If the service is running, restart it
Service sshd Status
Systemctl Status Sshd.service
Reporting whether the service is running
ls/etc/rc.d/init.d/
Systemctl List-unit-files--type=service
Ls/lib/systemd/system/*.service
/etc/systemd/system/*.service
Used to list the services that can be started or stopped
Chkconfig sshd on
Systemctl Enable Sshd.service
Set the service to start at the next startup or when other trigger conditions are met
Chkconfig sshd off
Systemctl Disable Sshd.service
Setting the service to disabled at the next startup or when other trigger conditions are met
Chkconfig sshd
Systemctl is-enabled Sshd.service
Used to check whether a service is configured to be enabled or disabled in the current environment
Chkconfig--list
Systemctl list-unit-files--type=service (recommended)
Ls/etc/systemd/system/*.service
Output enabled and disabled for the service under each run level
Chkconfig sshd--list
Ls/etc/systemd/system/*.wants/sshd.service
Used to list which runlevel the service is enabled and disabled
Chkconfig sshd--add
Systemctl Daemon-reload
used when creating a new service file or changing settings

Note: All/sbin/service and/sbin/chkconfig listed above can still work in SYSTEMD environment and will be translated into native equivalent commands if necessary. The only exception is Chkconfig--list.

Sysvinit and Systemd Change the Run level command comparison table:

Sysvinit command
SYSTEMD command
Note
Telinit 3
Systemctl Isolate Multi-user.target
Or
Systemctl Isolate Runlevel3.target OR telinit 3
Changing the maximum user run level
Sed s/^id:.*:initdefault:/id:3:initdefault:/
Ln-sf/lib/systemd/system/multi-user.target/etc/systemd/system/default.target
Set the multi-user run level to be used at the next startup

Sysvinit and SYSTEMD Power management Command Comparison table:

Sysvinit command
SYSTEMD command
Operation
Reboot
Systemctl reboot
Restarting the machine
Halt-p
Systemctl Poweroff
Shutdown
echo Standby >/SYS/POWER/STATC
Systemctl suspend
Standby
echo Platform >/sys/power/dist; Echo Dist >/sys/power/state
Or
echo Shutdown >/sys/power/disk;echo dist >/sys/power/state
Systemctl Hibernate
Dormancy

Systemctl Hybrid-sleep
Mixed sleep mode (simultaneously hibernate to hard drive and standby)

The shutdown command is not available to every logged-on user under any circumstances, and is generally only available to administrators.

2. Systemctl Command Instances

Basic usage of 2.1 systemctl

    • systemctl--lists all loaded cells and their status (unit is the term for Task/service).

    • Systemctl list-units--Lists all the units.

    • Systemctl start [NAME ...] --Start (activate) one or more cells.

    • Systemctl stop [NAME ...] --Stop (deactivate) one or more cells.

    • systemctl disable [NAME ...] --Disables one or more cell files.

    • Systemctl list-unit-files--displays all installed cell files and their status.

    • Systemctl--failed--shows which units have failed during startup.

    • Systemctl--type=xxx--type filter; type may be: Service, mount point, device, socket, and start target.

    • Systemctl enable debug-shell.service--to start the shell on TTY 9 for debugging.

Commands that system administrators of Linux service management need to master

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.