Cheat : 一個(gè)實(shí)用Linux命令示例集合
我們中的許多人經(jīng)常查看 man 頁面 來了解命令開關(guān)(選項(xiàng)),它會(huì)顯示有關(guān)命令語法、說明、細(xì)節(jié)和可用的選項(xiàng),但它沒有任何實(shí)際的例子。因此,在組合成一個(gè)我們需要的完整命令時(shí)會(huì)遇到一些麻煩。
你確實(shí)遇到這個(gè)麻煩而想要一個(gè)更好的解決方案嗎?我會(huì)建議你試一下 cheat
。
Cheat 是什么
cheat 允許你在命令行中創(chuàng)建和查看交互式的速查表。它旨在幫助提醒 *nix 系統(tǒng)管理員他們經(jīng)常使用但還沒頻繁到會(huì)記住的命令的選項(xiàng)。
如何安裝 Cheat
cheat
是使用 python 開發(fā)的,所以可以用 pip
來在你的系統(tǒng)上安裝 cheat
。
pip
是一個(gè)與 setuptools
捆綁在一起的 Python 模塊,它是在 Linux 中安裝 Python 包推薦的工具之一。
對(duì)于 Debian/Ubuntu 用戶,請(qǐng)使用 apt-get 命令或apt 命令來安裝 pip
。
[對(duì)于 Python2]
$ sudo apt install python-pip python-setuptools
[對(duì)于 Python3]
$ sudo apt install python3-pip
RHEL/CentOS 官方倉庫中沒有 pip,因此使用 EPEL 倉庫,并使用 YUM 命令安裝 pip
。
$ sudo yum install python-pip python-devel python-setuptools
對(duì)于 Fedora 系統(tǒng),使用 dnf 命令來安裝 pip
。
[對(duì)于 Python2]
$ sudo dnf install python-pip
[對(duì)于 Python3]
$ sudo dnf install python3
對(duì)于基于 Arch Linux 的系統(tǒng),請(qǐng)使用 Pacman 命令 來安裝 pip
。
[對(duì)于 Python2]
$ sudo pacman -S python2-pip python-setuptools
[對(duì)于 Python3]
$ sudo pacman -S python-pip python3-setuptools
對(duì)于 openSUSE 系統(tǒng),使用 Zypper 命令來安裝 pip
。
[對(duì)于 Python2]
$ sudo pacman -S python-pip
[對(duì)于 Python3]
$ sudo pacman -S python3-pip
用 pip
來在你的系統(tǒng)上安裝 cheat
。
$ sudo pip install cheat
如何使用 Cheat
運(yùn)行 cheat
,然后按相應(yīng)的命令
來查看速查表,作為例子,我們要來看下 tar
命令的例子。
$ cheat tar
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .gz archive:
tar -ztvf /path/to/foo.tgz
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
# To extract a .tar in specified Directory:
tar -xvf /path/to/foo.tar -C /path/to/destination/
# To list the content of an .bz2 archive:
tar -jtvf /path/to/foo.tgz
# To create a .gz archive and exclude all jpg,gif,... from the tgz
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
運(yùn)行下面的命令查看可用的速查表。
$ cheat -l
進(jìn)入幫助頁面獲取更多詳細(xì)信息。
$ cheat -h