How to run startx as non-root?
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 X
session 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
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.