opkada.blogg.se

Edit text file in terminal
Edit text file in terminal












edit text file in terminal edit text file in terminal

You get "permission denied" because of how Linux handles permission.Īnything in the $HOME folder belongs to the user, whereas almost anything else belongs to root. In case something goes wrong you can restore it from your backup in the home folder. Replace gedit with the editor of your choiceĪ new window opens and you can edit your config there. To be safe back it up using cp /etc/dhcp/nfig /$HOME/Īnd run gksu gedit /etc/dhcp/nfig

  • Doesn’t fall back onto the user application configuration data of the root user which may or may not look and behave acceptably.ġ EDITOR or SUDO_EDITOR work too but take less priority or are more specialised respectively.
  • Uses the current user’s application configuration but mess with the configuration file access permissions like sudo -H etc.
  • Doesn’t require the execution of potentially unsafe applications with elevated privileges.
  • Doesn’t require security policy changes like pkexec (for which you’d need to edit files… as super-user, the exact thing this answer is trying to solve).
  • Doesn’t require additional and/or deprecated applications.
  • Since sudoedit waits for the editor process to terminate to apply changes to the edited file, this may be necessary if you have other instances of the same Editor running: Some editor offer a command-line option to always start a new instance, even if one is currently running. Of course you can use any other editor that you like, e. Which is equivalent to VISUAL=gedit sudoedit /path/to/some-config-file.cfg You can use sudo -e or its alias sudoedit with your favourite (graphical!) text editor through the VISUAL environment variable 1: VISUAL=gedit sudo -e /path/to/some-config-file.cfg In Ubuntu 18.04, gksudo is not available in the official repositories. See Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland? for details. In Ubuntu 17.10, Wayland is default instead of the traditional X server, and running graphical editors as root is difficult. You will have to install the gksu package (either from the Software Centre or via sudo apt-get install gksu) to get it. In Ubuntu 14.04 onwards, gksudo is not installed by default. In either case, you'll need to first provide your password when requested.
  • In old versions of Ubuntu, gksudo /etc/dhcp/nfig could be used to launch GUI editors.
  • sudo -H /etc/dhcp/nfig for GUI editors in general.
  • gedit admin:///etc/dhcp/nfig using the the admin:// protocol with GNOME applications such as gedit (and others that support GVfs).
  • sudoedit /etc/dhcp/nfig if you are using a terminal-based editor such as nano or are ssh'ing into a server.
  • Which text editor are you using? If you are a sudoer and know your password, try (in a terminal) either:














    Edit text file in terminal