S3_软件手册Man
Categories:
2 分钟阅读
man 命令¶
通过 man 命令名 可以得到大部分安装在 Linux 上的软件的用户手册。
大部分软件在安装时会将它的软件手册安装在系统的特定目录, man 命令就是读取并展示这些手册的命令。在软件手册中,会带有软件的每一个参数的含义、退出值含义、作者等内容,大而全。但一般较少带有使用样例,需要根据自身需要拼接软件参数。
$ # 调出 tar 命令和 ls 命令的文档
$ man tar
$ man ls
文档中,往往会有命令的参数组合以及参数的详细含义,大而全能够很好地描述它,但是这对于我们希望能够快速上手一个命令是不利的,这就需要后面的另一个工具 tldr。
$ man tar
TAR(1) GNU TAR Manual TAR(1)
NAME
tar - an archiving utility
SYNOPSIS
Traditional usage
tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]
UNIX-style usage
tar -A [OPTIONS] ARCHIVE ARCHIVE
tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
$ man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by
default). Sort entries alphabetically if none of -cftuvSUX
nor --sort is specified.
(Output omitted)
tldr 软件¶
通常,软件手册中的内容十分繁多,如果只是希望能够快速了解软件的常用用法,可以使用 tldr 软件。
tldr 软件中包含有一个由社区维护的精简版文档,通过几个简单的例子让用户可以快速地一窥软件的使用方法。
安装¶
在 Debian 系下,可以直接通过 apt 进行安装:
$ sudo apt install tldr
$ # 更新 tldr pages
$ tldr --update
使用¶
直接输入 tldr 命令名 即可。由于是由社区维护的,一些自行安装的软件可能不会有精简过的文档。
输入 tldr tar 的样例:
$ tldr tar
tar
Archiving utility.
Often combined with a compression method, such as gzip or bzip.
More information:
https://www.gnu.org/software/tar
- Create an archive from files:
tar cf {{target.tar}} {{file1}} {{file2}} {{file3}}
- Create a gzipped archive:
tar czf {{target.tar.gz}} {{file1}} {{file2}} {{file3}}
- Extract a (compressed) archive into the current directory:
tar xf {{source.tar[.gz|.bz2|.xz]}}
- Extract an archive into a target directory:
tar xf {{source.tar}} -C {{directory}}
- Create a compressed archive, using archive suffix to determine the compression program:
tar caf {{target.tar.xz}} {{file1}} {{file2}} {{file3}}
- List the contents of a tar file:
tar tvf {{source.tar}}
- Extract files matching a pattern:
tar xf {{source.tar}} --wildcards {{"*.html"}}
可以从输出中快速地了解到:
- 创建存档文件;
- 创建压缩的存档文件;
- 解压一个存档文件;
- 解压一个存档文件到指定目录;
- 创建一个存档文件,并通过给定的目标存档文件的后缀名判断希望的压缩算法。在例子中,目标存档文件的后缀名是
tar.gz,即希望创建由 gzip 压缩的存档文件; - 给出一个存档文件中的文件列表;
- 解压一个存档文件,但是只有特定的文件名的文件才会被解压(在例子中,使用了通配符
*.html,即只有以.html结尾的文件才会被解压)。