引言

本文介绍tldr和Cheat等实用工具的装置和应用,这些工具尽管自身不能代替maninfo等命令,然而在很多时候想要疾速学习和把握命令然而遗记常见用法十分有帮忙。

集体认识:对于非运维人员几乎是神器。

tldr:全称 too long, Don’t read,翻译成中文就是太长不想浏览,比–help或者man这些传统手册更便捷、更便于应用。
cheat:舞弊。

这两个命令有什么用?这里简略举个例子就晓得了:

ubuntu@VM-8-8-ubuntu:~$ sudo tldr ls  ls  List directory contents.  More information: https://www.gnu.org/software/coreutils/ls.  - List files one per line:    ls -1  - List all files, including hidden files:    ls -a  - List all files, with trailing / added to directory names:    ls -F  - Long format list (permissions, ownership, size, and modification date) of all files:    ls -la  - Long format list with size displayed using human-readable units (KiB, MiB, GiB):    ls -lh  - Long format list sorted by size (descending):    ls -lS  - Long format list of all files, sorted by modification date (oldest first):    ls -ltr  - Only list directories:    ls -d */

内容概览

  1. Ubuntu和CenterOs介绍和装置tldr命令。

    1. CenterOs和Ubuntu的装置形式应用
    2. Ubuntu的常见问题和解决方案。
  2. Ubuntu和CenterOs介绍和装置cheat命令。

    1. 装置验证和应用
    2. Ubuntu和CenterOs解决形式统一
  3. 相似我的项目列举。

官网材料

在线wiki搜寻:tldr | simplified, community driven man pages (ostera.io)
(留神国内拜访比较慢,须要自带魔法)

官网的装置介绍页面地址:https://tldr.sh/#installation

tldr我的项目地址:https://github.com/tldr-pages/tldr

tldr

Ubuntu装置tldr

装置

Ubuntu 装置比较简单,间接应用sudo apt-get install tldr装置。

sudo apt-get install tldr

如果下面的命令装置之后仍然无奈应用,能够依照上面的命令进行装置:

sudo apt-get install npm
sudo apt-get install nodejs-legacy
sudo npm install n -g

留神这里有两种形式,一种是应用latest版本,另外一种是应用stable版本,集体倡议应用stable版本,如果Ubuntu的零碎版本比拟低,则须要升高node版本。

sudo n stable(或 sudo n latest)
sudo npm install -g tldr

当然也能够不应用nodeJS,也能够应用pip

pip3 install tldr

如果是Mac零碎就是非常简略了:

brew install tldr

验证

在ubuntu当中验证间接应用:

ubuntu@VM-8-8-ubuntu:~$ tldrtldr - Simplified and community-driven man pagesUsage: tldr [-v|--version]             ((-u|--update) | [-p|--platform PLATFORM] COMMAND | (-a|--about))  tldr Client programAvailable options:  -h,--help                Show this help text  -v,--version             Show version  -u,--update              Update offline cache of tldr pages  -p,--platform PLATFORM   Prioritize specfic platform while searching. Valid                           values include linux, osx, windows, sunos  COMMAND                  name of the command  -a,--about               About this program

Ubuntu装置常见问题

No tldr entry for xxx

Ubuntu装置tldr应用tldr ls之后,很有可能呈现相似No tldr entry for ls的命令,呈现这种状况可能有上面两种状况:

  • 首次装置须要更新tldr的“数据库”。
  • 当天用户装置应用sudo,tldr的数据库没法拜访。

更新tldr

ubuntu@VM-8-8-ubuntu:~$ tldr lsNo tldr entry for ls

更新tldr的数据库。

ubuntu@VM-8-8-ubuntu:~$ sudo tldr --update✔ Updating...✔ Creating index...

当然也能够应用tldr -u

ubuntu@VM-8-8-ubuntu:~$ sudo tldr --u

sudo装置应用

集体ubuntu应用了sudo装置之后,应用sudo tldr才能够失常应用,因为日常登录的用户为ubuntu用户,装置的过程全副应用sudo,查问某个命令也须要应用root身份进行查问。

所以如果呈现No tldr entry for xxx,有可能是你用的sudo装置然而以后的用户却没有sudo的权限。

