Open as administrator linux

[Quick Tip] Enable ‘Open as Administrator’ Option in Ubuntu 22.04

Want to open folder or edit file as administrator (aka root in Linux)? Here’s how to do the trick by adding menu option in Ubuntu 22.04 file manager.

The ‘Files’ (aka nautilus) has an extension called nautilus-admin to do administrative operations. With it, you may right-click on folder and select “Open as Administrator“, or right-click on file and select “Edit as Administrator“.

Don’t like MS Windows, it however does not support running an app as root.

1. Open Terminal

Firstly, open terminal either by pressing Ctrl+Alt+T key combination on keyboard, or by searching from the ‘Activities’ overview screen.

2. Install nautilus-admin

When the terminal opens, paste the command below into it and hit Enter.

sudo apt install nautilus-admin

Type user password (no asterisk feedback) for sudo authentication and hit Enter to continue.

3. Apply change

Once installed the extension, you need to restart the file manager to apply change.

Not just close and re-open the file manager window, but you need to run command to quit the background service and let it start again automatically:

Источник

[Quick Tip] Add ‘Open as Administrator’ in Ubuntu 20.04 LTS

gnome shell

This simple tutorial shows how to add ‘Open as Administrator‘ option to file browser right-click menu in Ubuntu 20.04 LTS.

Need to open or edit files with Administrator (root) user privilege directly from file browser in Ubuntu desktop? There’s an extension nautilus-admin can do the job in the default Gnome desktop.

1. Open terminal by either pressing Ctrl+Alt+T on keyboard or searching for ‘terminal’ from application menu.

2. When terminal opens, run command to install the extension:

sudo apt install nautilus-admin

You may replace nautilus-admin with caja-admin or peony-admin if you’re running with MATE or UKUI desktop.

Читайте также:  Linux gnu установка пакетов

Once installed, run command nautilus -q or log out and back in to apply changes.

Note the extension only adds Administrator privilege to open folders or edit files. There’s no ‘Run as Administrator’ option to run program as super user privilege.

permalink

Ji m

I’m a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to remind me outdated tutorial! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

Источник

Is it possible to open directories as administrator?

Create a simple nautilus script can also open a folder as root.

#!/bin/bash gksudo nautilus $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS 

Save the above script as Open folder as root in your ~/.gnome2/nautilus-scripts/ . On right click you will have an option under scripts, Open folder as root. And you can open a folder as root after providing your root password.

Do not forget to give the script execution permission. You can use in terminal,

chmod +x ~/.gnome2/nautilus-scripts/Open\ folder\ as\ root 

Or you can right click on the file, then go to Properties >> Permissions and check the box corresponds to Execute to give the script execution permission.

enter image description here

enter image description here

To use gksudo you need to install gksu . In Ubuntu 13.04 onwards it is not install by default. You can install it using,

Open files and folders as root

There is a nice application xdg-open which can open any arbitrary file or URL in the user’s preferred application. One can replace nautilus with xdg-open in the above script and it will enable one to open folders as well as all files as root. [Proposed by Sadi] It increases the applicability of the code. The modified script will look like,

#!/bin/bash # script_name: open as root gksudo xdg-open $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS 

Источник

How to Open Files and Folders as Administrator in Nautilus File Manager in Linux

If you want to open or edit a file as root, you can always do that in the terminal. I know a few people don’t feel too comfortable with the command line.

The desktop Linux often provides ways to avoid the command line for terminal-fearing people.

If you are in a situation where you have to access a folder as root or edit a file with root privilege, you can do that graphically in Nautilus file manager.

A neat Nautilus hack allows you to open files and folders as administrator, i.e. root. Let me show you how.

Add ‘open as administrator’ option in right click context menu in Nautilus file manager

Open Folder As Administrator Ubuntu

You can also edit files as root the same way. Just select the file, right click on it and choose the “Edit as Administrator” option.

Читайте также:  Kali linux to usb driver

Edit Files As Root Ubuntu

In both cases, you’ll be prompted to enter your account’s password:

Authentication Pop Up Ubuntu

That’s pretty much it. You can enjoy the comfort of GUI.

In case you don’t want to run Nautilus as root anymore, you can remove this plugin. It’s always good to remove additional things you installed but you don’t use anymore.

In the terminal (yes, again), use the following command to remove the Nautilus plugin.

sudo apt remove nautilus-admin

By the way, if you are using Ubuntu MATE, you can use caja-admin, instead of nautilus-admin. Other file managers may or may not provide such a feature.

I hope you find this quick tip helpful. Questions and suggestions are always welcome.

Источник

Enable ‘Open as Administrator’ in Ubuntu 22.04 & 23.04 without Gedit

Want to enable ‘Open as Administrator’ (aka ‘Open as Root’) in your file browser context menu? Here’s the beginner’s guide shows you how with a quick fix for Ubuntu 22.04, and Ubuntu 23.04 via default Gnome Text Editor.

