Archives For November 30, 1999

This is a step by step tutorial shows how to add “open as root (or administrator)” option in Pantheon file browser in Elementary OS 6 Odin.

Elementary OS now is at version 6.0 based on Ubuntu 20.04 LTS. For those looking for the “Open as Administrator” function to open system file via root user permission, or do copy & paste things outside of user’s home directory, things have changed.

The executable command for the file manager now is io.elementary.files, and the command to start text editor is io.elementary.code. Both are named in Flatpak app style. Gksu has gnone, and “pkexec” takes the place to allow an authorized user to execute program as root.

Add Open as Admin action in Elementary OS 6:

1. ) Firstly, search for and open “terminal” from the top-left corner Applications menu.

2. When terminal opens, run command to create (& edit via nano) the configuration file for option to edit file as root user privilege:

sudo nano /usr/share/contractor/io.elementary.code.open-as-root.contract

When the file opens in terminal, paste following lines and save via Ctrl+X, type y and hit Enter.

[Contractor Entry]
Name=Edit as Administrator
Icon=io.elementary.code
Description=Edit file via root user privilege
MimeType=text/plain;
Exec=pkexec io.elementary.code %U
Gettext-Domain=code

3. And create another config file for an option to open folder as root permission:

sudo nano /usr/share/contractor/io.elementary.files.open-as-root.contract

Then paste the following lines and save it (Ctrl+X, type y, and hit Enter):

[Contractor Entry]
Name=Open as Administrator
Icon=system-file-manager
Description=Open a folder via root user privilege
MimeType=inode/directory;
Exec=pkexec io.elementary.files %U
Gettext-Domain=file manager

After creating the two files, “Edit as Administrator” and “Open as Administrator” context menu option appear when right-clicking a file or folder immediately without restart.

As you see, you can create more actions by creating files with “.contract” extension under /usr/share/contractor directory. The name will be displayed as menu option, and you can find value of icon, MineType and Exec by checking the app shortcut file (.desktop) under /usr/share/applications directory.

That’s all. Enjoy!

Enable “Open as Admin” in Nautilus File Browser

Last updated: February 15, 2018

gnome shell

It’s been a long time last time I wrote about how to enable “Open as root” or “Open as Administrator” in Nautilus’ context menu.

A Nautilus extension called Nautilus Admin has been created for a period of time. It’s a simply Python script that adds some administrative actions to the right-click menu:

  • Open as Administrator: opens a folder in a new Nautilus window running with administrator (root) privileges.
  • Edit as Administrator: opens a file in a Gedit window running with administrator (root) privileges.

To install the Nautilus extension:

The extension is available for all current Ubuntu releases: Ubuntu 14.04, Ubuntu 16.04, Ubuntu 17.10, and Ubuntu 18.04.

1. Simply open “Terminal” either via Ctrl+Alt+T or from app launcher. Then run command:

sudo apt-get install nautilus-admin

Input your password (no visual feedback while typing) when it prompts and hit Enter.

2. Then restart Nautilus via command:

nautilus -q

That’s it. Open nautilus file browser again and enjoy with new context menu options!

ubuntu 14.04 context menu

 

This simple tutorial will show you how to add ‘Open As Root’ or ‘Open As Administrator’ option to context menu so that you can easily edit / open file folders as super user privilege within Nautilus file browser.

Open as Administrator ubuntu 14.04

There’s now a Nautilus extension (see the link) adds administrative actions to Nautilus context menu. It’s easy to install and supports for all current Ubuntu releases.

To get started:

1. Open Ubuntu Software Center. Search for and make sure the package gksu is installed. gksu allows graphical programs to ask a user’s password to run program as root / administrator.

gksu ubuntu 14.04

2. Open Nautilus file browser, press Ctrl+H to view hidden files & folders. Navigate to USER Home -> .local -> share -> nautilus -> scripts.

Create an empty document under this directory named ‘open-as-administrator’ or ‘open-as-root’

open as administtrator ubuntu 14.04

3. Edit and paste following lines into the file

