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
- # apt-get install Python (Debian-based system)
- # yum install Python (based on the small Red Hat system)
Install Pip
- # apt-get install python-pip (Debian-based system)
- # 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.
- # apt-get install git (Debian-based system)
- # yum install git (based on a small Red Hat system)
Next, install the required Python dependency package by running the following command.
- # pip install docopt pygments
Now, copy the Cheat git library
- # git clone https://github.com/chrisallenlane/cheat.git
Go to the Cheat directory and run 'setup.py' (a Python script).
- # cd cheat
- # Python setup. PY Install
If the installation is successful, you will be able to see the cheat version installed on the system.
- # Cheat -v
- 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:
- 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.
- # wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash
- # 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.
- 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.
- # 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.
- $ cheat -d
- /Home/avi/. Cheat
- /usr/local/Lib/python2. 7/Dist-packages/cheat/cheatsheets
Copy the built-in cheat sheet to your local directory.
- # 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"