ubuntu@VM-8-8-ubuntu:~$ sudo tldr ls  ls  List directory contents.  More information: https://www.gnu.org/software/coreutils/ls.  - List files one per line:    ls -1  - List all files, including hidden files:    ls -a  - List all files, with trailing / added to directory names:    ls -F  - Long format list (permissions, ownership, size, and modification date) of all files:    ls -la  - Long format list with size displayed using human-readable units (KiB, MiB, GiB):    ls -lh  - Long format list sorted by size (descending):    ls -lS  - Long format list of all files, sorted by modification date (oldest first):    ls -ltr  - Only list directories:    ls -d */

nodeJs版本降级

版本降级相干材料参考自:https://blog.csdn.net/Fabulous1111/article/details/84983869

(1)装置node版本治理模块n
    sudo npm install n -g

下边步骤请依据本人须要抉择

(2)装置稳定版
    sudo n stable
(3)装置最新版
    sudo n latest
(4) 版本降级/降级
    sudo n 版本号
(5)检测目前装置了哪些版本的node
n

提醒内容如下:

   node/16.15.1    node/18.13.0    node/19.5.0Use up/down arrow keys to select a version, return key to install, d to delete, q to quit
切换版本(不会删除曾经装置的其余版本)
n 版本号

比方:n 16.15.1

(7)删除版本
sudo n rm 版本号
(8)间接移除Nodejs

PS:留神不同的操作系统命令会有差异,这里为Ubuntu的卸载形式

sudo apt-get remove nodejs
简略应用
sudo npm install -g nsudo n install 16.15.1 # 太新的也会有问题

以上就是ubuntu常见问题和解决。

CenterOs 装置 tldr

CenterOs的装置形式和Ubuntu相似,这里展现装置Node环境之后装置tldr并应用的过程。

装置

  1. 装置NodeJs,如果嫌麻烦能够间接装置sudo yum install -y npm

[[【Linux】NodeJs 装置和环境变量配置]]

  1. 咱们应用官网提供的命令装置。
sudo npm install -g tldr
  1. 如果是应用NodeJs环境变量设置的形式装置,须要设置软链接,tldr命令默认会装置到nodeJs装置门路的Bin目录上面,如果不好了解,能够参考上面的软链接构建命令。
还有一种形式是在Path中设置/xx/nodejs/bin 为环境变量
[zxd@localhost ~]$ sudo ln -s /opt/nodeJs/bin/tldr /usr/local/bin[sudo] password for zxd: 
如果软链接门路构建谬误,能够应用sudo ln -fs /opt/nodeJs/bin/tldr /usr/local/bin退出 -f参数强制笼罩之前的软链接。

验证

因为构建了tldr软链接,咱们能够再任意门路应用这个命令。如果敲入tldr命令呈现上面的提醒证实装置胜利:

[zxd@localhost bin]$ tldrUsage: tldr command [options]Simplified and community-driven man pagesOptions:  -v, --version            Display version  -l, --list               List all commands for the chosen platform in the cache  -a, --list-all           List all commands in the cache  -1, --single-column      List single command per line (use with options -l or -a)  -r, --random             Show a random command  -e, --random-example     Show a random example  -f, --render [file]      Render a specific markdown [file]  -m, --markdown           Output in markdown format  -o, --os [type]          Override the operating system [linux, osx, sunos, windows]  --linux                  Override the operating system with Linux  --osx                    Override the operating system with OSX  --sunos                  Override the operating system with SunOS  --windows                Override the operating system with Windows  -t, --theme [theme]      Color theme (simple, base16, ocean)  -s, --search [keywords]  Search pages using keywords  -u, --update             Update the local cache  -c, --clear-cache        Clear the local cache  -h, --help               Show this help message  Examples:    $ tldr tar    $ tldr du --os=linux    $ tldr --search "create symbolic link to file"    $ tldr --list    $ tldr --list-all    $ tldr --random    $ tldr --random-example  To control the cache:    $ tldr --update    $ tldr --clear-cache  To render a local file (for testing):    $ tldr --render /path/to/file.md

