Switch users from terminal

From ArchWiki
Revision as of 12:22, 17 March 2012 by Kynikos (Talk | contribs) (quick fix)

Jump to: navigation, search

Merge-arrows-2.pngThis article or section is a candidate for merging with Post Installation Tips.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Post Installation Tips)

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

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.