Mac OS X Server: Editing Files in Single User Mode

My server won't start up into the Workspace Manager. How can I edit files in single-user mode?
To learn how to boot into single-user mode see the following article:

Article 30837: "Mac OS Server: Booting into Single-User Mode"

We ship a number of common editors with Mac OS X Server, including ed, emacs, ex, edit, and vi. Unfortunately, some of these editors do not work well in single-user mode. Some require better terminal support than is available in single-user mode; others try to write to /tmp, which isn't possible while booted from a read-only file system such as a CD-ROM; others are just plain unfriendly to the uninitiated.

Fortunately, the standard Mac OS X Server distribution includes pico, a simple, display-oriented text editor that overcomes the above problems. In order to use pico, you will need to change your terminal settings.

Note: The "#" symbol does not need to be typed. It represents the prompt at which commands are typed.

# TERM=vt100
# export TERM
# ^L (This means hold down the control key and the L key, then press return. This is so that the screen will draw.)
# pico the.file.you.want.to.edit

Here are the only commands you really need to know in order to edit a file using pico, some of which are displayed right at the bottom of the screen:

Ctrl-F: Move Forward a character
Ctrl-B: Move Backward a character
Ctrl-P: Move to the Previous line
Ctrl-N: Move to the Next line
Ctrl-D: Delete the character at the cursor position (or just use Backspace to delete the previous character)
Ctrl-X: Save the file and quit (press "y" and then Return to confirm the save)
Ctrl-G: Display help text listing the above commands and more

Normally, pico will also let you use the arrow keys to move around. However, these keys have not been mapped yet when you're in single-user mode, so you will need to use the Control-key combinations above. Similarly, you may be used to a keymapping that uses a different key (such as the Caps Lock key) as the Control key. This mapping has not happened yet either in single-user mode, so the Control key is in fact the Control key.

See also: The pico(1) System Reference Manual page
Published Date: Feb 20, 2012