目录

第一步:执行安装命令

第二步:更新tldr数据库

第三步:测试tldr功能

补充:未成功返回的错误类型


在安装之前你得先在Ubuntu上登入你自己的账户(当然你肯定在刚安装好Ubuntu的时候就注册自己的账户并且登录了)。

第一步:执行安装命令

~$ sudo apt-get install tldr

如果执行完命令后返回:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package tldr

则说明无法找到tldr的安装包,需要对数据库进行升级:

$ sudo apt-get update

升级的时候会有很多行的进程,在最后会有:(不同电脑的具体数据可能会稍有差异)

Fetched 26.2 MB in 12s (2180 kB/s)
Reading package lists... Done

现在再执行安装命令:

~$ sudo apt-get install tldr

就能安装了,在安装中间它会问你是否继续,

Do you want to continue? [Y/n] 

键入Y然后回车就能够继续安装了。

第二步:更新tldr数据库

~$ sudo tldr --update

如果返回

tldr: /root/.local/share/tldr: createDirectory: does not exist (No such file or directory)

则说明它找不到tldr文件,我们需要手动创建一个:

sudo mkdir -p /root/.local/share/tldr

注意需要在mkdir指令前加入sudo,否则它会告诉你没有权限在root下创建文件:

mkdir: cannot create directory ‘/root’: Permission denied

创建成功后什么都不会返回。

这时我们再对tldr数据库进行更新:

~$ sudo tldr --update

只有返回:

Cloning into 'tldr'...
remote: Enumerating objects: 79653, done.
remote: Counting objects: 100% (169/169), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 79653 (delta 84), reused 97 (delta 44), pack-reused 79484
Receiving objects: 100% (79653/79653), 19.13 MiB | 700.00 KiB/s, done.
Resolving deltas: 100% (47820/47820), done.

才算更新成功。

一开始可能会因为延迟的原因不成功,如果不成功可以多试几次。

第三步:测试tldr功能

我们利用tldr查询ssh:

~$ sudo tldr ssh
#注意安装好tldr之后要用sudo tldr命令才能进行查询

返回:

ssh
Secure Shell is a protocol used to securely log onto remote systems.It can be used for logging or executing commands on a remote server.More information: https://man.openbsd.org/ssh.- Connect to a remote server:ssh {{username}}@{{remote_host}}- Connect to a remote server with a specific identity (private key):ssh -i {{path/to/key_file}} {{username}}@{{remote_host}}- Connect to a remote server using a specific port:ssh {{username}}@{{remote_host}} -p {{2222}}- Run a command on a remote server with a [t]ty allocation allowing interaction with the remote command:ssh {{username}}@{{remote_host}} -t {{command}} {{command_arguments}}- SSH tunneling: Dynamic port forwarding (SOCKS proxy on localhost:1080):ssh -D {{1080}} {{username}}@{{remote_host}}- SSH tunneling: Forward a specific port (localhost:9999 to example.org:80) along with disabling pseudo-[T]ty allocation and executio[N] of remote commands:ssh -L {{9999}}:{{example.org}}:{{80}} -N -T {{username}}@{{remote_host}}- SSH jumping: Connect through a jumphost to a remote server (Multiple jump hops may be specified separated by comma characters):ssh -J {{username}}@{{jump_host}} {{username}}@{{remote_host}}- Agent forwarding: Forward the authentication information to the remote machine (see man ssh_config for available options):ssh -A {{username}}@{{remote_host}}

此时就成功了。

补充:未成功返回的错误类型

1.如果第一步安装tldr未成功,测试tldr会返回:

Command 'tldr' not found, but can be installed with:
sudo apt install tldr     # version 0.6.4-1build6.3, or
sudo apt install tldr-py  # version 0.7.0-4

2.如果第二步更新tldr数据库未成功,测试tldr会返回:

No tldr entry for xxx     
# xxx表示你测试要查询的命令