Linux Basics
4-7
ful options are –l for more detailed output and -a which shows hidden system files.
•
cd
directory_name
changes the directory to the one specified
•
cat
file_name
displays the contents of
file_name
on the screen.
The vi Editor
To edit a file using the vi editor, enter at the command prompt:
vi [file name]
The vi utility is a three-state line editor: it has a command mode, a line mode and an editing mode. If in
doubt as to which mode you are in, press the <ESC> key which will bring you to the command mode.
Vi Modes and Navigation
Vi has three different modes:
•
command mode for navigation within the open file. You enter command mode by pressing the <ESC>
key.
•
editing mode for text editing. See list of editing commands below for how to enter the editing mode.
•
line mode for file saving, opening, or closing vi. From the command mode, type “:” (the colon).
When entering the program, the user is automatically in the command mode. To navigate to the part of the
file to be edited, use the following keys:
•
h moves the cursor to the left (left arrow)
•
j moves the cursor to the next line (down arrow)
•
k moves the cursor to the previous line (up arrow)
•
l moves the cursor to the right (right arrow)
Having arrived at the location where text should be changed, use these commands to modify the text (note
commands “i” and “o” will move you into the editing mode and everything typed will be taken literally until