How to run startx as non-root?

34,184

Solution 1

First a clarification, X is not a window manager, it is a windowing system.

Now, the ~/.Xauthority file is simply where the identification credentials for the current user's Xsession are stored, it is the file read when the system needs to determine if you have the right to use the current X session.

You should never copy an existing one from another account, the file should always belong to the user running X and is created automatically when you start a new X session. So, just delete the one you have, and then run startx again, everything should work as normal:

$ rm ~/.Xauthority; startx

Solution 2

I think an issue is that people login as root, then switch users using su -l username, which creates/spawns a subprocess under root owned by "username". X will use the .Xauthority of the top process (in this case root), which "username" does not have permission to use.

The error will be shown:

Cannot open virtual console 1 (Permission denied).

To solve this, just run login instead of su to start a new shell as a top process.

Share:
34,184

Related videos on Youtube

Habi
Author by

Habi

Updated on September 18, 2022

Comments

  • Habi
    Habi almost 2 years

    Recently, I switched from Ubuntu to Arch Linux. I've installed X11 as my Window System and KDE as my Desktop Environment. I've separate partition for /home, /var, / and /boot and they all mount at boot time. When I run startx, the following message gets displayed.

    xauth:timeout in locking authority file /home/hello/.Xauthority

    Accidently, I've deleted that file. So, I copied it from /root. I've changed it's authority using code below:

    # chown hello:users ~/.Xauthority

    Even after this, I'm unable to run startx unless I use root account.

    • Admin
      Admin over 10 years
      Copying the file is a security risk. You changed its permissions (ownership), not its authority.
    • Admin
      Admin over 10 years
      (Re)move ~/.Xauthority and try startx again. Does it work? If not, what is the exact error message?
  • Habi
    Habi over 10 years
    Tredon, even after removing .Xauthority file. I am unable to starx. It keeps on displaying that same error.
  • terdon
    terdon over 10 years
    @Habi you need to make sure there are no running X sessions, then remove the file, then run startx again.
  • Habi
    Habi over 10 years
    Now, X runs but displays another message Call to Inusertemp failed(temporary directories full?). Check your installation.
  • terdon
    terdon over 10 years
    @Habi ah, good, that's progress :). Please post another question for this since it is a completely different problem. In the new question, show us the output of df -h and also make sure this problem is still there after restarting.