Raspberry Pi auto login without etc/inittab

限于喜欢 提交于 2019-12-08 16:41:31

问题


I would like to settup my Raspberry Pi to auto login in a specific user. I googled this and the solutions that i found were about editing the /etc/inittab file. My problem is now i dont have that file, it appears to be missing in my version of Raspbian. Is there another way to do this?


回答1:


I assume you're using the latest Raspian-Image (jessie). This one is based on Debian 8 (jessie) where the init-system changed from sysvinit to systemd. I think that it could have something to do with your problem. If you google: raspbian jessie auto login you should find a solution for your problem.

p.e. this link provides a possible solution:

$ sudo -i
# mkdir -pv /etc/systemd/system/getty@tty1.service.d
# nano /etc/systemd/system/getty@tty1.service.d/autologin.conf

insert the following text:

[Service]
ExecStart=-/sbin/agetty --autologin $username --noclear I 38400 linux

make sure that $username is your username

Then reboot.

optional:

If you want to start the X-Server automatically, just add the following line at the end of your ~/.profile

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx



回答2:


My autologin.conf file appears as below. Note the %I, my pi hangs otherwise:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux



回答3:


I found this, which is the only thing that worked for me.

Automatic Login for LightDM

Open the terminal and make first a backup of the file we are going to edit:

su - 
gedit /etc/lightdm/lightdm.gedit /etc/lightdm/lightdm.conf.back

Edit now this file:

gedit /etc/lightdm/lightdm.conf

or

nano /etc/lightdm/lightdm.conf

Uncomment these two lines:

autologin-user=USERNAME
autologin-user-timeout=0

Replace USERNAME with your own username. Save the file and exit. Run now this command so that changes are taken into effect:

dpkg-reconfigure lightdm 



回答4:


I use raspi-config:

pi@raspberrypi:~ $ sudo raspi-config
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.

There's a menu that comes up wherein you select Boot Options then something along the lines of B1 Boot Desktop Options and finally you select among several auto login options.

See: https://raspberrypi.stackexchange.com/questions/48241/auto-login-in-jessie-how



来源:https://stackoverflow.com/questions/33753985/raspberry-pi-auto-login-without-etc-inittab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!