Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have Debian 3.10 installed on a kiosk machine. I want it to automatically log in as a user so that if there's a power outage, wo don't have to walk around with a keyboard unlocking each kiosk and logging in.
We are NOT using GDM, KDM, etc. If we were, I wouldn't be asking this. We are using XFree86 and fvwm for the window manager. That's it. The only other software is firefox and whatever is installed as a bare minimum (ssh, etc...). Thanks in advance!
Create a file named autologinfred.c and type in this short C program:
Code:
int main() {
execlp( "login", "login", "-f", "fred", 0);
}
Run these commands:
gcc -o autologinfred autologinfred.c
chmod 755 autologinfred
cp autologinfred /usr/local/sbin/
Edit /etc/inittab and change the line beginning with "1:2345" so that it reads as follows:
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologinfred 38400 tty1
On some GNU/Linux distributions (like RedHat) /sbin/agetty must be used instead.
1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologinfred 38400 tty1
Make sure the default run level in /etc/inittab is init 1 or init 3
id:3:initdefault:
any idea why it doesn't seem to work right on slackware??
instead of automatically logging-in a user, it just asks for the password... like, at boot it will say "Password: " (without prompting for a username) and if you give it the password for the user you wanted to auto login it will then drop you to the shell like normal... the only way to log-in as another user is to switch to another console...
this is what my /etc/inittab looks like:
Code:
# These are the standard console login getties in multiuser mode:
#c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c1:1235:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c4:1235:respawn:/sbin/agetty 38400 tty4 linux
c5:1235:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux
my autologin.c file looks like:
Code:
int main() {
execlp( "login", "login", "-f", "win32sux", 0);
}
and i compiled it using:
Code:
gcc autologin.c -o autologin
the permissions for my binary look like:
Code:
-rwxr-xr-x 1 root bin 11066 2005-11-04 03:57 /usr/sbin/autologin
seems the reason it wouldn't work is because i needed to set the NO_PASSWORD_CONSOLE option in /etc/login.defs...
everything is working fine now... i set 3 ttys, tty3 being the one that is autologin...
this is what my working setup looks like now:
/etc/login.defs:
Code:
NO_PASSWORD_CONSOLE tty3
/etc/inittab:
Code:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:235:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty3 linux
~/.bash_profile:
Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty3 ]; then
startx
fi
/etc/securetty (i commented all ttys except tty1):
Code:
tty1
in the inittab i removed the "1" from the c3 line as i don't want the auto login tty3 to be up when i go to runlevel 1 (single user mode)...
Is there any problem I didn't notice using a shell script instead of C? Seems to work for me:
/etc/inittab:
Code:
c1:1235:respawn:/sbin/agetty -l /path/to/autologin.sh -n 38400 tty1 linux
autologin.sh:
Code:
#!/bin/sh
exec /bin/login -f username
I'd use the above for good measure, but is it any better then just
/etc/inittab:
Code:
c1:1235:respawn:/bin/su - username
?
EDIT3: This is probably useless, since su starts a shell but doesn't open a tty port. Maybe a -c option can be added to start x or something.
EDIT: What's the difference between:
Code:
exec /bin/login -f username
and
Code:
exec /bin/login -- username #this is what agetty does by default
?
I didn't notice any difference: if one asks for password so does the other and vice-versa (according to /etc/login.defs NO_PASSWORD_CONSOLE item and presence of password).
Is the -f option related to pam? I don't have pam installed.
EDIT2: If someone finds it inconvenient that you can't logout without being immediately relogged in, you can use the action "once" instead of "respawn" in the inittab entry.
If you don't want the tty to become useless after logout you can use a "wait" entry for the autologin, followed by the default "respawn" entry, both at the end of inittab:
Code:
a1:1235:wait:/sbin/agetty -l /path/to/autologin.sh -n 38400 tty1 linux
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
followed same as above but iam using xinit. want to display window launcher on boot time using xinit with user account and having only one tty (tty1). disabled remaining ttys
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then
su -c "xinit ./myapp" <username>
fi
now my app wants to display at boot time without asking password in user account
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.