Book: LPI Linux Certification in a Nutshell Section: Chapter 24. Exam 102 Highlighter's Index
### 24.4 Text-Editing, Processing, and Printing #### 24.4.1 Objective 1: Perform Basic File-Editing Operations Using vi Start vi with vi file1 file2. See Table 24-2.

##### Table 24-2. Basic vi Editing Commands

Command | Description
--- | ---
ZZ | Write the file contents (if changed) and quit.
:x | Write the file contents (if changed) and quit (the ex equivalent of ZZ).
:q | Quit without saving changes.
:q! | Quit without saving changes and without confirmation.
:n | Next file. When multiple files are specified for editing, this command loads the next file.
Esc (the Escape key) | Exit insert mode and put the editor back into command mode.
h | Left one character.
j | Down one line.
k | Up one line.
l (ell) | Right one character.
0 (zero) | Beginning of the current line.
^ | First non-whitespace character on the current line.
$ | End of the current line.
H | Top of the screen.
L | Bottom of the screen.
G | End-of-file.
Ctrl-F | Down one screen.
Ctrl-B | Up one screen.
i | Enter insert mode to place text before the cursor.
a | Enter insert mode to place text after the cursor (append). This is necessary at the ends of lines.
C | Delete to end-of-line and enter insert mode.
R | Enter replace mode (a variant of insert mode) and overwrite existing characters.
dm | Delete a text block defined by a movement command m relative to the location where the command started.
dd | Delete the entire current line.
D | Delete to end-of-line (same as d$)
ym | Yank (copy) a text block defined by a movement command m relative to the location where the command started.
yy | Yank the entire current line.
P | Paste text on a line before the cursor.
p | Paste text on a line after the cursor.
/pattern | Search forward for pattern.
?pattern | Search backward for pattern.
n | Repeat the last search.
N | Repeat the last search in the opposite direction.
#### 24.4.2 Objective 2: Manage Printers and Print Queues Printers are assigned to queues, which are managed by lpd , the print daemon. lpd listens for inbound print requests, forking a copy of itself for each active print queue. lpr submits jobs to print queues. lpq queries and displays queue status. lprm allows jobs to be removed from print queues. lpc allows root to administer queues; it has both interactive and command-line forms. filters translate data formats into a printer definition language. Spool directories hold spooled job data. #### 24.4.3 Objective 3: Print Files Files are printed with the lpr command:
    # lpr /etc/lilo.conf
    # man -t 5 myfile.txt | lpr -Pqueue2
- #### 24.4.4 Objective 4: Install and Configure Local and Remote Printers ##### 24.4.4.1 /etc/printcap New printer definitions are added to /etc/printcap:
      lp|ljet:\
              :sd=/var/spool/lpd/lp:\
              :mx#0:\
              :sh:\
              :lp=/dev/lp0:\
              :if=/var/spool/lpd/lp/filter:
              :lf=/var/spool/lpd/lp/log:
- The lines in this example are defined as follows: lp|ljet:\ This parameter defines two alternate names for the printer, lp or ljet. sd=spool_directory This parameter specifies the spool directory, under /var/spool/lpd. mx=max_size The maximum size of a print job in blocks. Setting this to `#0` indicates no limit. sh Suppress header pages. Placing this attribute in printcap sets it, eliminating the headers. lp=printer_device The local printer device, such as a parallel port. if=input_filter The input filter to be used. See Section 24.4.4.2 for additional information. lf=log_file The file where error messages are logged. ##### 24.4.4.2 Filters APSfilter is implemented as executable scripts. Installation configures /etc/printcap automatically. Multiple queues may be defined to give the user access to specific printer capabilities. Magicfilter is a binary program; installation does not automatically create print queues. ##### 24.4.4.3 Remote queues and Samba printers Printing on a remote system or network printer is done through a local queue. /etc/printcap for the local queue looks something like this:
      rlp:\
              :sd=/var/spool/lpd/rlp:\
              :rm=lphost:\
              :rp=rlp:\
              :mx#0:\
              :sh:\
              :if=/usr/local/bin/magicfilter:
- Printing to Windows printers is similar and uses the smbprint filter:
      winpr:\
              :sd=/var/spool/lpd/winpr:\
              :mx#0:\
              :sh:\
              :if=/usr/bin/smbprint: