Ubuntu Easy (And Quick) Ways To Open Any Files As Root

Ubuntu Easy (And Quick) Ways To Open Any Files As Root Техника


How do I start the GUI editor in Linux?

  1. Right-click a text or php file.
  2. Select «Properties»
  3. Select «Open with» tab.
  4. Choose among the listed/installed text editors.
  5. Click «Set as default»
  6. Click «Close»

How do I restart Sudo service?

  1. Linux provides fine-grained control over system services through systemd, using the systemctl command. …
  2. To verify whether a service is active or not, run this command: sudo systemctl status apache2. …
  3. To stop and restart the service in Linux, use the command: sudo systemctl restart SERVICE_NAME.

I am using Trisquel GNU/Linux-Libre which comes with Gnome3 Flashback Desktop Environment.

I know that I can run GUI application as root by sudo & gksudo but I want to know that How do I run GUI applications as root with the help of pkexec?

When I tries to run gedit (or any other application like:nautilus) by pkexec gedit then It prompts for password for authentication:-

screenshot

After entering password it exit with error:-

$ pkexec gedit
error: XDG_RUNTIME_DIR not set in the environment.

(gedit:6135): Gtk-WARNING **: cannot open display:

So, It seems something is going wrong with display environment.

I’ve also tried with DISPLAY=:0 pkexec gedit but doesn’t work.


Now I don’t know What to do in order to accomplish this.

Thus, Help me to find out How to run GUI applications as root by means of pkexec. Or Is this possible or not?


BTW, Inspired by gparted-pkexeccommand which works fine. How gparted use pkexec?

I’ve tried: gksudo gedit /etc/xinetd.d/tftp (this is the path I need). I got an error message:

couldn't find the file /etc/xinetd.d/tftp
please check that you typed the location correctly and try again

What do I need to do?

Kevin's user avatar

16 gold badges88 silver badges112 bronze badges

asked Feb 27, 2011 at 12:29

Shira's user avatar

My version of gedit (2.22.3) does create the file if it doesn’t exist. If yours doesn’t, you can create the file first with sudo touch /etc/xinetd.d/tftp.

I recommend using sudoedit /etc/xinetd.d/tftp instead. This uses your favorite editor, taken from the EDITOR environment variable, or a system default if you haven’t expressed your preference. Add export EDITOR=/usr/bin/gedit to your ~/.profile if necessary.

Дополнительно:  Шум на экране монитора | Пикабу

Community's user avatar

answered Feb 27, 2011 at 12:53

Gilles 'SO- stop being evil''s user avatar

I made a new launcher for my desktop (I installed gnome desktop fallback)
by gnome-desktop-item-edit —create-new ~/Desktop.
then typed in as the run command: gksu nautilus
that runs as root.

navigated to my regular home that logs in show hidden files went inside Templates folder, made new file and newfile.php and newfile.html
I also edited those files and put in my code I usually create with.

then I copied the Templates file and navigated to «root’ home the paste it there (the folder is missing) now when I run nautilus as root I can create my files as well as the untittled with no extention. then edit with gedit using the nautilus I launched as root with my new launcher (gksu nautilus)

answered Oct 6, 2015 at 22:44

David Mikeska's user avatar




gksu hasn’t been updated since 2009 and is not recommended any more. In fact, Ubuntu no longer ships with gksu by default (though it may be installed for many of you, because some apps still depend on it) and it may even be completely removed at some point.

The recommended replacement for gksu is pkexec. Applications like Synaptic, Ubuntu Software Center, Software & Updates and others use it for some time but what if you want to use pkexec with applications like Gedit or Nautilus?

For instance, Nemo comes with a such a file and so do Xfce’s Thunar and Mousepad (Xubuntu 15.04), but Nautilus and Gedit don’t support this by default.

There are two ways you can achieve this though:

Ubuntu Easy (And Quick) Ways To Open Any Files As Root

Ubuntu Easy (And Quick) Ways To Open Any Files As Root

Ubuntu Easy (And Quick) Ways To Open Any Files As Root

sudo apt-get install nautilus-admin

And restart Nautilus:

nautilus -q



B) Install PolicyKit files manually for Nautilus and Gedit

— for Nautilus:

wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.nautilus.policy -O /tmp/org.gnome.nautilus.policy
sudo cp /tmp/org.gnome.nautilus.policy /usr/share/polkit-1/actions/

— for Gedit:

wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy
sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/

That’s it! Now give it a try — open a terminal and type:

pkexec gedit
pkexec nautilus

For quick access, you can create launchers for running Nautilus and Gedit as root: simply use «pkexec nautilus» or «pkexec gedit» as the command.

Tagged with:
customization
gedit
gnome shell
nautilus
pkexec
ubuntu
unity

