cat reads a file. To change the text, you use a text editor. Linux computers have two editors in the terminal:
| Editor | Good for |
|---|---|
nano | Easy. The keys are listed at the bottom of the screen |
vim | Fast when you know it. It is on almost every Linux computer, also very small ones |
In this course
nano FILE and vim FILE open the file in an editor panel next to the terminal:
- Run
nano FILE. - Change the text in the panel.
- Push Save (or Ctrl+S). The file changes.
- Check the result in the terminal:
cat FILE.
If the file does not exist, the panel opens with no text, and Save makes the file. The directory must exist.
Copy before you edit
One wrong character in a settings file can stop a program. Make a copy first:
text
learner@tidepool:~$ cp shop.conf shop.conf.bak
learner@tidepool:~$ nano shop.confIf the change goes wrong, copy the old file back: cp shop.conf.bak shop.conf.
On a real server
On a real server, nano and vim fill the full terminal. Keep this table for later:
| Do | nano | vim |
|---|---|---|
| Type text | Type | Push i first, then type |
| Stop typing | — | Esc |
| Save | Ctrl+O, then Enter | :w, then Enter |
| Leave | Ctrl+X | :q, then Enter |
| Leave and do not save | Ctrl+X, then N | :q!, then Enter |
| Find a word | Ctrl+W | /word, then Enter |