12.07.2015 Views

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Editing Text Files 113Vi EditorThe Vi editor is text based, so it must be run in a terminal. To use it, you must have thevim-minimal RPM package installed. If it is not installed, install it as described in Chapter3, “Operating System Updates.”To open a file in Vi, type vi at the shell prompt. If the file does not exist, it willbe created with the filename you provided the first time you saved it. Remember, you canalways give the full path to the file if you are not in the directory that contains the file.Also remember that you can only modify files you have write permission to. Vi will letyou open files you have only read access to but will deny the save operation if you do nothave write access. For more information on read and write permissions, refer to the “FilePermissions” section later in this chapter.As shown in Figure 4.6, the Vi editor is very basic. By default, you are not even allowed toinput characters.4FIGURE 4.6The Vi EditorTo start making changes to the file or start typing content into a new file, change toinsert mode by pressing the I key. You will notice that the status at the bottom of thescreen changes to -- INSERT --. Next, start typing. Vi does not have automatic wordwrap, so you must press Enter to move the cursor to the next line. When you are finishedtyping the contents of the file, press the Esc key to exit insert mode. To save a file, exitinsert mode, type :w (the w is for write), and press Enter. If you have permission to savethe file, it will be saved. If you started Vi without specifying a filename, type :w, press thespacebar to add a space, type the desired filename, and press Enter to save the file.To exit Vi, type :q (for quit), and press Enter. To exit without saving the file, follow the :qcommand by an exclamation point (!).Common Vi operations are provided in Table 4.2. For even more instructions on usingthe Vi editor, pick up an inexpensive book on the editor or read some of the numerous Vitutorials on the Web.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!