To be safe back it up using cp /etc/dhcp/dhcpd.config /$HOME/dhcpd.config.backup
and run gksu gedit /etc/dhcp/dhcpd.config
Replace gedit
with the editor of your choice
you will get a prompt like this
Enter your password here.
A new window opens and you can edit your config there.
In case something goes wrong you can restore it from your backup in the home folder.
You get "permission denied" because of how Linux handles permission.
Anything in the $HOME
folder belongs to the user, whereas almost anything else belongs to root.
The /etc/dhcp/dhcpd.conf
file you are trying to access belongs to root, and most files in /etc/
belong to root by default for security reasons.
You can still edit this file by elevating your permissions.
To do this you have a number of ways:
use su
which stands for switch user. Without any attributes to it, it functions as a command to switch to the root account, but you need to enter the password of the user you are switching to, and since root has no password by default on Ubuntu (effectively disabling the root account), this won't work unless you have set a password for root, which is not recommended.
using sudo
which elevates your permission for only one command. This is generally used only for command-line apps such as CLI text editors like vim
,nano
etc
using gksu
which elevates your permission for only one command, but unlike sudo
is used for graphical programs such as GUI text editors like gedit
. it uses a graphical prompt to facilitate entering of a password.