3.1. 2018-01-02-练习systemd

3.1.1. 练习1

1、为编译安装的httpd服务,实现service unit文件

2、破解centos7 口令

方法1:

  1. 在启动的时候添加内核参数rd.break

  2. chmount -o remount,rw /sysroot ; chroot /sysroot

  3. passwd ;

  4. touch /.autorelabel

方法2:

  1. 启动的时候修改r为rw,添加内核参数init=/sysroot/bin/bash

  2. chroot /sysroot

  3. passwd

  4. touch /.autorelabel

3、修改默认的启动内核为新编译内核

1. 查看新内核在/boot/grub2/gurb.cfg里面的menuententry。
2. 修改/etc/default/grub中GRUB_DEFAULT=1
3. grub2-mkconfig
4. 重启即可

4、启动时临时禁用SELinux

selinux=0

5、启动时进入emergency模式

systemd.unit=emergency.target

6、卸载编译安装的新内核

1. 删除/boot目录对应文件
2. 删除/lib/modules对应文件
3. grub2-mkconfig
4. 重启