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镜像文件制作的过程,包括确定磁盘空间布局、制作空白镜像文件、分区与格式化、复制引导分区和其他分区... 目录1.确定磁盘空间布局2.制作空白镜像文件3.分区与格式化1) 分区2) 格式化4.复制引导分区5.复制其它分区1) 挂载2) 复制bootfs分区3)

Redis 命令详解与实战案例

《Redis命令详解与实战案例》本文详细介绍了Redis的基础知识、核心数据结构与命令、高级功能与命令、最佳实践与性能优化,以及实战应用场景,通过实战案例,展示了如何使用Redis构建高性能应用系统... 目录Redis 命令详解与实战案例一、Redis 基础介绍二、Redis 核心数据结构与命令1. 字符

Linux服务器数据盘移除并重新挂载的全过程

《Linux服务器数据盘移除并重新挂载的全过程》:本文主要介绍在Linux服务器上移除并重新挂载数据盘的整个过程,分为三大步:卸载文件系统、分离磁盘和重新挂载,每一步都有详细的步骤和注意事项,确保... 目录引言第一步:卸载文件系统第二步:分离磁盘第三步:重新挂载引言在 linux 服务器上移除并重新挂p

Linux下屏幕亮度的调节方式

《Linux下屏幕亮度的调节方式》文章介绍了Linux下屏幕亮度调节的几种方法,包括图形界面、手动调节(使用ACPI内核模块)和外接显示屏调节,以及自动调节软件(CaliseRedshift和Reds... 目录1 概述2 手动调节http://www.chinasem.cn2.1 手动屏幕调节2.2 外接显

Linux(centos7)虚拟机没有IP问题及解决方案

《Linux(centos7)虚拟机没有IP问题及解决方案》文章介绍了在CentOS7中配置虚拟机网络并使用Xshell连接虚拟机的步骤,首先,检查并配置网卡ens33的ONBOOT属性为yes,然后... 目录输入查看ZFhrxIP命令:ip addr查看,没有虚拟机IP修改ens33配置文件重启网络Xh

linux实现对.jar文件的配置文件进行修改

《linux实现对.jar文件的配置文件进行修改》文章讲述了如何使用Linux系统修改.jar文件的配置文件,包括进入文件夹、编辑文件、保存并退出编辑器,以及重新启动项目... 目录linux对.jar文件的配置文件进行修改第一步第二步 第三步第四步总结linux对.jar文件的配置文件进行修改第一步进

交换机救命命令手册! 思科交换机排障命令汇总指南

《交换机救命命令手册!思科交换机排障命令汇总指南》在交换机配置与故障排查过程中,总会遇到那些“关键时刻靠得住的命令”,今天我们就来分享一份思科双实战命令手册... 目录1. 基础系统诊断2. 接口与链路诊断3. L2切换排障4. L3路由与转发5. 高级调试与日志6. 性能与QoS7. 安全与DHCP8.

故障定位快人一步! 华为交换机排障命令汇总

《故障定位快人一步!华为交换机排障命令汇总》在使用华为交换机进行故障排查时,首先需要了解交换机的当前状态,通过执行基础命令,可以迅速获取到交换机的系统信息、接口状态以及配置情况等关键数据,为后续的故... 目录基础系统诊断接口与链路诊断L2切换排障L3路由与转发高级调试与日志性能、安全与扩展IT人无数次实战

linux ssh如何实现增加访问端口

《linuxssh如何实现增加访问端口》Linux中SSH默认使用22端口,为了增强安全性或满足特定需求,可以通过修改SSH配置来增加或更改SSH访问端口,具体步骤包括修改SSH配置文件、增加或修改... 目录1. 修改 SSH 配置文件2. 增加或修改端口3. 保存并退出编辑器4. 更新防火墙规则使用uf

Linux join命令的使用及说明

《Linuxjoin命令的使用及说明》`join`命令用于在Linux中按字段将两个文件进行连接,类似于SQL的JOIN,它需要两个文件按用于匹配的字段排序,并且第一个文件的换行符必须是LF,`jo... 目录一. 基本语法二. 数据准备三. 指定文件的连接key四.-a输出指定文件的所有行五.-o指定输出