How do I open file manager as Sudo?

Open Ubuntu Nautilus File Manager as root

  1. Open command terminal either from Applications or using keyboard shortcut- Ctrl+Alt+T.
  2. Run Nautilus file manager with sudo. …
  3. It will ask for your current non-root user’s password that is present in the sudo group.
  4. Ubuntu File manager will open under administrative rights.

What is root folder in Linux?

In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches originate from.

Дополнительно:  Чем грозит root доступ в смартфоне

How do I run a file as root?

You need to do two things; both from a Terminal prompt:

  1. Change to the directory where you have the . run file stored.
  2. Type: chmod 755 filename. run.
  3. Type: sudo ./filename. run.

Sudoedit

Once sudoedit is set up appropriately, you can do

SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile

sudoedit will check that you’re allowed to do this, make a copy of the file that you can edit without changing ownership manually, start your editor, and then, when the editor exits, copy the file back if it has been changed.

I’d suggest a function rather than an alias:

function susubl {
    export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
    sudoedit "$@"
}

although as Jeff Schaller pointed out, you can use env to put this in an alias and avoid changing your shell’s environment:

alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'

Take note that you don’t need to use the $SUDO_EDITOR environment variable if $VISUAL or $EDITOR are already good enough.

The -w option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit copy the files back.

Desktop environments (GNOME)

gedit admin:///etc/shells

This will prompt for the appropriate authentication using PolKit, and then open the file for editing if the authentication was successful.

How do I open the root directory in Ubuntu terminal?

In terminal type «gksu nautilus». (the gksu command can be used instead of sudo when wishing to run gui apps as root, though you should be cautious about what apps you run as root). In terminal type «sudo -i» then «nautilus». In terminal type «sudo nautilus».

How do I open a root file in Linux?

How to Open Root Terminal in Linux Mint

  1. Open your terminal app.
  2. Type the following command: sudo su.
  3. Enter your password when prompted.
  4. From now, the current instance will be the root terminal.

How do I open the text editor as root in Linux?

To open (text) files as root I use Nemo, right click the folder containing the file and select “Open as Root”. With “Elevated Privileges” e.g. xed will let me edit and save.

How do I give a user sudo access?

  1. Log into the system with a root user or an account with sudo privileges.
  2. Open a terminal window and add a new user with the command: adduser newuser. …
  3. You can replace newuser with any username you wish. …
  4. The system will prompt you to enter additional information about the user.
Дополнительно:  Run launcher as root

How do I edit a file with Sudo?

Using Gedit Editor

Replace /path/to/filename with the actual file path of the configuration file that you want to edit. When prompted for a password, enter sudo password. It is like the notepad editor in Windows OS. As soon as the editor window opens, you can start typing or editing without entering in any mode.

How do I Sudo to open a file?

Adding a contextual menu to right click open files as root:

  1. Open the Terminal.
  2. Type sudo su and press enter.
  3. Provide your password and press enter.
  4. Then type apt-get install -y nautilus-admin and press enter.
  5. Now type nautilus -q and press enter.
  6. Finally type exit and press enter, and close the terminal window.

How do I use text editor in Linux?

To start writing or editing, you must enter insert mode by pressing the letter i on your keyboard (“I” for insert). You should see —INSERT— at the bottom of your terminal page if you did it correctly. When you are finished typing, and you want to save your work, you need to exit insert mode.

How do I edit a file in Nano?

Creating or editing a file using ‘nano’

  1. Log into your server via SSH.
  2. Navigate to the directory location you want to create the file, or edit an existing file.
  3. Type in nano followed by the name of the file. …
  4. Start typing your data into the file.

How do I run a script without Sudo?

  1. cd /PATH/TO/FOLDER.
  2. chmod u+x ./filename (u — user, +x — execute permissions)
  3. if you want to execute it without .sh, add the following shebang line to the first line of the file: #!/bin/bash.
  4. If you want to execute it from anywhere on your system add the path of the folder to the $PATH variable.

How do I open a file as root in Ubuntu?

Adding a contextual menu to right click open files as root:

  1. Open the Terminal.
  2. Type sudo su and press enter.
  3. Provide your password and press enter.
  4. Then type apt-get install -y nautilus-admin and press enter.
  5. Now type nautilus -q and press enter.
  6. Finally type exit and press enter, and close the terminal window.

How do you edit a root file?

Then, enable root function at File Expert (More – Settings – File Explorer Settings – tick on Root Explorer). Then mount as read write mode (More – Mount – Mount As Read Write). Enable write permission to all of the file that you want to edit (Hold on the file – File Operations – Permission – tick all on write).

Оцените статью
Master Hi-technology
Добавить комментарий