Run a program as a different user

From NewbieDOC

Chris Lale
chrislale AT users DOT berlios DOT de

Go to NewbieDOC index

Revision History


Revision 1.0 30th January 2006 Revised by Chris Lale
Initial release.

Revision 1.1 22nd November 2007 Revised by Chris Lale
Modified to include Revision History, Abstract and Appendix for Licence, so that a stable version can be included in the "newbiedoc" package.


Image:Newbiedoc-32.png Stable document
You can comment on this document by clicking on the discussion tab.

You can edit the live version of this document: Run a program as a different user


Abstract

Help with using su, gksu and gksuexec - a guide for Debian newbie users and others.


Contents


1 Why switch user?

Sometimes, you will want to run a program user root. Some programs will only run if you are user root. Switching user enables you to log in as a normal, under-privileged user and run a particular program as root.

 
Warning
Warning: 
Avoid logging in as user root. Doing so would give all programs and processes complete access to the whole system. You could do a lot of damage accidentally and become vulnerable to a malicious attack. Switch user instead.
 

2 Running a GUI program as user root

Some desktops have gksuexec accessible from a menu. Alternatively, you can use the gksu command directly from the commandline in a terminal window. You will need to enter user root's password. The program (and only that program) will run as root. When the program is closed, you also exit from root automatically.

2.1 Gnome

  • Applications -> System Tools -> Run as different user
    • Run: (name of program)
    • As user: root
  • OK

(Requires gnomesu to be installed)

2.2 KDE

  • KDE Main Menu -> Run as different user
    • Run: (name of program)
    • As user: root
  • OK

(Requires kdesu to be installed)

2.3 X Desktop without a menu (generic)

Issue the gksu command from a terminal window.

$ gksu name of program

3 Running a commandline program as user root

Issue the su command to switch user to root

$ su
password: (enter root password here)
# name of program

When you have finished, close the program, then exit from user root at the commandline.

# exit
$


4 Appendix A: Licence

Copyright (c) 2006-2007 Chris Lale. chrislale AT users DOT berlios DOT de

GNU FDL Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License."

Go to NewbieDOC index

Content is available under GNU Free Documentation License 1.2, unless otherwise stated.