Raspberry Pi自动登录没有etc/inittab

ADT*_*ank 8 raspberry-pi raspbian

我想将我的Raspberry Pi设置为在特定用户中自动登录.我搜索了这个,我发现的解决方案是关于编辑/ etc/inittab文件.我的问题是现在我没有那个文件,它似乎在我的Raspbian版本中丢失了.还有另一种方法吗?

小智 6

我的autologin.conf文件如下所示.注意%I,我的pi挂起了:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux
Run Code Online (Sandbox Code Playgroud)

  • 不知道为什么这是低估的.解决方案@TomMekken的解决方案对我不起作用,但@Steve的确如此.对我来说,"额外的"`ExecStart =`是至关重要的. (3认同)

Tom*_*ken 5

我假设您使用的是最新的 Raspian-Image (jessie)。这个基于 Debian 8 (jessie),其中 init-system 从 sysvinit 更改为 systemd。我认为这可能与您的问题有关。如果您使用谷歌搜索:raspbian jessie auto login您应该为您的问题找到解决方案。

pe 这个链接提供了一个可能的解决方案:

$ sudo -i
# mkdir -pv /etc/systemd/system/getty@tty1.service.d
# nano /etc/systemd/system/getty@tty1.service.d/autologin.conf
Run Code Online (Sandbox Code Playgroud)

插入以下案文:

[Service]
ExecStart=-/sbin/agetty --autologin $username --noclear I 38400 linux
Run Code Online (Sandbox Code Playgroud)

确保这$username是您的用户名

然后重启。

可选的:

如果要自动启动 X-Server,只需在 ~/.profile 末尾添加以下行

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
Run Code Online (Sandbox Code Playgroud)

  • 此解决方案不起作用,它会中断树莓派启动。 (3认同)