39

I tried to do it with the command startx 1. It seemed to flicker to a different screen momentarily, but then exited. Got the following error:

/usr/bin/xterm: No absolute path found for shell: :1

Any ideas?

3 Answers3

53

I think you can do it with this:

$ startx -- :1

Note that you need to be on a text console. If you do this from an X session, you may not be authorized. First Ctrl+Alt+F1 to switch to a text console and log in there.

Press Ctrl+Alt+F7 and Ctrl+Alt+F8 to switch between the X sessions (the F key numbers may vary depending on your distribution).

If you want more control you can add more options to the command like so:

$ startx gnome-session -- :1 vt8

This will start up gnome-session on display :1 and run it on virtual console 8 (Ctrl+Alt+F8).

slm
  • 369,824
  • Oh, wow. I must have just mis-copied that command. With sudo, it works. Thanks. – Brian Peterson Aug 03 '13 at 03:18
  • 7
    Ugh, starting an X server with sudo causes everything within the X session to start with root privileges; this even causes some applications to fail. – Brian Peterson Aug 03 '13 at 03:29
  • 1
    @Bepetersn - I was surprised that you said you needed that. What happens without it? – slm Aug 03 '13 at 03:30
  • 5
    @Bepetersn Run this from a text console, not from an X session. On Linux, press Ctrl+Alt+F1 first, log in, and run startx -- :1 from the shell prompt. – Gilles 'SO- stop being evil' Aug 03 '13 at 23:22
  • 2
    @Gilles - thank you for incorporating that into the answer! – slm Aug 03 '13 at 23:47
  • 1
    Sorry, I forgot to respond @slm. If I run startx -- :1 from an X session, the terminal appears unresponsive for a bit, then tells me: xauth: timeout in locking authority file /var/run/gdm3/auth-for-brian-3zy5Hn/database, and fails a bit later with X: user not authorized to run the X server, aborting. During this time, nothing would come up in the 8th tty as you would expect. – Brian Peterson Aug 04 '13 at 06:08
  • 1
    However, @Gilles's solution of starting the second X server from outside an X session does indeed work; thanks much! – Brian Peterson Aug 04 '13 at 06:12
  • @Bepetersn - Yeah I completely forgot to mention the Ctrl-Alt+F8 bit to run the commands. I thought you knew that since you were using start -- :1. Gilles was kind enough to clean up my answer. Glad it works for you now. – slm Aug 04 '13 at 13:01
  • There must be a way to start a new X from within X. Could I ssh into localhost and start X that way? Is there a way that's less of a hack? – Samuel Danielson Mar 17 '15 at 00:47
  • @SamuelDanielson - if you have a new question please ask it. You can reference this question which should help expedite things. – slm Mar 17 '15 at 00:52
  • Did not work for me, failing with http://ix.io/BdU – isomorphismes Oct 14 '17 at 07:51
  • @isomorphismes says permission denied when it tries. Your not authorized. – slm Oct 14 '17 at 13:08
  • @BrianPeterson starting X session with sudo harmfull for Python users. I can't safely use pip. One more thing, firefox browser won't start – Willy satrio nugroho Aug 17 '21 at 11:15
6

I have found that the following way works for me:

sudo xinit /usr/bin/xterm  -e "su $(whoami) -c pekwm"  $* -- :1

What happening here?
First I start xinit with an xterm, as a parameter to that xterm I su to become myself. From there I start the window manager.
Only thing you need to do is minimize (not close) the xterm. Probably you could tell the xterm to start minimized—but I have not care enough to find that out.

Also: Replace pekwm with the session you want to login to. Look in the .dewsktop-file in /usr/share/xsessions

Edited code. Changed from my real username as in example to the output from whoami

Swepter
  • 91
  • On ubuntu 20.04. This, at least gives a new login dialog on CTRL+ALT+F1. But after login, I land in the existing session on ...F2, and the ...F1 goes back to the login dialog. – user66081 Jun 01 '20 at 06:56
  • @user66081 I changed the command. Please try again. And read the lines I added in bottom off the edited post. – Swepter Jun 03 '20 at 08:51
0

When I start another Xorg env I switch to tty2 (Ctrl+Alt+F2), then login as root and run those commands:

Xorg vt8 :1 &
su - user
export DISPLAY=:1
fluxbox &

You might have to change back to tty2 right after Xorg has started. And I've seen Xorg with setuid bit set so you can start Xorg without root, so check it out :)

esselfe
  • 1
  • 2