Editing files (command prompt)
From Axentra
Some rare circumstances may require you to edit files on your Axentra Server from a command prompt. Two text editors, vi and joe, are available for use on your Server from the command prompt.
| Table of contents |
Notes
- You should not need to edit files from the command prompt under normal usage. Most system settings can be changed more easily in the admin area.
- You will not be able to view or edit most system files or configuration files unless you first gain root access.
- Be very careful when editing system files or configuration files, as improper changes may cause your Server to behave unexpectedly or stop functioning. Axentra does not provide support for problems caused by users making changes to their Server.
Undoing changes
You may find that you have made a change you wish to undo. The Undo function of either editor only lasts as long as the editor is running; if you quit the editor, you lose the ability to reverse the changes you make.
For that reason, it is highly recommended that you make a backup copy of any file you wish to edit before you make any changes. To do so, use this command at the command prompt:
cp /path/to/file.txt /path/to/file.txt.backup
Replace both instances of /path/to/file.txt with the actual path to the file you wish to edit. Then, if you find you want to reverse the change you made, you can recover the original version of the file with this command:
cp /path/to/file.txt.backup /path/to/file.txt
Editors
joe
The joe editor is easy to use for making small changes to files. To edit a file with joe, use this command:
joe /path/to/file.txt
where /path/to/file.txt should be replaced with the actual path to the file you wish to edit. joe is considered a stateless editor, similar to Notepad for Windows. This means that you use the arrow keys to move around the file, and simply type in whatever new text is needed, or backspace over text you wish to remove.
If you find you do not want to save the changes you've made, press Control-C to abort. Other commands in joe (for example, saving the file) take two keystrokes. To save, press Control-K, then D. To save and exit, press Control-K, then X. To display a complete list of other commands available, press Control-K, then H. (The key F1 may also work for this purpose.)
vi
vi is a common editor in the Unix/Linux world, but it has a steep learning curve; it is provided mainly for people who are already familiar with it. If you are a novice and need to edit a file, you should use joe instead. If you wish to learn how to use vi, there are several tutorials available on the internet.
The Axentra Server actually uses vim, a common vi clone. If you find that the vi command does not work for you (as might be the case in single-user mode), use vim instead.
See Also
- sudo
- The Vim homepage (http://www.vim.org/)
- The Joe homepage (http://sourceforge.net/projects/joe-editor/)
