Linux 服务控制与运行级别
发布时间:2020-12-14 00:08:19 所属栏目:Linux 来源:网络整理
导读:如何控制服务的运行状态?如何切换不同的运行级别? 服务控制 ntsysv 仿图形交互界面,集中配置各种服务启动状态 --level 35 :同时对指定运行级别中的服务进行管理,不加仅管理当前运行级别中的服务。 [[email?protected] ~]# ntsysv --level 35 systemctl
如何控制服务的运行状态?如何切换不同的运行级别? 服务控制ntsysv
[[email?protected] ~]# ntsysv --level 35 systemctl
[[email?protected] ~]# systemctl start httpd.service [[email?protected] ~]# systemctl stop httpd.service
[[email?protected] ~]# systemctl restart httpd.service [[email?protected] ~]# systemctl reload httpd.service
[[email?protected] ~]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2019-08-27 17:31:39 CST; 40s ago Docs: man:httpd(8) man:apachectl(8) Process: 8833 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited,status=0/SUCCESS) Main PID: 8821 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─8821 /usr/sbin/httpd -DFOREGROUND ├─8835 /usr/sbin/httpd -DFOREGROUND ├─8836 /usr/sbin/httpd -DFOREGROUND ├─8837 /usr/sbin/httpd -DFOREGROUND ├─8838 /usr/sbin/httpd -DFOREGROUND └─8839 /usr/sbin/httpd -DFOREGROUND Aug 27 17:31:39 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Aug 27 17:31:39 localhost.localdomain httpd[8821]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name,using localhost.l...s message Aug 27 17:31:39 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Aug 27 17:31:45 localhost.localdomain httpd[8833]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name,using localhost.l...s message Aug 27 17:31:45 localhost.localdomain systemd[1]: Reloaded The Apache HTTP Server. Hint: Some lines were ellipsized,use -l to show in full. [[email?protected] ~]# systemctl is-active httpd.service active [[email?protected] ~]# systemctl is-failed httpd.service active
[[email?protected] ~]# systemctl enable httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [[email?protected] ~]# systemctl disable httpd.service Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service. [[email?protected] ~]# systemctl is-enabled httpd.service disabled
[[email?protected] ~]# systemctl list-dependencies httpd.service httpd.service ● ├─-.mount ● ├─system.slice ● └─basic.target ● ├─microcode.service ● ├─rhel-autorelabel-mark.service ● ├─rhel-autorelabel.service ● ├─rhel-configure.service ● ├─rhel-dmesg.service ● ├─rhel-loadmodules.service ● ├─[email?protected] ● ├─paths.target ● ├─slices.target ● │ ├─-.slice ● │ └─system.slice ● ├─sockets.target ● │ ├─dbus.socket ● │ ├─dm-event.socket ● │ ├─systemd-initctl.socket ● │ ├─systemd-journald.socket ● │ ├─systemd-shutdownd.socket ● │ ├─systemd-udevd-control.socket ● │ └─systemd-udevd-kernel.socket ● ├─sysinit.target ● │ ├─dev-hugepages.mount ● │ ├─dev-mqueue.mount ● │ ├─kmod-static-nodes.service ● │ ├─lvm2-lvmetad.socket ● │ ├─lvm2-lvmpolld.socket ● │ ├─lvm2-monitor.service ● │ ├─plymouth-read-write.service ● │ ├─plymouth-start.service ● │ ├─proc-sys-fs-binfmt_misc.automount ● │ ├─sys-fs-fuse-connections.mount ● │ ├─sys-kernel-config.mount ● │ ├─sys-kernel-debug.mount ● │ ├─systemd-ask-password-console.path ● │ ├─systemd-binfmt.service ● │ ├─systemd-firstboot.service ● │ ├─systemd-hwdb-update.service ● │ ├─systemd-journal-catalog-update.service ● │ ├─systemd-journal-flush.service ● │ ├─systemd-journald.service ● │ ├─systemd-machine-id-commit.service ● │ ├─systemd-modules-load.service ● │ ├─systemd-random-seed.service ● │ ├─systemd-sysctl.service ● │ ├─systemd-tmpfiles-setup-dev.service ● │ ├─systemd-tmpfiles-setup.service ● │ ├─systemd-udev-trigger.service ● │ ├─systemd-udevd.service ● │ ├─systemd-update-done.service ● │ ├─systemd-update-utmp.service ● │ ├─systemd-vconsole-setup.service ● │ ├─cryptsetup.target ● │ ├─local-fs.target ● │ │ ├─-.mount ● │ │ ├─boot.mount ● │ │ ├─rhel-import-state.service ● │ │ ├─rhel-readonly.service ● │ │ └─systemd-remount-fs.service ● │ └─swap.target ● │ └─dev-mapper-centosx2dswap.swap ● └─timers.target ● └─systemd-tmpfiles-clean.timer
[[email?protected] ~]# systemctl mask firewalld.service Created symlink from /etc/systemd/system/firewalld.service to /dev/null. [[email?protected] ~]# systemctl unmask firewalld.service Removed symlink /etc/systemd/system/firewalld.service. 运行级别runlevel
[[email?protected] ~]# runlevel N 5 切换多用户模式两种方法: [[email?protected] ~]# init 3 [[email?protected] ~]# systemctl isolate multi-user.target 切换图形化界面两种方法: [[email?protected] ~]# init 5 [[email?protected] ~]# systemctl isolate graphical.target 开机默认 target1.查看默认启动 [[email?protected] ~]# systemctl get-default graphical.target 2.切换默认启动 [[email?protected] ~]# systemctl set-default multi-user.target Removed symlink /etc/systemd/system/default.target. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target. [[email?protected] ~]# ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target 3.查看默认启动 [[email?protected] ~]# systemctl get-default multi-user.target (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |