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-基础知识3

打包和压缩 zip 安装zip软件包 yum -y install zip unzip 压缩打包命令: zip -q -r -d -u 压缩包文件名 目录和文件名列表 -q:不显示命令执行过程-r:递归处理,打包各级子目录和文件-u:把文件增加/替换到压缩包中-d:从压缩包中删除指定的文件 解压:unzip 压缩包名 打包文件 把压缩包从服务器下载到本地 把压缩包上传到服务器(zip

Linux 网络编程 --- 应用层

一、自定义协议和序列化反序列化 代码: 序列化反序列化实现网络版本计算器 二、HTTP协议 1、谈两个简单的预备知识 https://www.baidu.com/ --- 域名 --- 域名解析 --- IP地址 http的端口号为80端口,https的端口号为443 url为统一资源定位符。CSDNhttps://mp.csdn.net/mp_blog/creation/editor

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]

30常用 Maven 命令

Maven 是一个强大的项目管理和构建工具,它广泛用于 Java 项目的依赖管理、构建流程和插件集成。Maven 的命令行工具提供了大量的命令来帮助开发人员管理项目的生命周期、依赖和插件。以下是 常用 Maven 命令的使用场景及其详细解释。 1. mvn clean 使用场景:清理项目的生成目录,通常用于删除项目中自动生成的文件(如 target/ 目录)。共性规律:清理操作

Linux_kernel驱动开发11

一、改回nfs方式挂载根文件系统         在产品将要上线之前,需要制作不同类型格式的根文件系统         在产品研发阶段,我们还是需要使用nfs的方式挂载根文件系统         优点:可以直接在上位机中修改文件系统内容,延长EMMC的寿命         【1】重启上位机nfs服务         sudo service nfs-kernel-server resta

【Linux 从基础到进阶】Ansible自动化运维工具使用

Ansible自动化运维工具使用 Ansible 是一款开源的自动化运维工具,采用无代理架构(agentless),基于 SSH 连接进行管理,具有简单易用、灵活强大、可扩展性高等特点。它广泛用于服务器管理、应用部署、配置管理等任务。本文将介绍 Ansible 的安装、基本使用方法及一些实际运维场景中的应用,旨在帮助运维人员快速上手并熟练运用 Ansible。 1. Ansible的核心概念

Linux服务器Java启动脚本

Linux服务器Java启动脚本 1、初版2、优化版本3、常用脚本仓库 本文章介绍了如何在Linux服务器上执行Java并启动jar包, 通常我们会使用nohup直接启动,但是还是需要手动停止然后再次启动, 那如何更优雅的在服务器上启动jar包呢,让我们一起探讨一下吧。 1、初版 第一个版本是常用的做法,直接使用nohup后台启动jar包, 并将日志输出到当前文件夹n

[Linux]:进程(下)

✨✨ 欢迎大家来到贝蒂大讲堂✨✨ 🎈🎈养成好习惯,先赞后看哦~🎈🎈 所属专栏:Linux学习 贝蒂的主页:Betty’s blog 1. 进程终止 1.1 进程退出的场景 进程退出只有以下三种情况: 代码运行完毕,结果正确。代码运行完毕,结果不正确。代码异常终止(进程崩溃)。 1.2 进程退出码 在编程中,我们通常认为main函数是代码的入口,但实际上它只是用户级