linux自动登录|debian12实践|字符终端|自动登录|systemd|getty

发布时间 2023-06-15 23:50:21作者: smoggy

此方法适用于使用systemd启动的文件系统, debian12实践

1. 编辑此文件 /etc/systemd/system/getty.target.wants/getty@tty1.service
    或者是/etc/systemd/system/getty@tty1.service.d/autologin.conf(我的Debian12中没有找到这个目录,不知道和版本有关还是和发行版有关)。
2. 更改ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin username - $TERM
    与原文件对比, 增加了-f --autologin username这三个字段, 其中username换成你想要登录的用户名, 如root。
3. 有说法需要执行命令`sudo systemctl daemon-reload`,实际上似乎不用,直接重启系统就可以了。

参考链接:
https://www.jianshu.com/p/5eb4995d8496
https://wiki.archlinux.org/title/getty