cheat là công cụ dòng lệnh dựa trên Python, cho phép sysadmin xem và lưu cheat sheet (mẹo tắt) cho các lệnh. Hiển thị ví dụ văn bản đơn giản của lệnh - nhắc nhở options, arguments, use case phổ biến. Dành cho "lệnh dùng thường nhưng không đủ để nhớ".
Cài đặt
# Cập nhật hệ thống sudo apt update && sudo apt upgrade # Cài pip sudo apt install python3-pip # Cài cheat pip3 install cheat # Kiểm tra cheat --version # cheat 2.1.24+
Cấu hình trình soạn thảo
# Tạm thời export EDITOR=/usr/bin/vim # Vĩnh viễn - thêm vào ~/.bashrc hoặc ~/.zshrc echo 'export EDITOR=/usr/bin/vim' >> ~/.bashrc source ~/.bashrc
Sử dụng cơ bản
$ 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 wait for file to grow tail -f file
Các lệnh hữu ích
| Lệnh | Chức năng |
|---|---|
cheat <command> | Xem cheat sheet cho lệnh |
cheat -l | Liệt kê tất cả cheat sheet có sẵn |
cheat -e <name> | Tạo/sửa cheat sheet tùy chỉnh |
cheat -s <keyword> | Tìm kiếm trong cheat sheet |
cheat -d <name> | Xóa cheat sheet tùy chỉnh |
Ví dụ tìm kiếm
$ cheat -s tail tail: tail file, tail -n N file, tail -n +N file, tail -c N file, tail -f file asterisk: # tail -f /var/log/asterisk/messages journalctl: # Actively follow log (like tail -f)
Tạo cheat sheet riêng
$ cheat -e my_git # Mở editor, thêm nội dung: # git log --oneline --graph --all # git commit --amend --no-edit # Lưu và thoát editor