日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

利用tldr工具再也不怕记不住Linux命令

發布時間:2023/12/3 linux 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 利用tldr工具再也不怕记不住Linux命令 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 1 前言
  • 2 tldr
  • 3 安裝
  • 4 使用


1 前言

??linux命令非常多,少用的命令往往易忘記,甚至常用的語法較為復雜的命令也不好記住。當然有些太復雜的命令也不需要死記硬背,我們往往會借助man命令去查找命令的具有用法。man功能著實強大,但有的時候顯得繁瑣累贅;我們只需要關鍵的使用語法、例子,man給出了一堆詳細信息,影響我們提取關鍵信息,特別是比較陌生的命令。


acuity@ubuntu:~$ man tar TAR(1) BSD General Commands Manual TAR(1)NAMEtar — The GNU version of the tar archiving utilitySYNOPSIStar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --get [options] [pathname ...]DESCRIPTIONTar stores and extracts files from a tape or disk archive.The first argument to tar should be a function; either one of the letters Acdrtux, or one of the long function names. A function letter need not be prefixed with ``-'', and may be combined with other single-letteroptions. A long function name must be prefixed with --. Some options take a parameter; with the single-letter form these must be given as separate arguments. With the long form, they may be given by appending =value tothe option.FUNCTION LETTERSMain operation mode:-A, --catenate, --concatenateappend tar files to an archive-c, --createcreate a new archive-d, --diff, --comparefind differences between archive and file system--deletedelete from the archive (not on mag tapes!)-r, --appendappend files to the end of an archive-t, --listlist the contents of an archive--test-labeltest the archive volume label and exit

??總會有一些高效的工具出現,去改變一些東西,比如tldr工具,一個使用非常方便、高效的linux命令工具查詢器,而且還是開源的。


2 tldr

??tldr,作者給出的含義是Too Long; Didn’t Read,直譯即是“太長,不值得一讀”,嚴重懷疑在明嘲暗諷man。tldr簡化了煩瑣的man的輸出幫助信息,只列出關鍵的語法信息、例子,方便用戶使用。


??tldr開源地址:https://github.com/tldr-pages/tldr


3 安裝

??tldr安裝比較簡單,主機聯網狀態下,可以直接在線安裝。x64 ubuntu16 安裝步驟如下:


  • 第一步, 安裝 npm
sudo apt-get install npm -y

??為了快速下載,我們先更新一下npm 的包鏡像源:

sudo npm config set registry https://registry.npm.taobao.org

??接著升級到最新版本的npm:

sudo npm install npm@latest -g
  • 第二步,安裝 nodejs
sudo apt install nodejs

??可能會提示如下錯誤:

acuity@ubuntu:~$ sudo apt install nodejs Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required:gyp libjs-inherits libjs-node-uuid libjs-underscore libuv1 libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream node-combined-stream node-cookie-jar node-delayed-stream node-forever-agentnode-form-data node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirpnode-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slidenode-tar node-tunnel-agent node-underscore node-which Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED:nodejs-dev nodejs-legacy npm The following packages will be upgraded:nodejs 1 upgraded, 0 newly installed, 3 to remove and 89 not upgraded. Need to get 18.1 MB of archives. After this operation, 68.5 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://deb.nodesource.com/node_12.x xenial/main amd64 nodejs amd64 12.20.1-1nodesource1 [18.1 MB] Err:1 https://deb.nodesource.com/node_12.x xenial/main amd64 nodejs amd64 12.20.1-1nodesource1 Operation too slow. Less than 10 bytes/sec transferred the last 120 seconds E: Failed to fetch https://deb.nodesource.com/node_12.x/pool/main/n/nodejs/nodejs_12.20.1-1nodesource1_amd64.deb Operation too slow. Less than 10 bytes/sec transferred the last 120 seconds E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
??如果出現該錯誤,說明安裝源過于陳舊,根據以下步驟更新安裝源:

【1】配置域名解析文件resolv.conf ,增加“nameserver 8.8.8.8”內容

sudo vim /etc/resolv.conf

【2】更新安裝源

sudo apt-get update

??更新完成,再執行sudo apt install nodejs即可成功安裝nodejs。


  • 第三步,安裝tldr
sudo npm install -g tldr
  • 第四步,使用前建議先更新下
sudo tldr --update

4 使用

??執行tldr會提示使用方法,還有例子,很是人性化。

acuity@ubuntu:~$ tldr Usage: tldr command [options]Simplified and community-driven man pagesOptions:-V, --version output the version number-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]--linux Override the operating system with Linux--osx Override the operating system with OSX--sunos Override the operating system with SunOS-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 display help for commandExamples:$ tldr tar$ tldr du --os=linux$ tldr --search "create symbolic link to file"$ tldr --list$ tldr --list-all$ tldr --random$ tldr --random-exampleTo control the cache:$ tldr --update$ tldr --clear-cacheTo render a local file (for testing):$ tldr --render /path/to/file.md

??查詢tar命令的使用方法,與前面的man的查詢結果相比,tldr的結果顯得通俗、精煉,方便用戶抓住關鍵信息。

acuity@ubuntu:~$ tldr tar ? Page not found. Updating cache... ? Creating index...tarArchiving utility.Often combined with a compression method, such as gzip or bzip.More information: https://www.gnu.org/software/tar.- [c]reate an archive from [f]iles:tar cf target.tar file1 file2 file3- [c]reate a g[z]ipped archive from [f]iles:tar czf target.tar.gz file1 file2 file3- [c]reate a g[z]ipped archive from a directory using relative paths:tar czf target.tar.gz --directory=path/to/directory .- E[x]tract a (compressed) archive [f]ile into the current directory:tar xf source.tar[.gz|.bz2|.xz]- E[x]tract a (compressed) archive [f]ile into the target directory:tar xf source.tar[.gz|.bz2|.xz] --directory=directory- [c]reate a compressed archive from [f]iles, using [a]rchive suffix to determine the compression program:tar caf target.tar.xz file1 file2 file3- Lis[t] the contents of a tar [f]ile [v]erbosely:tar tvf source.tar- E[x]tract [f]iles matching a pattern:tar xf source.tar --wildcards "*.html"

總結

以上是生活随笔為你收集整理的利用tldr工具再也不怕记不住Linux命令的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。