# 11.1.快速入门

将信息写在纸上是一个至关重要的功能，尽管有许多尝试去消除这一点。打印有两个基本组成部分。数据必须传送到打印机，并且必须以打印机能够理解的形式呈现。

基本打印可以快速设置。打印机必须能够打印普通的 `ASCII` 文本。有关打印其他类型文件的信息，请参见 [Filters](https://docs.freebsd.org/en/books/handbook/printing/#printing-lpd-filters)。

1. 创建一个目录来存储正在打印的文件：

   ```sh
   # mkdir -p /var/spool/lpd/lp
   # chown daemon:daemon /var/spool/lpd/lp
   # chmod 770 /var/spool/lpd/lp
   ```
2. 作为 `root` 用户，创建 `/etc/printcap` 文件，内容如下：

   ```ini
   lp:\
   lp=/dev/unlpt0:\  ①
   sh:\
   mx#0:\
   sd=/var/spool/lpd/lp:\
   lf=/var/log/lpd-errs:
   ```

   * ① 这行是用于连接到 `USB` 端口的打印机。

   对于连接到并行端口或“打印机”端口的打印机，使用：

   ```ini
   :lp=/dev/lpt0:\
   ```

   对于直接连接到网络的打印机，使用：

   ```ini
   :lp=:rm=network-printer-name:rp=raw:\
   ```

   将 *network-printer-name* 替换为网络打印机的 `DNS` 主机名。
3. 通过编辑 `/etc/rc.conf` 文件启用 LPD，添加以下行：

   ```ini
   lpd_enable="YES"
   ```

   启动服务：

   ```sh
   # service lpd start
   Starting lpd.
   ```
4. 打印测试：

   ```sh
   # printf "1. This printer can print.\n2. This is the second line.\n" | lpr
   ```

   > **技巧**
   >
   > 如果两行没有从左边界开始，而是呈现“阶梯形”，请参见 [防止纯文本打印机出现阶梯形问题](https://docs.freebsd.org/en/books/handbook/printing/#printing-lpd-filters-stairstep)。

   现在可以使用 `lpr` 打印文本文件。可以在命令行中给出文件名，或直接将输出通过管道传递给 `lpr`。

   ```sh
   % lpr textfile.txt
   % ls -lh | lpr
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://handbook.bsdcn.org/di-11-zhang-da-yin/11.1.-kuai-su-ru-men.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
