Cheat एक कमांड लाइन है जो मुख्य रूप से पायथन सॉफ्टवेयर पर आधारित है जो सिस्टम एडमिनिस्ट्रेटर्स को उपयोगी चीट शीट्स देखने और सेव करने की अनुमति देता है। यह एक प्रतिनिधि कमांड के सरल-टेक्स्ट उदाहरणों को पुनर्प्राप्त करता है जो उपयोगकर्ता को विकल्पों, आर्ग्यूमेंट्स, या सामान्य उपयोगों की याद दिलाएगा। Cheat का उपयोग "उन कमांड्स के लिए किया जाता है जिनका आप अक्सर उपयोग करते हैं, लेकिन उन्हें याद रखने के लिए पर्याप्त नहीं"।
Cheat इंस्टॉल करना
Cheat इंस्टॉल करने से पहले, हमें यह सुनिश्चित करना होगा कि सिस्टम पर सब कुछ अप-टू-डेट है जैसा कि नीचे दिए गए कमांड में दिखाया गया है:
$ sudo apt-get update && sudo apt-get upgrade
Cheat इंस्टॉल करना पायथन पैकेज मैनेजर Pip के साथ सबसे अच्छा किया जाता है। Pip इंस्टॉल करने के लिए, निम्न कमांड का उपयोग करें:
$ sudo apt-get install python-pip
Cheat इंस्टॉल करने के लिए, निम्न कमांड का उपयोग करें:
$ sudo pip install cheat
सैंपल आउटपुट इस तरह होना चाहिए:
Collecting cheat Downloading cheat-2.1.24.tar.gz (42kB) 100% |████████████████████████████████| 51kB 89kB/s Collecting docopt>=0.6.1 (from cheat) Downloading docopt-0.6.2.tar.gz Collecting pygments>=1.6.0 (from cheat) Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB) 100% |████████████████████████████████| 757kB 892kB/s Installing collected packages: docopt, pygments, cheat Running setup.py install for docopt ... done Running setup.py install for cheat ... done Successfully installed cheat-2.1.24 docopt-0.6.2 pygments-2.1.3
यह वेरिफाई करने के लिए कि cheat इंस्टॉल है या नहीं, निम्न कमांड का उपयोग करें:
$ cheat -v
सैंपल आउटपुट इस तरह होना चाहिए:
cheat 2.1.24
टेक्स्ट एडिटर सेट करना
हम अपने स्वयं के चीट शीट्स बनाने के लिए आगे बढ़ सकते हैं, Cheat को यह जानने की जरूरत है कि हम डिफ़ॉल्ट रूप से शीट्स को एडिट करने के लिए किस टेक्स्ट एडिटर का उपयोग करना चाहेंगे। नैनो टेक्स्ट एडिटर सेट करने के लिए, निम्न कमांड का उपयोग करें:
$ export EDITOR=/usr/bin/vim
हम उपरोक्त कमांड सफल रहा या नहीं, इसकी पुष्टि निम्न कमांड का उपयोग करके कर सकते हैं:
$ printenv EDITOR
आउटपुट इस तरह होना चाहिए:
/usr/bin/vim
इस परिवर्तन को स्थायी बनाने और सभी भविष्य के शेल सेशन्स में स्थायी रखने के लिए, आपको एनवायरनमेंट वेरिएबल डिक्लेरेशन को अपनी .bashrc फाइल में जोड़ना होगा। यह कई फाइलों में से एक है जो बैश शेल सेशन की शुरुआत में चलती हैं। Bashrc फाइल खोलने के लिए, निम्न कमांड का उपयोग करें:
$ nano ~/.bashrc
सैंपल आउटपुट इस तरह होना चाहिए:
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac export EDITOR=/usr/bin/vim # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000
फिर उसी एक्सपोर्ट कमांड को नीचे दिखाए अनुसार जोड़ें:
..................................................... # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac export EDITOR=/usr/bin/vim # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth ...........................................
फाइल को सेव करें और बाहर निकलें।
Cheat चलाना
tail कमांड के लिए अपने सबसे बेसिक रूप में Cheat चलाने के लिए, निम्न कमांड का उपयोग करें:
$ cheat tail
सैंपल आउटपुट इस तरह होना चाहिए:
# To show the last 10 lines of file tail file # To show the last N lines of file tail -n N file # To show the last lines of file starting with the Nth tail -n +N file # To show the last N bytes of file tail -c N file # To show the last 10 lines of file and to wait for file to grow tail -f file
सभी मौजूदा चीट्स की सूची देखने के लिए, निम्न कमांड का उपयोग करें:
$ cheat -l
आउटपुट इस तरह होना चाहिए:
7z /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/7z ab /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ab apk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apk apparmor /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apparmor apt /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt apt-cache /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-cache apt-get /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-get aptitude /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/aptitude asciiart /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asciiart asterisk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asterisk at /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/at awk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/awk bash /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bash bower /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bower chmod /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chmod chown /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chown convert /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/convert crontab /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/crontab csplit /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/csplit cups /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cups curl /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/curl cut /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cut date /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/date dd /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dd df /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/df dhclient /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dhclient ..............................................................................................
चीट शीट्स बनाना और एडिट करना
चीट शीट बनाने के लिए, निम्न कमांड का उपयोग करें:
$ cheat -e tutorialspoint
उपरोक्त कमांड tutorialspoint एक चीट शीट नाम है। यह एक खाली चीट शीट खोलेगा। अब अपने चीट्स जोड़ें और सेव करें।
चीट शीट्स खोजना
चीट शीट खोजने के लिए, निम्न कमांड का उपयोग करें:
$ cheat -s tail
उपरोक्त कमांड tail कमांड के लिए खोज रहा है। सैंपल आउटपुट इस तरह होना चाहिए:
asterisk: # To print out the details of SIP accounts:
dnf: # To search package details for the given string
dpkg: # List all installed packages with versions and details
hardware-info: # Display all hardware details
journalctl: # Actively follow log (like tail -f)
mdadm: # See detailed array confiration/status
mdadm --detail /dev/md${M}
mdadm --detail --scan > /etc/mdadm/mdadm.conf
p4: # Print details related to Client and server configuration
pacman: pacman -Ql | sed -n -e 's/.*\/bin\///p' | tail -n +2
pip: # Show details of a package
tail: tail file
tail -n N file
tail -n +N file
tail -c N file
tail -f file
बस इतना ही। इस लेख के बाद, आप समझ पाएंगे - "उबंटू पर कमांड लाइन चीट शीट्स कैसे इंस्टॉल और उपयोग करें", हम अधिक लिनक्स-आधारित ट्रिक्स और टिप्स के साथ आएंगे। पढ़ते रहें!