咱们应用tldr ls查看ls命令的用法,的确赏心悦目。

[zxd@localhost ~]$ tldr ls✔ Page not found. Updating cache...⠴ Creating index...✔ Creating index...  ls  List directory contents.  More information: https://www.gnu.org/software/coreutils/ls.  - List files one per line:    ls -1  - List all files, including hidden files:    ls -a  - List all files, with trailing / added to directory names:    ls -F  - Long format list (permissions, ownership, size, and modification date) of all files:    ls -la  - Long format list with size displayed using human-readable units (KiB, MiB, GiB):    ls -lh  - Long format list sorted by size (descending):    ls -lS  - Long format list of all files, sorted by modification date (oldest first):    ls -ltr  - Only list directories:    ls -d */

Cheat

介绍

这个漫画是Cheat恶搞man命令查一个命令须要翻几本书的工夫,挺有意思的。

cheat:有坑骗的意思,能够间接了解为舞弊或者舞弊

官网材料

github我的项目地址:
cheat/cheat: cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember. (github.com)

官网装置教程:cheat/INSTALLING.md at master · cheat/cheat (github.com)

手动装置

类Unix

类Unix零碎能够应用上面一串命令解决。

cd /tmp \  && wget https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz \  && gunzip cheat-linux-amd64.gz \  && chmod +x cheat-linux-amd64 \  && sudo mv cheat-linux-amd64 /usr/local/bin/cheat

集体的CenterOs试验如下:

[zxd@localhost ~]$ cd /tmp \>   && wget https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz \>   && gunzip cheat-linux-amd64.gz \>   && chmod +x cheat-linux-amd64 \>   && sudo mv cheat-linux-amd64 /usr/local/bin/cheat--2023-01-28 18:34:35--  https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gzResolving github.com (github.com)... 20.205.243.166Connecting to github.com (github.com)|20.205.243.166|:443... connected.Unable to establish SSL connection.[zxd@localhost tmp]$ cd /tmp   && wget https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz   && gunzip cheat-linux-amd64.gz   && chmod +x cheat-linux-amd64   && sudo mv cheat-linux-amd64 /usr/local/bin/cheat--2023-01-28 18:34:59--  https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gzResolving github.com (github.com)... ... 省略一些装置提示信息... github拜访比较慢,急躁期待100%[=============================================================================>] 4,696,443   9.87KB/s   in 6m 11s 2023-01-28 18:41:13 (12.4 KB/s) - ‘cheat-linux-amd64.gz’ saved [4696443/4696443]

集体的Ubuntu云服务器的试验如下:

ubuntu@VM-8-8-ubuntu:~$ cd /tmp \  && wget https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz \  && gunzip cheat-linux-amd64.gz \  && chmod +x cheat-linux-amd64 \  && sudo mv cheat-linux-amd64 /usr/local/bin/cheat--2023-01-28 10:56:00--  https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz... 省略信息Saving to: ‘cheat-linux-amd64.gz’cheat-linux-amd64.gz              100%[==========================================================>]   4.48M   871KB/s    in 1m 42s  2023-01-28 10:57:43 (44.9 KB/s) - ‘cheat-linux-amd64.gz’ saved [4696443/4696443]ubuntu@VM-8-8-ubuntu:/tmp$ cheatA config file was not found. Would you like to create one now? [Y/n]: yWould you like to download the community cheatsheets? [Y/n]: yCloning community cheatsheets to /home/ubuntu/.config/cheat/cheatsheets/community.Enumerating objects: 335, done.Counting objects: 100% (335/335), done.Compressing objects: 100% (314/314), done.Total 335 (delta 36), reused 274 (delta 19), pack-reused 0Cloning personal cheatsheets to /home/ubuntu/.config/cheat/cheatsheets/personal.Created config file: /home/ubuntu/.config/cheat/conf.ymlPlease read this file for advanced configuration information.
留神:这里可能须要更改版本号(“4.4.0”)和存档(“cheat-linux-amd64.gz”),具体取决于装置平台。

能够浏览 releases page 理解以后命令反对的平台。

通过 go install装置

如果有GO 1.17 以上的版本,能够通过go install装置cheat。

