There are a great many types of files, but I'm going to stretch it here, and class them into two really broad
families:
Text files are just that.
Binary files are not.
Binary files are meant to be read by machines, text files can be easily edited, and are generally read by
people. But text files can be (and frequently are) read by machines. Examples of this would be configuration
files, and scripts.
There are a number of different text editors available in *nix. A few are found on every system. That would
be '/bin/ed' and '/bin/vi'. 'vi' is almost always a clone such as 'vim' due to license problems. The problem with
'vi' and 'ed' is that they are terribly user unfriendly. Another common editor that is not always installed by
default is 'emacs'. It has a lot more features and capability, and is not easy to learn either.
As to 'user friendly' editors, 'mcedit' and 'pico' are good choices to start with. These are often much easier for
those new to *nix.
The first things to learn are how to exit an editing session, how to save changes to the file, and then how to
avoid breaking long lines that should not be broken (wrapped).
The 'vi' editor
'vi' is one of the most common text editors in the Unix world, and it's nearly always found on any *nix
system. Actually, due to license problems, the '/bin/vi' on a Linux system is always a 'clone', such as 'elvis',
'nvi', or 'vim' (there are others). These clones can act exactly like the original 'vi', but usually have additional
features that make it slightly less impossible to use.
So, if it's so terrible, why learn about it? Two reasons. First, as noted, it's almost guaranteed to be installed,
and other (more user friendly) editors may not be installed by default. Second, many of the 'commands' work
in other applications (such as the pager 'less' which is also used to view man pages). In 'less', accidentally
pressing the 'v' key starts 'vi' in most installations.
'vi' has two modes. The first is 'command mode', and keystrokes are interpreted as commands. The other
mode is 'insert' mode, where nearly all keystrokes are interpreted as text to be inserted.
==> Emergency exit from 'vi' 1. press the <esc> key up to three times, until the computer beeps, or the screen
flashes. 2. press the keys :q! <Enter>
That is: colon, the letter Q, and then the exclamation point, followed by the Enter key.
'vi' commands are as follows. All of these are in 'command' mode:
a Enter insertion mode after the cursor.
A Enter insertion mode at the end of the current line.
i Enter insertion mode before the cursor.
Security Quick−Start HOWTO for Red Hat Linux
8.6. Editing Text Files 63
Commenti su questo manuale