Useful Commands
less | vi | mail | tar | zip | dd | screen | find | Miscellaneous
less
The less command displays a text document on the console. It is present on most
installation.
# less unixtoolbox.xhtml
Some important commands are (^N stands for [control]-[N]):
* h H good help on display
* f ^F ^V SPACE Forward one window (or N lines).
* b ^B ESC-v Backward one window (or N lines).
* F Forward forever; like "tail -f".
* /pattern Search forward for (N-th) matching line.
* ?pattern Search backward for (N-th) matching line.
* n Repeat previous search (for N-th occurrence).
* N Repeat previous search in reverse direction.
* q quit
vi
Vi is present on ANY Linux/Unix installation (not gentoo?) and it is therefore useful to
know some basic commands. There are two modes: command mode and insertion mode. The
commands mode is accessed with [ESC], the insertion mode with i. Use : help if you are
lost.
The editors nano and pico are usually available too and are easier (IMHO) to use.
Quit
* :w newfilename save the file to newfilename
* :wq or :x save and quit
* :q! quit without saving
Search and move
* /string Search forward for string
* ?string Search back for string
* n Search for next instance of string
* N Search for previous instance of string
* { Move a paragraph back
* } Move a paragraph forward
* 1G Move to the first line of the file
* nG Move to the n th line of the file
* G Move to the last line of the file
* :%s/OLD/NEW/g Search and replace every occurrence
Delete copy paste text
* dd (dw) Cut current line (word)
* D Cut to the end of the line
* x Delete (cut) character
* yy (yw) Copy line (word) after cursor
* P Paste after cursor
* u Undo last modification
* U Undo all changes to current line
mail
The mail command is a basic application to read and send email, it is usually installed. To
send an email simply type "mail user@domain". The first line is the subject, then the mail
content. Terminate and send the email with a single dot (.) in a new line. Example:
# mail
[email protected]
Subject: Your text is full of typos
"For a moment, nothing happened. Then, after a second or so,
nothing continued to happen."