go install github.com/cheat/cheat/cmd/cheat@latest

其余装置形式

上面是官网介绍的其余装置形式。

Package managerPackage(s)
aurcheat, cheat-bin
brewcheat
dockerdocker-cheat
nixnixos.cheat
snapcheat

根底应用

和tldr相似,第一次应用cheat也须要构建“数据库”,然而cheat比tldr的应用体验更好,咱们只须要依照提醒输出两次y确认即可:

[zxd@localhost tmp]$ cheat A config file was not found. Would you like to create one now? [Y/n]: yWould you like to download the community cheatsheets? [Y/n]: yCloning community cheatsheets to /home/zxd/.config/cheat/cheatsheets/community.Enumerating objects: 335, done.Counting objects: 100% (335/335), done.Compressing objects: 100% (314/314), done.Total 335 (delta 36), reused 274 (delta 19), pack-reused 0Cloning personal cheatsheets to /home/zxd/.config/cheat/cheatsheets/personal.Created config file: /home/zxd/.config/cheat/conf.ymlPlease read this file for advanced configuration information.

最初是间接应用,个人感觉要比tldr麻烦事件少很多:

和 tldr的区别是排版的形式有点不同
[zxd@localhost tmp]$ cheat ls# To display everything in <dir>, excluding hidden files:ls <dir># To display everything in <dir>, including hidden files:ls -a <dir># To display all files, along with the size (with unit suffixes) and timestamp:ls -lh <dir># To display files, sorted by size:ls -S <dir># To display directories only:ls -d */ <dir># To display directories only, include hidden:ls -d .*/ */ <dir># To display all files sorted by changed date, most recent first:ls -ltc # To display files sorted by create time:ls -lt# To display files in a single column:ls -1# To show ACLs (MacOS):# see also `cheat chmod` for `/bin/chmod` options for ACLs/bin/ls -le# To show all the subtree files (Recursive Mode):ls -R

Uuntu的应用相似:

# 根底应用ubuntu@VM-8-8-ubuntu:/tmp$ cheat cp# To copy a file:cp ~/Desktop/foo.txt ~/Downloads/foo.txt# To copy a directory:cp -r ~/Desktop/cruise_pics/ ~/Pictures/# To create a copy but ask to overwrite if the destination file already exists:cp -i ~/Desktop/foo.txt ~/Documents/foo.txt# To create a backup file with date:cp foo.txt{,."$(date +%Y%m%d-%H%M%S)"}# To copy a symlink that points to a directory (and is thus soft) and not# 'expand' the symlink (aka, preserve its nature as a symlink):# Note this does NOT work (note trailing '/'):  cp -P /path/to/symlink-dir/cp -P <symlink-dir> <dest-dir># To copy sparsely:cp --sparse=always <src> <dest>

相似我的项目

还有更多和cheat以及tldr相似的我的项目,这里就不过多介绍了。

Cheat 容许您在命令行上创立和查看交互式备忘单。它旨在帮忙揭示 Linux 系统管理员他们常常应用但不够频繁而无奈记住的命令的选项。

cheat.sh 将来自多个起源(包含 tldr-pages)的备忘单聚合到 1 个对立界面中。

devhints Rico 的备忘单不仅仅关注命令行,还包含大量与编程相干的其余备忘单。

eg 在命令行上提供了具体的示例和解释。示例来自存储库,但例如反对显示自定义示例和命令以及默认值。

kb 是一个极简的命令行知识库管理器。 kb 可用于以极简主义和洁净的形式组织您的笔记和备忘单。它还反对非文本文档。

navi 是一个交互式备忘单工具,它容许您即时浏览特定示例或残缺命令。

bropages(已弃用)是对手册页的高度可读性补充。它显示了 Unix 命令的扼要、常见示例。这些示例由用户群提交,能够投票赞成或拥护;最好的条目是人们在查找命令时最先看到的内容。

写在最初

整体体验下来集体比拟偏差cheat一点,类Unix零碎装置官网的教程一个名称就能够实现,而tldr须要Node环境,同时因为Node更新速度就像喝汤容易导致Linux零碎版本或者内核版本低而不反对的问题。