引言
本文介绍tldr和Cheat等实用工具的安装和使用,这些工具虽然本身不能替代man
、info
等命令,但是在很多时候想要快速学习和掌握命令但是忘记常见用法非常有帮助。
个人看法:对于非运维人员简直是神器。
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 */
内容概览
- Ubuntu和CenterOs介绍和安装tldr命令。
- CenterOs和Ubuntu的安装方式使用
- Ubuntu的常见问题和解决方案。
- Ubuntu和CenterOs介绍和安装cheat命令。
- 安装验证和使用
- Ubuntu和CenterOs处理方式一致
- 类似项目列举。
官方资料
在线wiki搜索:tldr | simplified, community driven man pages (ostera.io)(注意国内访问比较慢,需要自带魔法)
官方的安装介绍页面地址:tldr.sh/#installati…
tldr项目地址:github.com/tldr-pages/…
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:~$ tldr tldr - Simplified and community-driven man pages Usage: tldr [-v|--version] ((-u|--update) | [-p|--platform PLATFORM] COMMAND | (-a|--about)) tldr Client program Available 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的数据库没法访问。
ubuntu@VM-8-8-ubuntu:~$ tldr ls No 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版本降级
版本降级相关资料参考自:blog.csdn.net/Fabulous111…
(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.0 Use 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 n sudo n install 16.15.1 # 太新的也会有问题
以上就是ubuntu常见问题和处理。
CenterOs 安装 tldr
CenterOs的安装方式和Ubuntu类似,这里展示安装Node环境之后安装tldr并使用的过程。
安装
- 安装NodeJs,如果嫌麻烦可以直接安装
sudo yum install -y npm
。
[[【Linux】NodeJs 安装和环境变量配置]]
- 我们使用官方提供的命令安装。
sudo npm install -g tldr
- 如果是使用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
参数强制覆盖之前的软链接。
【Linux】Linux命令快速学习神器tldr、cheat介绍和使用(二)https://developer.aliyun.com/article/1395258