Run a program as a different user

From NewbieDOC

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
$

--Chris Lale 21:46, 30 January 2006 (CET)

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