Linux命令行实用助记工具


在segmentfault上看到一篇名为“[极客工具]cheat-linux命令行实用助记工具”的文章,比较感兴趣,然后自己实际安装试了试,感觉还行,在这里推荐一下:

相关说明

虽然Linux下的命令基本上都可以在man/help中找到详细用法,但不得不说——不够直观,我就是想用这个命令解决这个问题,你跟我说一堆背景知识有毛用,我就是想要个示例,改改然后用到我自己的命令/脚本中来,在这方面cheat就可比man/help要好用多了。按照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.(cheat命令允许你在命令行中查看or创建交互式的使用手册、实例,目的是用来帮助Linux系统的管理员操作那些他们常会用到但没有熟悉到随手就来的命令)”,反正确实还是能够起到一些作用的,以后就不用非得Google/Baidu去找示例了。

安装方法
1.使用pip

sudo pip install cheat

2.使用homebrew

sudo brew install cheat

3.手动安装

先安装依赖:sudo pip install docopt pygments

然后:git clone https://github.com/chrisallenlane/cheat.git && cd cheat && sudo python setup.py install

使用示例
1.查看tar命令的使用方法

cheat tar

2.查看都有哪些命令的示例

cheat -l

3.搜索是否存在某个命令的使用帮助

cheat -s awk

4.个性化定制

cheat -e xxoo    #这里xxoo可以是你自己定义的命令别名,然后编辑它的使用示例、帮助

root@debian:~# cheat --help
cheat

Usage:
  cheat <cheatsheet>
  cheat -e <cheatsheet>
  cheat -s <keyword>
  cheat -l
  cheat -d
  cheat -v

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.

Examples:
  To look up 'tar':
  cheat tar

  To create or edit the cheatsheet for 'foo':
  cheat -e foo

Options:
  -d --directories  List directories on CHEATPATH
  -e --edit         Edit cheatsheet
  -l --list         List cheatsheets
  -s --search       Search cheatsheets for <keyword>
  -v --version      Print the version number
root@debian:~#
root@debian:~# 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-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
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
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
diff           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/diff
distcc         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/distcc
emacs          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/emacs
find           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/find
gcc            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/gcc
gdb            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/gdb
git            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/git
gpg            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/gpg
grep           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/grep
gs             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/gs
head           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/head
history        /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/history
ifconfig       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ifconfig
indent         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/indent
ip             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ip
iptables       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/iptables
irssi          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/irssi
iwconfig       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/iwconfig
journalctl     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/journalctl
less           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/less
ln             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ln
ls             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ls
lsof           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/lsof
markdown       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/markdown
mkdir          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/mkdir
mount          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/mount
mysql          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/mysql
mysqldump      /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/mysqldump
ncat           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ncat
netstat        /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/netstat
nmap           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/nmap
notify-send    /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/notify-send
od             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/od
openssl        /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/openssl
pacman         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/pacman
pdftk          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/pdftk
php            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/php
ps             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ps
python         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/python
rm             /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/rm
rsync          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/rsync
sam2p          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/sam2p
scp            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/scp
screen         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/screen
sed            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/sed
shred          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/shred
sockstat       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/sockstat
sort           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/sort
split          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/split
sqlmap         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/sqlmap
ssh            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ssh
ssh-copy-id    /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ssh-copy-id
ssh-keygen     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ssh-keygen
stdout         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/stdout
strace         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/strace
systemctl      /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/systemctl
tail           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/tail
tar            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/tar
tcpdump        /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/tcpdump
tee            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/tee
tmux           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/tmux
top            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/top
truncate       /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/truncate
uname          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/uname
vim            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/vim
wget           /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/wget
xargs          /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/xargs
yaourt         /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/yaourt
youtube-dl     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/youtube-dl
yum            /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/yum

root@debian:~# cheat -d
/root/.cheat
/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets
root@debian:~#
root@debian:~# cheat -s awk
awk:
  printf '1n2n3n' | awk '{ sum += $1} END {print sum}'

find:
  find / -type f -size +20000k -exec ls -lh {} ; | awk '{ print $9 ": " $5 }'

history:
  history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

netstat:
  netstat -pln | grep <port> | awk '{print $NF}'

openssl:
  awk '/-----BEGIN/,/END CERTIFICATE-----/' | 
相关项目
  • lucaswerkmeister/cheats: An implementation of this concept in pure bash that also allows not only for numerical indexing of subcomands but also supports running commands interactively.
  • jahendrie/cheat: A bash-only implementation that additionally allows for cheatsheets to be created and grep searched from the command-line. (jahendrie contributed key ideas to this project as well.)
  • cheat RubyGem: A clever gem from 2006 that clearly had similar motivations. It is unclear whether or not it is currently maintained.
  • tldr: “Simplified and community-driven man pages”.

 

明天就65周年国庆了,虽说不上班,但是,想想也都知道人山人海的场面会有多壮观,就不出去凑这个热闹了,宅着吧(还不是因为没钱,没法去好地方玩,哎,说多了都是泪啊::>_<:: )

,

《“Linux命令行实用助记工具”》 有 1 条评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注