SEARCH

How-To Geek

Create Shortcuts on the Desktop to Run Programs as Root in Ubuntu 11.10

00_running_program_as_root

Programs, such as Nautilus or gedit, allow you to browse or view all the files on your system, but they only allow you to change or create new files in your home directory (e.g., /home/lori) and its subfolders.

We’ve previously showed you how to access an advanced file manager if you’re using Linux Mint 12. If you’re using Ubuntu 11.10, it’s easy to set up a shortcut that allows you to open any program as root or another user.

To be able to create a shortcut in Ubuntu 11.10, you must install some packages. See our article about creating shortcuts in Ubuntu 11.04 and 11.10 for instructions.

NOTE: When we tell you to type or enter text into an edit box or at the command prompt, and the text is surrounded by quotes, DO NOT type the quotes, unless otherwise specified.

Once you have installed the required packages, press Ctrl + Alt + T to open a Terminal window. Type the following command at the prompt and press Enter.

gnome-desktop-item-edit –create-new ~/Desktop

01_opening_create_launcher_dialog

NOTE: You can also press Alt + F2 and enter the command in the edit box that displays.

02_opening_create_launcher_dialog_using_alt_f2

The Create Launcher dialog box displays. Enter a name, such as Open As, in the Name edit box. Type the following text in the Command edit box:

/usr/bin/gksu

You can enter a description for the shortcut in the Comment edit box, but it is not required. Click OK to create the shortcut.

03_create_launcher_dialog

You are returned to the prompt in the Terminal window. To close the window, type “exit” at the prompt and press Enter.

04_closing_terminal_window

The new Open As shortcut displays on the desktop. Double-click on it to invoke it.

05_starting_open_as

The Run program dialog box displays. If you want to run Nautilus as root, enter “nautilus” in the Run edit box, make sure root is selected in the As user drop-down list, and click OK.

06_running_nautilus_as_root

Enter your password on the dialog box that displays and click OK.

07_entering_password_orig

The following error displays because Nautilus uses a directory in the .config directory in the home directory of the current user, which, in this case, is root. Therefore, we need to create a “nautilus” directory in the /root/.config directory. To do this, we must open a Terminal window as root. We can use our new shortcut to do that.

08_nautilus_error_dialog

When the Run program dialog box displays, enter “gnome-terminal” in the Run edit box and click OK.

09_running_gnome_terminal_as_root

A Terminal window opens with a pound sign (#) as the prompt. This indicates you are now root. Type the following command at the prompt and press Enter to change to the “.config” directory in the “root” directory.

cd /root/.config

10_change_to_root_config_directory

In the .config directory, we need to create a “nautilus” directory. To do so, type the following command at the prompt and press Enter.

mkdir nautilus

11_making_nautilus_directory

If you type “ls” at the prompt and press Enter, you’ll see the new nautilus directory listed. To close the Terminal window, type “exit” at the prompt and press Enter.

12_nautilus_directory_created

Now, when you invoke the Open As shortcut and enter “nautilus,” Nautilus opens with root permissions.

13_nautilus_open_as_root

You can add the shortcut to the Unity launcher by dragging and dropping it onto the launcher.

14_dragging_shortcut_to_launcher

The icon is added near the bottom of the launcher.

15_shortcut_on_launcher

IMPORTANT NOTE: Be very careful when changing or deleting files outside of your home directory. If you rename or delete a critical file, you can ruin your system and make it unusable.

You can also run Firefox as root by entering “firefox” on the Run program dialog box. If you want to open the home folder as root, enter “nautilus /home” on the Run program dialog box. To open the command console, enter “gnome-terminal” on the Run program dialog box. You can run most programs as root in this manner, as long as you know the command to run the program. See our article about finding files and folders in Linux using the command line for information about the which and whereis commands that can help you find executable files.

Lori Kaufman is a freelance technical writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 05/2/12

Comments (1)

  1. M Henri Day

    Lori, have you tested this in Precise ?…

    Henri

Enter Your Email Here to Get Access for Free:

Go check your email!