Knowledge Base:Edit a configuration file

Synopsis
Article description::Step by step guide to edit a configuration file.

Environment
All the time.

Analysis
Configuration files are the default method to configure most software. Use a text editor to edit them. The default text editor in Gentoo is nano.

Resolution
Different text editors may be used on the command line to edit configuration files. Nano will be installed by default on a Gentoo installation, but it is ultimately up to the user what editor to install and use.

Nano will probably be the most accessible editor for beginners, because it behaves a little like many GUI editors, and provides a help bar at the bottom of the screen by default.

The sudo command may be needed to edit system configuration files owned by root.

Emacs
Start Emacs by typing in the terminal, followed by file path and name:

Move around with the arrow keys, insert text freely. To save a file, type (+ followed by +).

To close Emacs, type (+ followed by +).

For "quick-start" documentation directly in Emacs, type: (+ followed by ). For further help on how to use Emacs, type (+ followed by ).

For more information online:


 * A guided tour of Emacs
 * GNU Emacs manual

Nano
Start Nano by typing in the terminal, followed by file path and name:

Nano now shows the content of the text file. Navigate through the text with the arrow keys and make edits as desired.

At the bottom Nano shows shortcuts for common actions (save, exit, etc.). The shortcut to save a file is shown as "^O". Users must prefix the shortcut with the key, so to save a file press +. To exit press +.

Vim
Start Vim by typing in the terminal, followed by file path and name, using  should also be possible:

Vim will create the file upon saving if no such file exists yet.

Vim is a modal editor, it will start in command mode, and can be switched between this and insert mode. Use, , , (by default) to move the cursor in command mode. Enter insert mode, to enter text, by pressing, and return to command mode by pressing. Save by opening the Vim command line, by pressing, then ,. Quit with, ,. Add after  to quit without saving changes.

See Vim/Guide for more instructions on using Vim.