The tutorial will work on:

This tutorial will work on all current Ubuntu releases, including Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and Ubuntu 23.04. And it’s for the default Nautilus file browser.

1.) Install nautilus-admin extension:

Ubuntu comes with the nautilus-admin package in the main repositories. With it, you’ll get “Edit as Administrator” option for editing documents, and “Open as Administrator” option for opening folders as root.

To install it, press Ctrl+Alt+T on keyboard to open terminal and run command:

sudo apt install nautilus-admin

UPDATE: For Ubuntu 22.10 & 23.04, use sudo apt install —no-install-recommends nautilus-admin command instead to skip installing Gedit text editor, since it now uses GNOME Text editor as default.

Tip: For Ubuntu MATE or Linux Mint MATE desktop, there's also a similar package called caja-admin for the Caja file browser.

2.) Restart nautilus to apply change:

After installed the extension, you need to apply change by restarting nautilus via command:

Or you can just log out and back in. And it should work afterwards.

3.) Use GNOME Text Editor to edit documents as root in Ubuntu 23.04

For Ubuntu 22.04|20.04, you’re done now!

However, Ubuntu 22.10 & 23.04 has replaced Gedit with GNOME Text Editor as default! In case you don’t want to use Gedit to edit documents as administrator. Do following steps one by one:

  1. First, press Ctrl+Alt+T shortcut key on keyboard to open terminal.
  2. Then, run command to edit the extension script file:
sudo nano /usr/share/nautilus-python/extensions/nautilus-admin.py

  • When file opens in command, find out and replace /usr/bin/gedit with /usr/bin/gnome-text-editor as value for “GEDIT_PATH”.
  • Finally, press Ctrl+X, type y and hit Enter to save file. And, run nautilus -q command to apply change.
  • Читайте также:  Linux files in directory size

    (For OLD Ubuntu) Fix / Workaround for Ubuntu 21.04 & Ubuntu 21.10:

    In Ubuntu 21.04 Hirsute Hippo, there are two issues in my case. If you get into the same problem, here’s the workaround.

    a.) Fix nautilus -q error for Ubuntu 21.04

    Running nautilus -q command will output an error message in Ubuntu 21.04:

    Traceback (most recent call last):
    File “/usr/share/nautilus-python/extensions/nautilus-admin.py”, line 25, in
    from gettext import gettext, locale, bindtextdomain, textdomain
    ImportError: cannot import name ‘locale’ from ‘gettext’ (/usr/lib/python3.9/gettext.py)

    This is due to a small change in the Python 3.9 library. To fix it, do the steps below one by one:

      Firstly press Ctrl+Alt+T on keyboard to open terminal. When it open, run command to edit the extension script:

    sudo gedit /usr/share/nautilus-python/extensions/nautilus-admin.py

    Finally save the file and restart Nautilus via nautilus -q command.

    b.) Workaround for nautilus admin & gedit admin error:

    Due to update of the gvfs package, you’ll get an error when using ‘Open as Admin’ action:

    GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Unix process subject does not have uid set

    It’s a bug caused by the commit to fix a network permission issue for flatpak apps. The upstream has fixed the issue by releasing gvfs 1.48.1. However, Ubuntu stuck at version 1.47.91 without a fix.

    Solution:

    • Install gvfs 1.48.1 from a third-party PPA.
    • Or downgrade gvfs by installing the package from Ubuntu 20.10.

    Option 1: Install gvfs 1.48.1 from Ubuntu PPA:

    Thanks to Panda Jim, who has backported the package from Debian into this Ubuntu PPA with Ubuntu 21.04 and Ubuntu 21.10 support.

    Open terminal via Ctrl+Alt+T keyboard shortcut, then run the commands below one by one to add the PPA & upgrade gvfs package:

    sudo add-apt-repository ppa:ubuntuhandbook1/gvfs

    After that, the ‘Open as Administrator’ function should work at next login.

    For any issue, purge the PPA which will also revert the package to the stock version:

    sudo apt install ppa-purge && sudo ppa-purge ppa:ubuntuhandbook1/gvfs

    Option 2: install the gvfs packages from Ubuntu 20.10:

    For those don’t like third-party PPAs though upgrading gvfs is preferred, you can alternatively downgrade the gvfs package to the old 1.46 version.

    1. Firstly, download the .deb packages (for 64-bit system) one by one by clicking the following links:
      • gvfs
      • gvfs-libs
      • gvfs-fuse
      • gvfs-daemons
      • gvfs-common
      • gvfs-backends
    2. Secondly, press Ctrl+Alt+T to open terminal and run command to install all downloaded deb packages:
    sudo apt install ./Downloads/gvfs*.deb

    Finally restart your machine to apply changes.

    Источник

    Оцените статью
    Adblock
    detector