0

I am trying to start startx as non-root user in my Ubuntu-server 16.04(Linux nanopim1 3.4.113-sun8i #16 SMP PREEMPT Tue Jun 13 14:15:57 CEST 2017 armv7l armv7l armv7l GNU/Linux) with openbox installed on it.

I tried to put each of these files one-by-ne inside /rc.local but didn't work! the only thing that is work is putting startx without any addition on /etc/rc.local and it starts as root!

su -l m -c startx

su -s /bin/bash -c startx m&

su - m -c startx

Also I tried another way, I did create a file here: /etc/systemd/system/autologin.service with this content:

[Unit]
Description=Autologin service

[Service]
Type=fork
user=m
group=m
ExecStart=/usr/bin/startx
TimeoutSec=0

[Install]
WantedBy=multi-user.target

Then: sudo systemctl daemon-reload but didn't work again!!!

Only putting startx alone inside /etc/local works but it's root user that I don't want to be!

1

Display manager version (easier)

It is typically the job of display manager to show a login screen and start a user session. If you had one, it would be a path of least resistance to set it up to autologin. It is a widely used and probably well tested and supported solution. You would need to set it up to 1) autologin and 2) use your preffered session, but both are typically supported with the usual display managers supported by your linux (lightdm, xdm, whatever..).

On ubuntu 16.04 (non-server) I have the following in /etc/lightdm/lightdm.conf

[Seat:*]
autologin-guest=false
autologin-user=xyz
autologin-user-timeout=0

You would need to install and possibly enable lightdm

apt-get install lightdm

Lightdm is the default ubuntu display manager. It is not installed by default on ubuntu server edition and you will be installing serveral packages so the harder manual way would be required if you wish to avoid them.

Ways of setting up a graphical login on ubuntu server is better described here https://askubuntu.com/questions/53822/how-do-you-run-ubuntu-server-with-a-gui#788193, after which you can set up autologin if you wish.

You may want to select your preffed type of session (openbox), by setting /home/username/.dmrc to something like

[Desktop]
Session=openbox

Manual (startx)

I don't know what is exactly required to start an x session startx on boot, but I would suggest decomposing the problem to step-by-step process:

  1. you say you startx works as root. It would be nice to verify you can log in as root on a console and start an x session with:

    root@xyz # startx
    
  2. Make sure you can start an X session when logged in as your preffered user.

    myuser@xyz $ startx
    
  3. Make sure you can start an X session as the preffered user, but while logged in as root, by building upon the previous command:

    a) Use something like:

    root@xyz # su -l myuser -c startx
    

    quote the command if you need multiple arguments:

    root@xyz # su -l myuser -c "startx arg1 arg2 .."
    

    b) You may be able to skip this step if you set the user in the systemd unit.

  4. Make it autostart.

    a) Add the (3a) command to /etc/rc.local and reboot.

    b) Use a systemd unit like you described, with the command set according to 2/3. To test, you may use something like

    root@xyz # systemctl stop autologin  # make sure to reset service
    root@xyz # systemctl daemon-reload   # don't know if needed
    root@xyz # systemctl start autologin
    

    Once it works, you may need to enable it to autostart or whatever it is that systemd needs (not an expert).

    root@xyz # systemctl enable autologin
    

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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