0%

Linux-Debian杂谈

rc.local服务

systemd 服务配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
root@debian9 ~ # cat /lib/systemd/system/rc.local.service
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

初始化rc.local

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cat <<EOF >/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
EOF

记得加权限chmod +x /etc/rc.local

启动服务

systemctl start rc-local

重新设定字符集

1
dpkg-reconfigure locales

设定启动级别

systemctl+grub

debian
1
2
3
systemctl get-default #查看默认启动级别
systemctl list-units --type=target #查看所有target
systemctl set-default multi-user.target #设定默认启动级别,多用户文本模式
ubuntu

将GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"的一行注释掉: # GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 将GRUB_CMDLINE_LINUX=""的一行修改为: GRUB_CMDLINE_LINUX="text" 去掉#GRUB_TERMINAL=console一行的注释,即修改为: GRUB_TERMINAL=console

1
2
3
update-grub
systemctl set-default multi-user.target
reboot
恰饭,恰饭