Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: HOWTO: Automatically login to XFCE without a login manager

Hybrid View

  1. #1
    Join Date
    May 2005
    Location
    Marlborough, UK
    Beans
    469
    Distro
    Ubuntu Karmic Koala (testing)

    HOWTO: Automatically login to XFCE without a login manager

    I based this post of one made in the Hoary section by "peekpt" with some updates for breezy and later versions of ubuntu.

    Are you tired off typing logins? Don't want to load heavy login managers?

    This guide let's you have autologin and autostart for your XFCE:

    Let's open a console and then create the file autologin.c

    Code:
    sudo nano autologin.c
    and paste this code inside (middle mouse button will paste the text you select):
    Code:
    int main() { execlp( "login", "login", "-f", "your_user_here", 0); }
    replace the string: your_user_here with the user you want to autologin. (ctrl+O to save and Ctrl + X to quit)

    Let's compile.. you will need to have gcc-3.4 installed so if you dont you need to
    Code:
    sudo apt-get install gcc-3.4
    first. (If you are unsure just try and install it anyway).

    Code:
    sudo gcc-3.4 -o autologin autologin.c
    copy the compiled autologin file into /usr/local/sbin

    Code:
    sudo cp autologin /usr/local/sbin
    now we need to edit the file /etc/inittab

    Code:
    sudo nano /etc/inittab
    search for this:

    Code:
    1:2345:respawn:/sbin/getty 38400 tty1
    put a # to comment this line and add this new line:

    Code:
    1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
    it will look like this:

    Code:
    #1:2345:respawn:/sbin/getty 38400 tty1
    1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
    2:23:respawn:/sbin/getty 38400 tty2
    3:23:respawn:/sbin/getty 38400 tty3
    4:23:respawn:/sbin/getty 38400 tty4
    5:23:respawn:/sbin/getty 38400 tty5
    this will make the autologin stuff...

    let's make the autostart:

    Code:
    Code:
    nano .bash_profile
    put this code on the bottom and save it

    Code:
    if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
           startxfce4
    fi
    then you just have to remove your login manager :
    Code:
    sudo apt-get remove gdm xdm kdm
    Reboot your machine (to try it out)

    I used this page as guide:
    http://www.dicas-l.unicamp.br/dicas-l/20030129.shtml

    Notes
    If you don't use xfce you can also run startx at startup using
    Code:
    if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
           startx
    fi
    in your .bash_profile file instead.

    To undo the changes you have made just edit the inittab file and uncomment the line you commented and comment out the line you added.
    Code:
    sudo nano /etc/inittab
    Last edited by Haegin; December 11th, 2006 at 09:49 PM. Reason: Updating to bring inline with new forum rules on howtos
    Regards,
    Haegin
    If all else fails curl up in bed with a good book.
    "<mc44> rob: every time you don’t read the topic, god kills a lolcat"

  2. #2
    Join Date
    Oct 2005
    Location
    London
    Beans
    477
    Distro
    Ubuntu 6.10 Edgy

    Re: HOWTO: Automatically login to XFCE without a boot loader

    Nice howto. Just to mention that boot loader is GRUB. This refers to programs like GDM or KDM which are login managers.

  3. #3
    Join Date
    May 2005
    Location
    Marlborough, UK
    Beans
    469
    Distro
    Ubuntu Karmic Koala (testing)

    Re: HOWTO: Automatically login to XFCE without a boot loader

    Darn! If somebody can edit this or knows how I can then please do so/tell me...
    Regards,
    Haegin
    If all else fails curl up in bed with a good book.
    "<mc44> rob: every time you don’t read the topic, god kills a lolcat"

  4. #4
    Join Date
    Mar 2006
    Beans
    15
    Distro
    Xubuntu

    Re: HOWTO: Automatically login to XFCE without a boot loader

    Thank you, worked well on my installation of breezy with xfce.

  5. #5
    Join Date
    Mar 2006
    Beans
    15
    Distro
    Xubuntu

    Re: HOWTO: Automatically login to XFCE without a boot loader

    could you maybe also supply a script for automated shut down, so I dont have to type "sudo halt"?
    thanks
    Last edited by Tobitas; March 30th, 2006 at 10:00 PM.

  6. #6
    Join Date
    Nov 2006
    Beans
    Hidden!

    Re: HOWTO: Automatically login to XFCE without a boot loader

    Quote Originally Posted by Tobitas View Post
    could you maybe also supply a script for automated shut down, so I dont have to type "sudo halt"?
    thanks
    hello. try this. add this line to /etc/sudoers
    Code:
    %users    localhost=NOPASSWD:/sbin/reboot, /sbin/poweroff
    this makes possible to any user from the users group to invoke sudo reboot or sudo poweroff without the need of typing in root password.
    lastly, make a change in ~/.bash_profile as such:
    Code:
    if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
           startx; sudo poweroff;
    fi
    for me it works like a charm. btw. I don't use any of the xDMs (have GDM in my Debian/Etch installed but disabled), just terminal login with the autologin feature created according to the how-to found in this topic.
    the effect is: when I invoke "log off" from gnome menu, the xserver shuts down and the sudo poweroff command is executed automaticlly (no need to give root password).

    btw. anyone could tell me what are the drawbacks of my solution?

    one quiet annoying thing I found is that when you want to resetart xorg (by ctrl+alt+backspace) the computer goes off, because the power off command is invoked always after the xserver shutdown. a good thing would be to swap this command with the call of some kind of script which could offer choosing, if the user wants to restart or halt the system or just log off (back to text login prompt). I'm not the best in bash programming so if anyone can help, I'd be thankful. the use of ncurser would be nice.
    Last edited by wrrr; October 2nd, 2007 at 06:35 PM. Reason: found a drawback

  7. #7
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: HOWTO: Automatically login to XFCE without a boot loader

    Quote Originally Posted by wrrr View Post
    hello. try this. add this line to /etc/sudoers
    Code:
    %users    localhost=NOPASSWD:/sbin/reboot, /sbin/poweroff
    this makes possible to any user from the users group to invoke sudo reboot or sudo poweroff without the need of typing in root password.
    lastly, make a change in ~/.bash_profile as such:
    Code:
    if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
           startx; sudo poweroff;
    fi
    for me it works like a charm. btw. I don't use any of the xDMs (have GDM in my Debian/Etch installed but disabled), just terminal login with the autologin feature created according to the how-to found in this topic.
    the effect is: when I invoke "log off" from gnome menu, the xserver shuts down and the sudo poweroff command is executed automaticlly (no need to give root password).

    btw. anyone could tell me what are the drawbacks of my solution?
    looks okay to me, i do mine a little different(using debian+xfce4).no compiling needed, i apt-get mingetty. "user" is my login name.

    Code:
    my sudoers line:
    %nopasswd ALL=(root) NOPASSWD: /usr/bin/conky, /sbin/halt, /sbin/reboot, /sbin/shutdown, /usr/sbin/xfsm-shutdown-helper, /usr/bin/thunar, /usr/bin/mousepad, /usr/sbin/synaptic
    Code:
    my login line(/etc/inittab):
    1:2345:respawn:/sbin/mingetty tty1 --autologin user
    Code:
    bash_profile:
    if [ `tty` = "/dev/tty1" ]; then
    startx
    fi
    Last edited by kerry_s; September 30th, 2007 at 12:45 PM.

  8. #8
    Join Date
    Jun 2005
    Beans
    42

    Re: HOWTO: Automatically login to XFCE without a boot loader

    http://www.cs.rit.edu/~css8044/?q=autologin

    Mingetty has a auto login option also.

  9. #9
    Join Date
    Aug 2005
    Beans
    80

    Re: HOWTO: Automatically login to XFCE without a boot loader

    The default XFCE behavior is to make you type in your password in order to shut down. To fix this so that xfce simply shuts down without prompting you for a password, add the following line to the /etc/sudoers file as root:

    ALL ALL = NOPASSWD: /usr/sbin/xfsm-shutdown-helper

    I picked this up on another forum. I added this as the last line in the file and it works like a charm.

  10. #10
    Join Date
    Aug 2005
    Beans
    80

    Re: HOWTO: Automatically login to XFCE without a boot loader

    I ran the sudo gcc-3.4 -o autologin autologin.c command as described above and received the following error:

    sudo: gcc-3.4: command not found.

    I did a whereis gcc in a shell and found it in the /usr/bin directory. Scanning this directory I found gcc and also found a gcc-4.0.

    Re-running the compile with gcc threw an error message I did not understand. I continued through the instructions, and the automated login process still worked, so whatever the compile error was, it was not a showstopper. I repeated the experiment using gcc-4.0 and same results: compile error, but the auto login process still worked.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •