How do I get permissions to edit system configuration files?
I can't seem to edit and save config files in the root system (eg: /etc/dhcp/dhcpd.config
); it just says "permission denied" or the save option is blocked in the text editor.
I'm pretty sure I'm a root user, but how do I make sure? If I am a root user, how do I fix this?
Solution 1:
Which text editor are you using? If you are a sudoer and know your password, try (in a terminal) either:
-
sudoedit /etc/dhcp/dhcpd.config
if you are using a terminal-based editor such asnano
or are ssh'ing into a server. -
gksudo <text editor here> /etc/dhcp/dhcpd.config
if you are using a GUI-based editor such asgedit
In either case, you'll need to first provide your password when requested.
In Ubuntu 14.04 onwards, gksudo
is not installed by default. 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 17.10, Wayland is default instead of the traditional X server, and running graphical editors as root is difficult. See Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland? for details.
In Ubuntu 18.04, gksudo
is not available in the official repositories. Use sudo -H <text editor>
instead, or the admin://
protocol:
gedit admin:///etc/dhcp/dhcpd.config
Solution 2:
If you don't want to use a terminal, you can invoke a GUI program as root thus (this example is for Gedit):
- Hit Alt+F2 to bring up the Run dialog.
-
Type
gksudo
followed by the executable name of your program (which might be different from the name displayed by the GUI). For example:gksudo gedit
- Hit Enter.