cheat--gives Linux beginners and administrators an ultimate command line "cheat sheet"

Source: Internet
Author: User
Tags python script

Compiled from: http://www.tecmint.com/cheat-command-line-cheat-sheet-for-linux-users/ Avishek Kumar
Original: LCTT https://linux.cn/article-3760-1.html Translator: Su-kaiyao
A slight change in the original

What do you do when you're not sure what commands you're running, especially complex commands that use a lot of options? In this case, we use the man pages to get help. There are other options that may include commands suchas ' help ', 'whereis' and 'whatis'. But all of these have both advantages and disadvantages.

When we browse the man pages to see the options and help, the description is too lengthy and we can't understand it in a short time.

Linux Mans Pages

Linux Mans Pages

Likewise, the' help ' command may not give you the answers you expect.

Help Command

Help Command

The 'whereis' command hardly gives you any information except the location of the binaries (which may sometimes be important)

Whereis Command

Whereis Command

The 'whatis' command gives a very strict answer, and it doesn't help much except to say what the query command does. Moreover, it never describes the available options.

Whatis Command

Whatis Command

We have used all of the above options until we have solved the problem in a difficult situation, but now we have an interactive memo application 'cheat', which will stand out from the rest of the commands.

What is cheat?

Cheat is an interactive cheat sheet application that is distributed to Linux command line users under the GNU General Public License. It provides a display of Linux command use cases, including all of the options and short but understandable features of the command.

Cheat:provides Easy Command Options

Cheat: provides simple command options

Installing ' Cheat ' in a Linux system

'Cheat' has two main dependencies-'python' and 'pip', before installing 'Cheat', make sure your system has Python and Pip installed.

Install Python
    1. # apt-get install Python (Debian-based system)
    2. # yum install Python (based on the small Red Hat system)

Install Pip

    1. # apt-get install python-pip (Debian-based system)
    2. # yum install python-Pip (based on the small Red Hat system)

Note: Pip is a simple installation replacement and a Python third-party Package installer with great improvements.

If PIP is not successfully installed:

Need to install Epel-release first

Run

Yum Install Epel-release

Yum Install wget

For cent OS 7.x (X86*64)

RPM -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

For cent OS 6.x (X86*64)

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/ epel-release-6-8.noarch.rpm

For Cent OS 6.x (i386)

RPM -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

For Cent OS 5.x (X86*64)

RPM -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

For Cent OS 5.x (i386)

RPM -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Then install PIP

Yum Install -y python-pip

Download and install cheat

We will download ' Cheat ' via git and make sure you install the ' git ' package if it is not best to install it.

    1. # apt-get install git (Debian-based system)
    2. # yum install git (based on a small Red Hat system)

Next, install the required Python dependency package by running the following command.

    1. # pip install docopt pygments

Now, copy the Cheat git library

    1. # git clone https://github.com/chrisallenlane/cheat.git

Go to the Cheat directory and run 'setup.py' (a Python script).

    1. # cd cheat
    2. # Python setup. PY Install

If the installation is successful, you will be able to see the cheat version installed on the system.

    1. # Cheat -v
    2. Cheat 2.0. 9
Some necessary configurations of cheat

You must set the 'EDITOR' environment variable in the ' ~/.BASHRC ' file, open the user '. BASHRC' file, and add the following line to the inside:

    1. Export EDITOR = /usr/bin/nano

You can use your favorite editor instead of 'nano'. Save the file and then exit and log in again to make sure the changes take effect.

Next, add the cheat auto-completion feature to ensure that the command line is automatically complete under different interpreters. To get to this feature, simply clone the 'cheat.bash' script down and copy it to your system's correct path.

    1. # wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash
    2. # mv cheat. Bash /etc/bash_completion. D/

Note: The team has uploaded automatic completion scripts for other interpreters on Git, which can be cloned and used on different interpreters. Use the links below to find the automatic completion script for the remaining interpreters:

    • Auto completion Script for Various shells

Not only that, you can also use syntax highlighting if you need to. To do this, add the 'cheatcolors' environment variable in your '. BASHRC' file.

    1. Export Cheatcolor=true

The Cheat app provides only the most basic and commonly used commands by default. The contents of the cheat cheat sheet are saved in ~/.cheat/. Directory, we can manually add the contents of the cheat sheet in this directory, so that our cheat application will be more powerful.

    1. # Cheat -xyz

This will open the XYZ cheat sheet, and if not, create one. The cheat sheet will be opened using the default editor set in the . BASHRC , which is set by the default editor. BASHRC .

Use of some cheat commands

A package can be *.gz, *.bz2, *.zip, *.XZ, but what are the options?

Tar command options

Tar command options

I never use the dd command until I have consulted and checked in a different place, and before that, no matter how sure I am about the command. Now, things are going to be a lot easier.

DD Command Options

DD Command Options

'uname' command help

uname command Selection

uname command Options

A short ifconfig command Operation tutorial

Ifconfig command Options

Ifconfig command Options

The ' top ' command is one of the most important commands for administrators and ordinary users.

Top command Options

Top command Options

Let's cheat the cheat order, how (though it doesn't make sense)? Getting a list of available commands is actually a cheat memo installed on your system.

List all Linux commands

List all Linux Commands

Use keywords to search for cheat sheets.

Search Cheat Sheet

Search Cheat Sheet

Take a look at the built-in cheat sheets that contain all the commands.

    1. $ cheat -d
    2. /Home/avi/. Cheat
    3. /usr/local/Lib/python2. 7/Dist-packages/cheat/cheatsheets

Copy the built-in cheat sheet to your local directory.

    1. # CP/ usr/local/Lib/python2. 7/Dist-packages/cheat/cheatsheets/*/home/avi/.cheat/
Conclusion

This awesome tool in many cases serves as the "savior" role, giving you the information you need, information that is not redundant, not blurred, and, conversely, hitting the point. This is a tool that everyone will need, very simple to create, install, use and understand, the tool is promising.

This git repository has added a wonderful gag, and I'm not going to explain it here, but leave it to everyone to explain.

Linux Gag

Linux Gag

Well, the article is coming to an end, and I'm going to come back here with the next interesting article you like, so keep an eye on us all the time. Don't forget to leave us your valuable feedback in the comments section below.

cheat--gives Linux beginners and administrators an ultimate command line "cheat sheet"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.