Linux的启动与进程管理[上]

一、启动管理

1、启动过程

        //不需要自己操作,仅需等待登录,不多赘述

2、Linux运行级别

查询:

使用runlevel指令

        会提醒上次所处的运行级别和当前系统正在运行的运行级别

        系统开机时就进入级别x(x可为数字0~6)

        因此上一次的运行级别没有,用N表示

切换:

使用init x

        注:x表示运行级别的数字,可为0~6

二、服务单元控制

这里介绍如何在systemd中控制服务:

通常将服务称为单元,包含:服务、挂载点、系统设备等

1)查看系统中的单元:

1、systemctl

(注:其中的l是字母l,不是数字1或i)

不知道为什么以为是数字1,结果找了各种方法都不行,报错为:

但在此整理两种搜到的方法

注:解决:systemctl: command not found

1、使用 service指令替代
service redisd start
service redisd restart
service network restart
2、安装 systemctl
安装 systemctl
sudo apt-get install --reinstall systemd

设置服务开机启动
sudo systemctl enable ssh

输入后得到:

2、list-units

2)查看运行失败的单元:

systemctl -- failed

3)查看系统中安装的服务:

systemctl list-unit-files

4)启动服务单元

1、指令:

1、systemctl start 【服务名】httpd

2、systemctl start 【服务名.service】httpd.service

3、service httpd【service 服务名】 start

2、出现的问题(未完全解决):

Failed to start httpd.service: Unit httped.service not found

原因:在系统中未安装httped,调用了:

        systemctl list-unit-files查看服务,随机挑选了atd进行测试

        start指令后系统无反馈,用status查看系统运行状态:

        等效命令:

        1、systemctl status 【服务名】httpd

        2、systemctl status 【服务名.service】httpd.service

        3、service httpd【service 服务名】 status、

如果有该服务,可以重新安装该服务,调用reload(指令:systemctl daemon-reload)(未尝试)

(找了半天没找到如何安装)

        重新读取配置:

        systemctl reload httpd

        systemctl reload httpd.service

5)停止服务单元

1、指令:

1、systemctl stop 【服务名】httpd

2、systemctl stop 【服务名.service】httpd.service

3、service httpd【service 服务名】 stop

6)重启服务单元

1、指令:

1、systemctl restart 【服务名】httpd

2、systemctl restart 【服务名.service】httpd.service

3、service httpd【service 服务名】 restart

7)自启动服务单元

1、查询是否为自动启动

systemctl is-enabled 服务名

2、将服务设置为自启动

systemctl enable 服务名

3、再次查询是否为自启动

systemctl is-enabled 服务名

4、取消服务自启动

systemctl disable 服务名

8)关机重启待机操作:

systemctl poweroff

systemctl reboot

systemctl suspend

9)单元配置文件

完全不理解这个地方(page 35)

通常单元的配置文件会放在  /usr/lib/systemd/system/(存放软件安装包)

和  /etc/systemd/system(存放由系统管理员安装的与系统密切相关的单元)

若需要添加单元配置文件,需要将配置文件放到对应目录中,然后执行命令

systemctl daemon-reload就可以添加单元

(不理解的点在于作用和如何操作,后续会补)

  • 22
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值