Switch users from terminal

From ArchWiki
Revision as of 19:20, 28 December 2007 by Ravster (Talk | contribs) (Directions on how to log in as another user)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you have more than one normal user account on a computer, you might find the need to run programs as the other user (instead of the user you are logged in as).

In such a situation, the 'su' command comes in handy.

Let us assume that the two users are user1 and user2, and that you know the passwords for both users. Type the following if you are logged in as user1 and need to run a program as user2.

$ su user2
Password:

This is all you need if you are going to start a console application, however, if you are going to run a graphical program, you will need to tell the x-server that user2 has to be allowed to use X too.

Again, as user1 (the user you have logged in as), type one of the following commands

$ xhost user2
$ xhost +user2
$ xhost +

The first and second are synonymous to each other, while the third command allows any user or host to run a program that requires x-authority. For further details on the xhost program, see its man page.