Ubuntu – How to edit configuration files

configurationeditingtext-editor

I'm a beginner to Ubuntu. Can anyone tell me how to edit a configuration file?

This is on Ubuntu 18.04 LTS. Thanks in advance.

Best Answer

Configuration files are usually owned by root. For example:

$ ll /etc/default/grub

-rw-r--r-- 1 root root 6801 Jul 18 13:26 /etc/default/grub

 ^^ ^  ^
 || |  +-- Users can only read
 || +----- Members of the group can only read
 |+------- The owner can write
 +-------- The owner can read

In order for a user (yourself) to edit /etc/grub/default you need to use sudo powers. So instead of using:

gedit /etc/default/grub

You must use:

sudo -H gedit /etc/default/grub

At which point you will be prompted for your password.

Note: Related question today: Grub file can't be saved after modification