Cheat是主要基于Python软件的命令行,可让系统管理员查看和保存有用的备忘单。它检索委托命令的简单文本示例,该示例将提醒用户其他选择,参数或常用的用法。作弊用于“您经常使用的命令,但是现在不足以考虑”
在安装Cheat之前,我们需要确保系统上的所有内容都是最新的,如以下命令所示–
$ sudo apt-get update && sudo apt-get upgrade
最好使用Python软件包管理器Pip安装Cheat。要安装pip,请使用以下命令-
$ sudo apt-get install python-pip
要安装作弊功能,请使用以下命令-
$ sudo pip install cheat
样本输出应如下所示–
Collecting cheat Downloading cheat-2.1.24.tar.gz (42kB) 100% |████████████████████████████████| 51kB 89kB/s Collecting docopt>=0.6.1 (from cheat) Downloading docopt-0.6.2.tar.gz Collecting pygments>=1.6.0 (from cheat) Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB) 100% |████████████████████████████████| 757kB 892kB/s Installing collected packages: docopt, pygments, cheat Running setup.py install for docopt ... done Running setup.py install for cheat ... done Successfully installed cheat-2.1.24 docopt-0.6.2 pygments-2.1.3
要验证是否安装了作弊软件,请使用以下命令–
$ cheat -v
样本输出应如下所示–
cheat 2.1.24
我们能够继续创建我们的个人备忘单,Cheat希望知道我们希望默认使用哪种文本内容编辑器来编辑表单。要设置nano文本编辑器,请使用以下命令–
$ export EDITOR=/usr/bin/vim
我们可以使用以下命令确认以上命令是否成功–
$ printenv EDITOR
输出应该是这样的–
/usr/bin/vim
要使此更改在以后的所有Shell会话中永久保留,必须将环境变量声明添加到.bashrc文件中。这是在bash shell会话开始时运行的几个文件之一。要打开bashrc文件,请使用以下命令-
$ nano ~/.bashrc
样本输出应如下所示–
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac export EDITOR=/usr/bin/vim # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000
然后添加相同的导出命令,如下所示
..................................................... # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac export EDITOR=/usr/bin/vim # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth ...........................................
保存并退出文件。
要以最基本的形式运行Cheat的tail命令,请使用以下命令-
$ cheat tail
样本输出应如下所示–
# To show the last 10 lines of file tail file # To show the last N lines of file tail -n N file # To show the last lines of file starting with the Nth tail -n +N file # To show the last N bytes of file tail -c N file # To show the last 10 lines of file and to wait for file to grow tail -f file
要查看所有现有作弊项的列表,请使用以下命令–
$ cheat -l
输出应该是这样的–
7z /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/7z ab /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ab apk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apk apparmor /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apparmor apt /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt apt-cache /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-cache apt-get /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-get aptitude /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/aptitude asciiart /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asciiart asterisk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asterisk at /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/at awk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/awk bash /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bash bower /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bower chmod /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chmod chown /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chown convert /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/convert crontab /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/crontab csplit /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/csplit cups /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cups curl /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/curl cut /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cut date /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/date dd /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dd df /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/df dhclient /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dhclient ..............................................................................................
要创建备忘单,请使用以下命令–
$ cheat -e nhooo
上面的命令nhooo是备忘单名称。它将打开一个空白备忘单。现在添加您的秘籍并保存。
要搜索备忘单,请使用以下命令–
$ cheat -s tail
上面的命令正在搜索tail命令。样本输出应如下所示–
asterisk: # To print out the details of SIP accounts: dnf: # To search package details for the given string dpkg: # List all installed packages with versions and details hardware-info: # Display all hardware details journalctl: # Actively follow log (like tail -f) mdadm: # See detailed array confiration/status mdadm --detail /dev/md${M} mdadm --detail --scan > /etc/mdadm/mdadm.conf p4: # Print details related to Client and server configuration pacman: pacman -Ql | sed -n -e 's/.*\/bin\///p' | tail -n +2 pip: # Show details of a package tail: tail file tail -n N file tail -n +N file tail -c N file tail -f file
而已。在阅读完本文之后,您将能够了解–如何在Ubuntu上安装和使用命令行备忘单,我们将提供更多基于Linux的技巧和窍门。继续阅读!