Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I’m trying to execute the login command but it fails.

As root (via SSH) I get:

root@server:~# login
Connection to 192.168.0.50 closed.

The SSH connection is closed. In a “physical” TTY the session is closed and I go back to the login screen.

As a regular user using sudo:

bilbax@server:~$ sudo login
Password: 

[1]+  Stopped                 sudo login

Just before this bug appeared, I tried to use the login command as usual, it worked, it asked for the password. I typed it wrong, I retried, but the command froze. I tried ^C, without success. So, as root, I executed killall login; didn't worked too. I rebooted the system and now I have to bug described above.

Did I do something wrong by killing the command?

I’m on Arch Linux x86_64 (kernel 3.4.7-1-ARCH).

share|improve this question
3  
You shouldn't need to run login at all. What are you trying to do? –  Michael Hampton Aug 11 '12 at 22:34
    
I need to launch my Minecraft server under the minecraft account. I can’t use su minecraft, it causes problems with screen which can’t start. So I logged into minecraft use using login as root, and start the server. –  Kévin Lesénéchal Aug 11 '12 at 23:04
2  
@KévinLesénéchal su is the proper way to do what you want, not login. If you're having a problem getting screen to work with su, you should open question on that instead. –  Patrick Aug 12 '12 at 3:46
add comment

1 Answer

The problem with su will be that it doesn't chown the tty to the new user. That doesn't matter when you're su'ing to root, but for other users not owning the tty leads to difficulty.

Running login from the shell used to be a normal (or at least acceptable) thing to do. Shells treated it specially, implicitly doing an exec. Modern shells don't seem to do that any more. Running exec login explicitly might help. Adding -f username is another thing to try.

When you do it as a non-root user, it only works if login is setuid-root, which used to be the standard setup but isn't so common anymore. The sudo version might also work if preceded by exec, assuming sudo is smart enough to get out of the way (i.e. do a direct exec itself, not a fork+exec+wait)

After going through all that I wonder why you don't just ssh host -l minecraft and cut out the middleman

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.