Linux Format

A quick reference to config files

-

Editing configurat­ion files directly can be a little risky at times, as a mistake may mean that the program they relate to may fail to start. This becomes more than just a little inconvenie­nt if the program is critical to using your system.

One such file is the user specificat­ion file at /etc/passwd – a mistake in this may leave you unable to login. While it may be possible to boot from a rescue disk and fix the problem, this is one of those problems that we would prefer not to have in the first place.

What we want is a program that will enable us to edit the file, but also check that all is well before actually writing it back to disk. Such a program is vipw. Despite the name, this doesn’t necessaril­y use vi to edit the file – cue huge sighs of relief from anyone who’s used that – but can work with any editor you choose.

What it does is to make a temporary copy of the passwd file and load that into your chosen editor. After saving, it makes sure the edited temporary copy is still valid before copying it over the original. If it is not valid, you are warned and given the chance to re-edit the file.

How does it choose your editor? It first looks at the $VISUAL environmen­t variable; if that if not present it uses

$EDITOR. Only if it fails to find both does it subject you to vi. You will normally find $EDITOR defined in your profile – try

$ echo $EDITOR

to see what it is. Many distros now use

nano. Alternativ­ely, you can set it on the command line when running vipw with the following:

$ Editor=”/usr/bin/nano” vipw

There are similar helper programs for editing the group and sudoers files called, unsurprisi­ngly, vigr and viduso.

Newspapers in English

Newspapers from Australia