#!/bin/bash
#
# this code will determine exactly the path and the type of object,
# then it will decide use gedit or nautilus to open it by ROOT permission
#
# Determine the path
if [ -e -n $1 ]; then
obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
else
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
obj="$base/${1##*/}"
fi
# Determine the type and run as ROOT
if [ -f "$obj" ]; then
gksu gedit "$obj"
elif [ -d "$obj" ]; then
gksu nautilus "$obj"
fi

exit 0

4. Press Ctrl+Alt+T to open the terminal. When it opens, run the command below to make executable:

cd .local/share/nautilus/scripts/ && chmod 0755 open-as-administrator

5. Finally restart Nautilus via command nautilus -q, or just log out and back in.

This simple tutorial will show you how to add ‘Open as Administrator’ or ‘Open as root’ to Pantheon Context menu in Elementary OS Luna. So that you can easily open system files or folders with super user privilege through the default Pantheon file browser.

First take a look at the screenshots:

open file as root in elementary os

open file as root in elementary os

open folder as root in elementary os

open folder as root in elementary os

Before getting started, search for and install gksu from Software Center. It is a Gtk+ frontend allows graphical programs to ask a user’s password to run another program as root / administrator.

Open files as root in Panthen Context Menu:

It’s a little different to Ubuntu Nautilus. Because I don’t know how to use if conditional statements in ‘.contractor’ files, so I divided this into two parts: Open files as root and Open folders as root.

1. Use your favorite editor to create and edit the config file. Here I use gedit (press Ctrl+Alt+T to open terminal for running commands):

sudo apt-get install gedit

sudo gedit /usr/share/contractor/scratch-openasroot.contract

2. Copy and paste below lines into the file and save it.

[Contractor Entry]
Name=Open file as root
Icon=scratch-text-editor
Description=open file as root with scratch
MimeType=text
Exec=gksudo scratch-text-editor %U
Gettext-Domain=scratch-text-editor

This will add an option “Open file as root” to Pantheon context menu, which open text files as root user with Scratch Text Editor (the default editor for eOS).

Open folders as root in Panthen Context Menu:

1. Use your favorite editor to create and edit the config file:

sudo gedit /usr/share/contractor/folder-openasroot.contract

2. Copy and paste below lines into the file and save it.

[Contractor Entry]
Name=Open folder as root
Icon=pantheon-files
Description=Open current folder as root privilege
MimeType=inode;
Exec=gksudo pantheon-files %U
Gettext-Domain=pantheon-files

This adds the option ‘Open folder as root’ to context menu, which open folders as root privilege.

Remember, you need a restart to get things done. Enjoy!

This quick tip is going to show beginners how to add ‘open as administrator’ or ‘open as root’ into Nautilus context menu in Ubuntu 13.10 Saucy.

With this feature enabled, you can quickly open files and folders in Nautilus with root (super user) privilege. This also works on Linux Mint 16 Petra if you’re using Nautilus 3.8.x.

Open as Administrator ubuntu 13.10

To get started:

1. Open Ubuntu Software Center, search for and install gksu. It allows graphical programs to ask a user’s password to run program as root / administrator.

2. Open Nautilus file browser, press Ctrl+H to view hidden files & folders. Navigate to USER Home -> .local -> share -> nautilus -> scripts.

Create an empty document under this directory named ‘open-as-administrator’

create open as administrator

3. Open this file with Gedit, copy and paste following codes into the file and save.

#!/bin/bash
#
# this code will determine exactly the path and the type of object,
# then it will decide use gedit or nautilus to open it by ROOT permission
#
# Determine the path
if [ -e -n $1 ]; then
obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
else
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
obj="$base/${1##*/}"
fi
# Determine the type and run as ROOT
if [ -f "$obj" ]; then
gksu gedit "$obj"
elif [ -d "$obj" ]; then
gksu nautilus "$obj"
fi

exit 0

4. Right-click on this file, go to Properties -> Permissions tab. Check the box which says ‘Allow executing file as program’.

Log out and back in, or restart Nautilus by nautilus -q command. Done.