bseal
Posts: 3
Joined: Sun Nov 10, 2013 8:04 pm

etc/inittab auto login frustration~!

Thu Nov 14, 2013 8:57 pm

Yes, like the thousands of others posting (many it seems with a similar question) I am new to linux/ rpi. Until now I've been successful with getting my questions answered via google and this forum. However, for the life of me I can not seem to get my raspberry pi to bypass the command line login screen.

End Goal

Have my pi always be running a python script. This python script is always waiting for a password to be entered via a small usb 10-keyboard. If the correct password is entered, one of the GPIO pin triggers a solenoid unlocking a drawer.

So for I've managed to configure the python script to load upon the "pi" user logging in. I thought that would be the hardest part. WRONG! Getting the dang thing to automatically log in as "pi" is posing to being much more of a challenge.

What I've tried so far...

From reading countless forums and blog posts from all around the interwebs, I gathered that the best (and possibly only) way of auto logon is by editing the inittab file located in the /etc. I ventured to do just that, I found several similar ways of doing it, all invlolved editing the same line, but each in their own way. I tried them all. As i'm sure the well versed linux people know, if you comment out line 55 to look like this:

Code: Select all

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
you can replace it with (here is the most popular way I found):

Code: Select all

1:2345:respawn:/bin/login -f rfid tty1 </dev/tty1 >/dev/tty1 2>&1
This did not work, and after the boot process complete, i continue to see the same login screen.

Here are some of the other variations I found, I tried them all to no avail:

Code: Select all

1:2345:respawn:/sbin/getty -n pi 38400 tty1  

1:2345:respawn:/sbin/getty --autologin pi --noclear 38400 tty1

1:2345:respawn:/bin/login -f pi tty2 </dev/tty1 >/dev/tty2 2>&1

1:23345:respawn:/sbin/getty -a pi 38400 tty1
My next thought, there must be a log file somewhere giving me some indication if its even trying to auto login. The closest "clue" I found was in /var/log/auth.log. I noticed the following line always happening at the end of every boot sequence:

Code: Select all

Nov 14 12:24:38 raspberrypi perl: pam_unix(webmin:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
To me (a noob) this sure looks like an attempt at loggin it, but none of the parameters are there, thus it fails. Then again this may have nothing to do with my problem and might be related to something completely different. I'm hoping the "experts" can shed some light.

To be sure I've covered all my bases, here is my inittab file in its entirety (with the most popular edit):

Code: Select all

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#


1:2345:respawn:/bin/login -f rfid tty1 </dev/tty1 >/dev/tty1 2>&1
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
#1:2345:respawn:/sbin/getty -n pi 38400 tty1  
#1:2345:respawn:/sbin/getty --autologin pi --noclear 38400 tty1
#1:2345:respawn:/bin/login -f pi tty2 </dev/tty1 >/dev/tty2 2>&1
#1:23345:respawn:/sbin/getty -a pi 38400 tty1

2:23:respawn:/sbin/getty 38400 tty2
#2:23:respawn:/sbin/getty -a pi 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3


#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
lastly, my distribution:

PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"


Any help would be very much appreciated!

videoicu
Posts: 1
Joined: Sun Nov 24, 2013 2:21 pm

Re: etc/inittab auto login frustration~!

Sun Nov 24, 2013 2:28 pm

I am no expert but this worked for me for autologin. I commented out the default code

Code: Select all

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1 
I assume in your example that your pi has a user login name of "rfid"? If you have not changed it then it is "pi" by default.

bseal
Posts: 3
Joined: Sun Nov 10, 2013 8:04 pm

Re: etc/inittab auto login frustration~!

Mon Nov 25, 2013 4:47 pm

I have this working now. Not sure what I had done, but i started with a fresh install of wheezy 7, then this worked like it was supposed to.

Not sure if something i installed had changed the way linux was loading, but it alsmost seemed as if it wasn't using the etc/inittab file at all.

All is well and the following worked fine for me.

Code: Select all

1:2345:respawn:/bin/login -f rfid tty1 </dev/tty1 >/dev/tty1 2>&1

User avatar
DougieLawson
Posts: 42306
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: etc/inittab auto login frustration~!

Mon Nov 25, 2013 5:58 pm

bseal wrote:I have this working now. Not sure what I had done, but i started with a fresh install of wheezy 7, then this worked like it was supposed to.

Not sure if something i installed had changed the way linux was loading, but it alsmost seemed as if it wasn't using the etc/inittab file at all.

All is well and the following worked fine for me.

Code: Select all

1:2345:respawn:/bin/login -f rfid tty1 </dev/tty1 >/dev/tty1 2>&1
In your original posts you were aiming at tty2 not tty1. So would have needed to use CTRL+ALT+2 to see the terminal where the login was happening. The default (of the six running getty) is tty1 (CTRL+ALT+1). Xwindows usually uses CTRL+ALT+7 or CTRL+ALT+8.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Return to “General programming discussion”