Archive

Just Edit

“Just edit this file…”

“Err… how do I do that? When I type edit it just does nothing.”

If you’re new to this UNIX lark, you will rapidly discover that more or less all of the configuration of your computer is done in text files, and that therefore you will need an editor to get things working. (Or at least, to follow the instructions that the weirdo hair-shirted gurus on the MailingList will try to get you to follow).

Something which is usually implied is that you know how to edit these files, which implies knowing where to find and use a text editor. This isn’t necessarily something which a UNIX beginner knows.

Editing as root

All sensitive system files should only be editable by the root user. This is so that users can’t easily break their system. However, you’ll probably need to edit these files at some point. If you’re running the X Window System (X), then you have the option of logging out and logging into X as root. You can then use a graphical editor to edit your file. However, don’t admit to doing this in public – running X as root is generally considered a moderately Bad Thing, and you’ll only get sidelined into an argument about it.

If you’re concerned about running X as root, or it’s a pain to keep logging out and logging back in again, you could use sudo (/PseudoRoot) to launch an editor as root. However, if you haven’t got X running at all, or just like working in a terminal emulator, then you will need a console editor. This is where it can get unpleasant for the new user. Most of the wearing-broken-glass-against-the-skin brigade (myself included) use either emacs or vi as their text editor of choice. Both emacs and vi are immensely powerful, and have more options, switches, toggles and controls than your average nuclear submarine. Not for the faint-hearted.

My suggestion for a simple, easy-to-use text editor that can be found on most systems is…

nano

“pico” is the default text editor included in the “pine” mail client package.

“nano” is the GNU open source model based on “pico”. As usual, the open source coders include a sense of humour and called it “nano” to mean it is smaller than “pico” (but with the same, or better, functionality) and the ever present acronym: Not ANOther editor. Nano has only a few controls, and they’re printed at the bottom of the screen to help you.

If you don’t have nano, or want something slightly more “powerful”, then you might also try

jed

This is designed to look like emacs, but it’s much smaller and faster and a bit less daunting. Press F10 to access the menus at the top of the screen for common tasks.

mcedit

Part of the Midnight Commander package is a particularly easy-to-use editor which can be invoked with mcedit or mc -e (or just run mc, choose the file to edit and then press F4). One of the most useful features of the current versions of this editor is that it remembers the cursor position in each file between invocations – perfect for adjusting settings in configurations files.

joe

Reminds me of MS-DOS edit for some reason, although operates more like a cross-between EMACS and Vim. Console-based, and relatively easy to use — once you get used to the CTRL-letter combinations.

Leave a Reply