Merge pull request #1462 from su-kaiyao/master

完成翻译 20140804 Cheat--An Ultimate Command Line 'Cheat-Sheet' for Linux Beginners and Administrators.md
This commit is contained in:
Xingyu.Wang 2014-08-07 19:19:21 +08:00
commit 740da5df0d
3 changed files with 178 additions and 176 deletions

View File

@ -1,175 +0,0 @@
[su-kaiyao]翻译中
Cheat An Ultimate Command Line Cheat-Sheet for Linux Beginners and Administrators
================================================================================
What you do when you are not sure of the command you are running especially in case of complex commands which uses a lot of options. We use man pages to get some help in such situation. Some of the other options may include commands like **help**, **whereis** and **whatis**. But all has their Pros and Cons.
While going through **man pages** for options and help, the description in man pages are too lengthy to understand specially in short span of time.
![Linux Man Pages](http://www.tecmint.com/wp-content/uploads/2014/07/Linux-Man-Pages.jpeg)
Linux Man Pages
Similarly, **help** command may not give you desired output.
![Help Command](http://www.tecmint.com/wp-content/uploads/2014/07/help-command.jpeg)
Help Command
A **whereis** command hardly tells anything other than the location of Installed Binaries (May be Important at time).
![Whereis Command](http://www.tecmint.com/wp-content/uploads/2014/07/whereis-command.jpeg)
Whereis Command
A **whatis** command gives strict and one liner answer which is not much helpful other than acknowledging the purpose of the command, Moreover it never says a single word about the available options.
![Whatis Command](http://www.tecmint.com/wp-content/uploads/2014/07/whatis-command.jpeg)
Whatis Command
We have used all these options till date to solve our issue in the dilemma but here comes an interactive cheat-sheet application **cheat** which is going to lead all the rest.
### What is cheat? ###
**Cheat** is an interactive cheat-sheet application released under GNU General Public License for Linux Command line users which serves the purpose of showing, use cases of a Linux command with all the options and their short yet understandable function.
![Cheat: Provides Easy Command Options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-sheet.jpeg)
Cheat: Provides Easy Command Options
### Installing Cheat in Linux Systems ###
**Cheat** has two major dependency **python** and **pip**. Make sure you have installed python and pip before installing **cheat** on the system.
#### Install Python ####
# apt-get install Python (On Debian based Systems)
# yum install python (On RedHat based Systems)
Install Pip
# apt-get install python-pip (On Debian based Systems)
# yum install python-pip (On RedHat based Systems)
**NOTE**: pip is an easy install replacement and is intended to be an improved Python package installer.
### Download and Install Cheat ###
We will be downloading cheat from Git. Make sure you have package git installed, if not better install this first.
# apt-get install git (On Debian based Systems)
# yum install git (On RedHat based Systems)
Next, install the required python dependencies by running following command.
# pip install docopt pygments
Now, clone the [Git repository][1] of cheat.
# git clone https://github.com/chrisallenlane/cheat.git
Move to the cheat directory and run **setup.py** (a python script).
# cd cheat
# python setup.py install
If installation goes smoothly, you should be able to see a cheat version installed on the system.
# cheat -v
cheat 2.0.9
### Required Configuration for Cheat ###
You must have an **EDITOR** environment variable set in ~/.bashrc file. Open the user **.bashrc** file and add the following line to it.
export EDITOR =/usr/bin/nano
You can use your favourite editor here in place of **nano**. Save the file and logout. Again Login to make the changes taken into effect.
Next, add the cheat autocompletion feature to enable command-line autocompletion for different shells. To enable autocompletion, simply clone the **cheat.bash** script and copy the script to the appropriate path in your system.
# wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash
# mv cheat.bash /etc/bash_completion.d/
**NOTE**: The team has uploaded other shells auto completion scrip to Git, which may be cloned and used in case of respective Shell. Use the following link for other shells auto completion script.
- [Auto Completion Script for Various Shells][2]
Optionally, you can also enable syntax highlighting, if desired. To active syntax highlighting feature, add a **CHEATCOLORS** environment variable in your **.bashrc** file.
export CHEATCOLORS=true
The Cheat application default program only serves the basic and most used commands. The content of cheat-sheet resides at location **~/.cheat/.** Manual Cheatsheets can be added to this location to make the application rich.
# cheat -e xyz
This will open xyz cheat-sheet if available. If not it will create one. The cheat-sheet will be opened in the default **EDITOR**, we set in **.bashrc** in the configuration stage, above.
### Usage of Cheat with Some Commands ###
A tarball may be *.gz or *.bz2 or *.zip or *.xz. So, what option to be used where?
![tar command options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-tar.jpeg)
tar command options
I never run **dd** command, no matter how much sure I am about the command before consulting and cross checking it at more than one location. The things seems to be easy now.
![dd command options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-dd.jpeg)
dd command options
A **uname** command help.
![uname command options](http://www.tecmint.com/wp-content/uploads/2014/07/uname-command.jpeg)
uname command options
A short **ifconfig** command line tutorial, in action.
![ifconfig command options](http://www.tecmint.com/wp-content/uploads/2014/07/ifconfig-command.jpeg)
ifconfig command options
A top command, one of the most important command for Admin and Normal User.
![top command options](http://www.tecmint.com/wp-content/uploads/2014/07/top-command.jpeg)
top command options
How about Cheating the cheat command (though the other sense)? Get a list of available commands, the cheat-sheet of which is installed in the System.
![List All Linux Commands](http://www.tecmint.com/wp-content/uploads/2014/07/linux-commands.jpeg)
List All Linux Commands
Search Cheat-sheet with specific keyword.
![Search Cheat Sheet](http://www.tecmint.com/wp-content/uploads/2014/07/search-cheat-sheet.jpeg)
Search Cheat Sheet
See the location of built-in cheat-sheets for all the commands.
$ cheat -d
/home/avi/.cheat
/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets
Copy the in-built cheat-sheet to your native directory.
# cp /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/* /home/avi/.cheat/
### Conclusion ###
This wonderful project is a life Saviour in many-a-situation. It just gives you information that is required, nothing extra, nothing vague and to the point. This is a must tool for everyone. Easy to build, easy to install, easy to run and easy to understand, this project seems promising.
This Git project has added a wonderful **gag** which I am not going to explain but leave on you to interpret.
![Linux Gag](http://www.tecmint.com/wp-content/uploads/2014/07/linux-gag.jpeg)
Linux Gag
Thats all for now. Ill be here again with another interesting article you people will love to read. Till then stay tuned and connected to Tecmint. Dont forget to provide us with your valuable feedback in the comment section below.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/cheat-command-line-cheat-sheet-for-linux-users/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/install-git-to-create-and-share-your-own-projects-on-github-repository/
[2]:https://github.com/chrisallenlane/cheat/tree/master/cheat/autocompletion

View File

@ -1,3 +1,5 @@
[su-kaiyao]翻译中
Command Line Tuesdays Part Seven
================================================================================
Heya geekos. Ive checked the curriculum, and were at part 7 of 8 as of today. Which means there will be one more and sadly final CLT next tuesday. So for today, lets deal with some **permissions**!
@ -79,4 +81,4 @@ via: https://news.opensuse.org/2014/08/05/command-line-tuesdays-part-seven/
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:https://news.opensuse.org/author/holden87/
[1]:https://news.opensuse.org/2014/07/01/command-line-tuesdays-part-three/
[1]:https://news.opensuse.org/2014/07/01/command-line-tuesdays-part-three/

View File

@ -0,0 +1,175 @@
Cheat - 一个给Linux初学者和管理员的终极命令行备忘单
==============================================================================================
当你不确定你所运行的命令尤其是那些使用了许多选项的复杂命令的时候你怎么做在这种情况下我们使用man pages来获取帮助。还有一些其它的选择可能包括像**help****whereis**’和‘**whatis**’这样的命令。但是所有的这些既有优点,也有缺点
当我们浏览**man pages**来查看选项和帮助的时候man pages里面的描述实在太冗长了我们无法在很短的时间里理解它的意思
![Linux Man Pages](http://www.tecmint.com/wp-content/uploads/2014/07/Linux-Man-Pages.jpeg)
Linux Man Pages
同样,‘**help**’命令可能不会给你想要的答案
![Help Command](http://www.tecmint.com/wp-content/uploads/2014/07/help-command.jpeg)
Help Command
**whereis**’命令几乎不给你任何信息,除了安装的二进制文件的位置(有些时候可能非常重要)
![Whereis Command](http://www.tecmint.com/wp-content/uploads/2014/07/whereis-command.jpeg)
Whereis Command
**whatis**’命令给出一套很严格的答案---仅仅说出了所查询命令的作用,但,它并没有什么太大帮助。而且, 它从来不提及所查询命令所拥有的选项
![Whatis Command](http://www.tecmint.com/wp-content/uploads/2014/07/whatis-command.jpeg)
Whatis Command
我们使用这些选项直到在困境中解决问题,但是现在来了一个交互式的备忘录应用程序‘**cheat**’,它将带领其余的命令查询命令
### 什么是cheat? ###
**cheat**是在GNU通用公共许可证下为Linux命令行使用者发行的交互式备忘单应用程序。它提供显示Linux命令使用案例包括该命令所有的选项和简短但尚可理解的功能介绍
![Cheat: Provides Easy Command Options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-sheet.jpeg)
Cheat提供简单命令选项
### 在Linux系统中安装Cheat ###
**Cheat**’有两个主要的依赖 - **python****pip**’,在安装‘**cheat**之前确保你的系统安装了python和pip
### Install Python ###
# apt-get install Python (基于Debian的系统)
# yum install python (基于小红帽的系统)
Install Pip
# apt-get install python-pip (基于Debian的系统)
# yum install python-pip (基于小红帽的系统)
**Note**pip是一个简单的安装替代是一个有极大改进的Python第三方包安装器
### 下载并安装Cheat ###
我们将通过Git下载Cheat确保你安装了git如果没有最好安装下
# apt-get install git (基于Debian的系统)
# yum install git (基于小红帽的系统)
接下来通过运行下面的命令来安装所需要的python依赖包
# pip install docopt pygments
现在clone cheat的[Git repository][1]
# git clone https://github.com/chrisallenlane/cheat.git
进入cheat目录运行**setup.py**一个python脚本
# cd cheat
# python setup.py install
如果安装很顺利你就能够看到安装在系统上的cheat版本了
# cheat -v
cheat 2.0.9
### cheat的一些必要配置 ###
你必须在‘~/.bashrc文件里设置**EDITOR**’环境变量,打开用户‘**.bashrc**’文件,然后把下面这行加入到里面:
export EDITOR = /usr/bin/nano
你可以使用你喜欢的编辑器来替代‘**nano**’。保存文件然后退出,再次登录以确保修改生效
接下来添加cheat的自动补全特性来确保不同解释器下命令行的自动补全。为了到达该功能要求简单地将**cheat.bash**脚本clone下来然后复制到你系统正确的路径下
# wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash
# mv cheat.bash /etc/bash_completion.d/
**NOTE**团队已经在Git上上传了其他解释器的自动补全脚本这些都可以被克隆然后用在不同的解释器上。使用下面的链接以找到其余解释器的自动补全脚本
- [Auto Completion Script for Various Shells][2]
不仅如此,如果需要的话,你也可以使用语法高亮。要想达到次功能,在你的‘**.bashrc**’文件中添加‘**CHEATCOLORS**’环境变量
export CHEATCOLOR=true
Cheat应用默认只提供最基本和最常用的命令。cheat备忘单的内容保存在**~/.cheat/.**目录里我们可以手动在这个目录添加备忘单里面的内容这样我们的cheat应用将更强大
# cheat -xyz
这将打开xyz备忘单如果没有的话就会创建一个。备忘单将使用**.bashrc**里设置的默认**编辑器**打开,默认编辑器就是上面内容所提及到的
### 一些Cheat命令的使用 ###
一个包可以是 *.gz , *.bz2 , *.zip , *.xz可是什么情况下用哪些选项呢
![tar command options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-tar.jpeg)
tar命令选项
除非在不同的地方咨询和核对后,我才使用**dd**命令,在此之前,无论我对这个命令多么的确定,我从不使用它。现在,事情就变得简单多了
![dd command options](http://www.tecmint.com/wp-content/uploads/2014/07/cheat-dd.jpeg)
dd命令选项
**uname**’命令帮助
![uname command options](http://www.tecmint.com/wp-content/uploads/2014/07/uname-command.jpeg)
uname命令选择
一个简短的**ifconfig**命令操作教程
![ifconfig command options](http://www.tecmint.com/wp-content/uploads/2014/07/ifconfig-command.jpeg)
ifconfig命令选项
top命令一个对管理员和正常用户来说最重要的命令之一
![top command options](http://www.tecmint.com/wp-content/uploads/2014/07/top-command.jpeg)
top命令选项
我们来骗骗cheat命令如何尽管别有意义得到可用命令的的列表其实就是安装在你系统里的cheat备忘录
![List All Linux Commands](http://www.tecmint.com/wp-content/uploads/2014/07/linux-commands.jpeg)
列出所有Linux命令
使用关键字搜索备忘单
![Search Cheat Sheet](http://www.tecmint.com/wp-content/uploads/2014/07/search-cheat-sheet.jpeg)
搜索备忘单
来看看包含所有命令的内置备忘单
$ cheat -d
/home/avi/.cheat
/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets
复制内置的备忘单到你的本地目录
# cp /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/* /home/avi/.cheat/
### 结论 ###
这个有趣的工程在许多情况下担任救世主的角色,它给予你需要的信息,信息不冗余,不模糊,相反地,却击中要点。这是每个人都会需要的工具,很简单就能创建,安装,使用和理解,这个项目前途无量
这个Git仓库已经添加了一个精彩的**gag**,这里我不打算去解释它,而留给你去解释
![Linux Gag](http://www.tecmint.com/wp-content/uploads/2014/07/linux-gag.jpeg)
Linux Gag
好了文章就要结束了我会带着下一个你们爱读的有趣文章回到这里的在此之前时刻关注Tecmint。别忘了在下面的评论部分给我们提供你们有价值的反馈
-------------------------------------------------------------------------------------------------------------------------------
via: http://www.tecmint.com/cheat-command-line-cheat-sheet-for-linux-users/
作者:[Avishek Kumar][a]
译者:[su-kaiyao](https://github.com/su-kaiyao)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/install-git-to-create-and-share-your-own-projects-on-github-repository/
[2]:https://github.com/chrisallenlane/cheat/tree/master/cheat/autocompletion