Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using startx in my .bashrc file to start X when I login at tty1 instead of using a display manager like KDM (I'm using KDE 4.3.4). The actual code in my .bashrc:

if [ -z "$DISPLAY" ] && [ "`tty`" = /dev/tty1 ]
then
    startx
    logout
fi

Now the problem is since KDM is not running I'm not able to use the shut down button from the KDE menu (because it needs root privileges to do so) and some other features are gone as well.

Is there a way to start KDM when I run startx in my .bashrc, like just running KDM in the background? The point is that I want no login display, so I'm sure there must be a way to just start KDM silently.

share|improve this question
add comment

3 Answers

Putting startx in .bashrc is a bad idea. It will prevent you from being able to log in normally to a console. Unless you have a really, really good reason to do so (and I suspect that you, like pretty much everyone else, do not), use a display manager instead.

share|improve this answer
    
Exactly. Or do the extra seven keystrokes and run startx the normal way after you log in. –  Justin Smith Apr 7 '10 at 2:31
add comment

you can set kdm to auto-login, so you'll see no login form displayed. would it help? if it does help, you need to run systemsettings as root (alt+f2 => kdesu systemsettings) then in "login manager" under the "advanced tab" choose "enable auto login" in "convenience" tab.

share|improve this answer
    
The problem is that I still want my login prompt at tty1. If I start KDM using a auto-login I won't be prompted for a password at all (as far as I know?). What I want is to login via tty1 and then start X and run KDM in the background. –  watain Dec 29 '09 at 13:50
    
can you run 'sudo' on .bashrc? it should help you with the permissions issue. auto-login would do everything else once you start the KDM service (usually in /etc/init.d/kdm). –  barraponto Mar 21 '10 at 15:15
add comment

It is not really clear what you want to achieve, but like Ignacio wrote putting startx into your .bashrc is a really bad idea. If your problem were only that you cannot call shutdown -h from within that session, CTRLALTdel is usually mapped to shutdown -r now in /etc/inittab. You can change it to shutdown -h now in there as well.

If your problem is only that you really, really badly want to have X running on tty1, you can of course start kdm on tty1. Then you would also only have to give your login once (was that the issue?). To do that you need to modify a few files.

  • /etc/inittab:

    Remove/comment the line that spawns the getty on tty1. It looks something like

    ## c1:12345:respawn:/sbin/agetty 38400 tty1 linux
    
  • /etc/conf.d/xdm

    Tell the xdm scripts that they are working on tty1; change the entry in there to

    CHECKVT=1
    

To have X start automatically you of course need it in your default runlevel (added via rc-update add xdm).

share|improve this answer
    
Using startx in my .bashrc ain't that bad because I use if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then startx; logout; fi (sorry, I guess I wasn't precise enough there). Your idea with starting kdm on tty1 might look like a acceptable solution. The main reason why I want the text login prompt, is that this way I'd be able to login as root as well, dropping into a shell f.e. for any kind of maintenance. And that's why I start X on tty1 :). –  watain May 19 '10 at 18:54
    
@watain: for the scenary you mention there are 6 tty's available. Just for reference: Use CTRL-ALT F1..F6 to switch. –  Benjamin Bannier May 19 '10 at 22:38
    
I'm aware of that, but that's not the point. I simply want to be able to use the text login at tty1 with my user to start X and on all other ttys to get the console after login. –  watain May 20 '10 at 17:30
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.