博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
systemctl 常用命令
阅读量:2784 次
发布时间:2019-05-13

本文共 1076 字,大约阅读时间需要 3 分钟。

最近开始使用systemd,相比于以往使用service命令,或者直接修改/etc/init.d,或者chkconfig这样多种工具搭配来完成一个系统服务的配置,部署,systemd的野心极大,它要让一切都回归统一,redhat系已经将systemd作为了其默认的系统服务管理工具。

这篇文章记录了一些systemd常用的用法,大都是我自己会用到的。

  1. 启动级别配置

    由于工作需要,常常会在虚拟机中安装各类linux系统,而绝大部分时间,我们需要的只是一个文字界面,能够通过host ssh到VM中,图形界面没必要起着,白白浪费cpu和内存,通过systemctl命令配置默认进入文字界面,只需一行:

    systemctl set-default multi-user.target

    如果要切回图形界面,相应地:

    systemctl set-default graphical.target

  2. 开机启动服务

    systemctl enable ***.service

  3. 停止开机启动服务

    systemctl disable ***.service

  4. 启动/停止/重启服务

    systemctl start/stop/restart ***.service

  5. 查询服务状态

    systemctl status ***.service

  6. 在远程机器上执行命令,类似ssh user@host ""

    systemctl -H user@hostname

  7. 列出系统服务,-t后用tab键可以关联出所有支持的unit类型

    systemctl -t service

  8. 列出所有已经加载的units的状态

    systemctl -a

  9. 列出加载的units/sockets/timers

    systemctl list-units [pattern]

    systemctl list-sockets [pattern]
    systemctl list-timers [pattern]

  10. 查询某项服务是否active,以sshd.serice为例

    systemctl is-active sshd.service

  11. 直接查看某项服务的配置文件,以sshd.serice为例

    systemctl cat sshd.service

  12. 查看服务的依赖关系,以sshd.serice为例

    systemctl list-dependencies sshd.service

  13. 查看环境变量

    systemctl show-environment

systemctl 还能实习非常之多的系统管理配置功能,不在这一一列举了。

转载地址:http://gtfld.baihongyu.com/

你可能感兴趣的文章
Android Volley完全解析(四),带你从源码的角度理解Volley
查看>>
Android访问网络,使用HttpURLConnection还是HttpClient?
查看>>
Activity的四种启动模式
查看>>
Activity生命周期
查看>>
android BroadcastReceiver应用详解
查看>>
MeasureSpec介绍及使用详解
查看>>
apache 的工作模式
查看>>
scrapy xpath提取标签
查看>>
php扩展函数
查看>>
yaf 框架路由解析过程
查看>>
linux shell wget下载远程目录
查看>>
mysql 5.7源码 启动监听过程
查看>>
js运行上下文
查看>>
git pull fetch 更新本地文件区别
查看>>
REQUEST_URL PHP_SELF SCRIPT_NAME区别
查看>>
mysql字符集转换 过程
查看>>
Python正则表达式中的 compile,search,group,groups 函数的简单说明
查看>>
jQuery 架构分析
查看>>
shell for循环遍历csv串 的坑
查看>>
shell 脚步批量转换文件编码
查看>>