小编Mar*_*aro的帖子

如何在 Arch Linux 的登录屏幕上显示 IP

我可以通过编辑文件在 Ubuntu 中执行以下操作:

/etc/rc.local
Run Code Online (Sandbox Code Playgroud)

并添加:

IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')

echo "IP: $IP" > /etc/issue
Run Code Online (Sandbox Code Playgroud)

在 Arch 中,这个文件不存在“/etc/rc.local”,经过一番搜索,我发现我必须创建这个文件:

/etc/systemd/system/rc-local.service
Run Code Online (Sandbox Code Playgroud)

内容:

[Unit]
Description=/etc/rc.local compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local

TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

然后创建“/etc/rc.local”。

内容:

IP=$(/sbin/ip route get 1 | awk '{print $NF;exit}')
echo "IP: $IP" > /etc/issue

exit 0
Run Code Online (Sandbox Code Playgroud)

然后使其可执行:

sudo chmod +x /etc/rc.local
Run Code Online (Sandbox Code Playgroud)

最后开始/测试:

sudo systemctl start rc-local.service
Run Code Online (Sandbox Code Playgroud)

得到错误:

Job for rc-local.service failed because the control process exited with …
Run Code Online (Sandbox Code Playgroud)

bash arch-linux systemd

4
推荐指数
1
解决办法
1685
查看次数

标签 统计

arch-linux ×1

bash ×1

systemd ×1