Linux下更好用的帮助命令—cheat

2024-01-26 14:18
文章标签 linux 命令 帮助 更好 cheat

本文主要是介绍Linux下更好用的帮助命令—cheat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

來自與這個地址

点击打开链接


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

Linux Man Pages

Similarly, ‘help‘ command may not give you desired output.

Linux help command

Help Command

A ‘whereis‘ command hardly tells anything other than the location of Installed Binaries (May be Important at time).

Linux Whereis Command

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.

Linux Whatis Command

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.

Install Cheat in Linux

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 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 shell’s auto completion scrip to Git, which may be cloned and used in case of respective Shell. Use the following link for other shell’s auto completion script.

  1. Auto Completion Script for Various Shells

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?

Linux Tar Command

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.

Linux dd Command

dd command options

A ‘uname‘ command help.

Linux uname Command

uname command options

A short ifconfig command line tutorial, in action.

Linux ifconfig Command

ifconfig command options

A ‘top‘ command, one of the most important command for Admin and Normal User.

Linux top Command

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

List All Linux Commands

Search Cheat-sheet with specific keyword.

Search Cheat Sheet

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

Linux Gag

That’s all for now. I’ll be here again with another interesting article you people will love to read. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in the comment section below.


这篇关于Linux下更好用的帮助命令—cheat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/647063

相关文章

Linux换行符的使用方法详解

《Linux换行符的使用方法详解》本文介绍了Linux中常用的换行符LF及其在文件中的表示,展示了如何使用sed命令替换换行符,并列举了与换行符处理相关的Linux命令,通过代码讲解的非常详细,需要的... 目录简介检测文件中的换行符使用 cat -A 查看换行符使用 od -c 检查字符换行符格式转换将

Linux系统配置NAT网络模式的详细步骤(附图文)

《Linux系统配置NAT网络模式的详细步骤(附图文)》本文详细指导如何在VMware环境下配置NAT网络模式,包括设置主机和虚拟机的IP地址、网关,以及针对Linux和Windows系统的具体步骤,... 目录一、配置NAT网络模式二、设置虚拟机交换机网关2.1 打开虚拟机2.2 管理员授权2.3 设置子

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Linux samba共享慢的原因及解决方案

《Linuxsamba共享慢的原因及解决方案》:本文主要介绍Linuxsamba共享慢的原因及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux samba共享慢原因及解决问题表现原因解决办法总结Linandroidux samba共享慢原因及解决

新特性抢先看! Ubuntu 25.04 Beta 发布:Linux 6.14 内核

《新特性抢先看!Ubuntu25.04Beta发布:Linux6.14内核》Canonical公司近日发布了Ubuntu25.04Beta版,这一版本被赋予了一个活泼的代号——“Plu... Canonical 昨日(3 月 27 日)放出了 Beta 版 Ubuntu 25.04 系统镜像,代号“Pluc

Linux安装MySQL的教程

《Linux安装MySQL的教程》:本文主要介绍Linux安装MySQL的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux安装mysql1.Mysql官网2.我的存放路径3.解压mysql文件到当前目录4.重命名一下5.创建mysql用户组和用户并修

Linux上设置Ollama服务配置(常用环境变量)

《Linux上设置Ollama服务配置(常用环境变量)》本文主要介绍了Linux上设置Ollama服务配置(常用环境变量),Ollama提供了多种环境变量供配置,如调试模式、模型目录等,下面就来介绍一... 目录在 linux 上设置环境变量配置 OllamPOgxSRJfa手动安装安装特定版本查看日志在

Linux系统之主机网络配置方式

《Linux系统之主机网络配置方式》:本文主要介绍Linux系统之主机网络配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、查看主机的网络参数1、查看主机名2、查看IP地址3、查看网关4、查看DNS二、配置网卡1、修改网卡配置文件2、nmcli工具【通用

Linux系统之dns域名解析全过程

《Linux系统之dns域名解析全过程》:本文主要介绍Linux系统之dns域名解析全过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、dns域名解析介绍1、DNS核心概念1.1 区域 zone1.2 记录 record二、DNS服务的配置1、正向解析的配置