Linux中國
命令行樂趣:嘲諷輸錯 Bash 命令的用戶
你可以通過配置 sudo 命令去嘲諷輸入錯誤密碼的用戶。但是現在,當用戶在 shell 輸錯命令時,就能嘲諷他了(濫用?)。
你好 bash-insulter
來自 Github 頁面:
當用戶鍵入錯誤命令,隨機嘲諷。它使用了一個 bash4.x. 版本的全新內置錯誤處理函數,叫
command_not_found_handle。
安裝
鍵入下列 git 命令克隆一個倉庫:
git clone https://github.com/hkbakke/bash-insulter.git bash-insulter
示例輸出:
Cloning into 'bash-insulter'...
remote: Counting objects: 52, done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 52 (delta 12), reused 12 (delta 2), pack-reused 0
Unpacking objects: 100% (52/52), done.
用文本編輯器,比如說使用 vi,編輯你的 ~/.bashrc 或者 /etc/bash.bashrc 文件:
$ vi ~/.bashrc
在其後追加這一行(具體了解請查看 if..else..fi 聲明 和 source 命令):
if [ -f $HOME/bash-insulter/src/bash.command-not-found ]; then
source $HOME/bash-insulter/src/bash.command-not-found
fi
保存並關閉文件。重新登錄,如果不想退出賬號也可以手動運行它:
$ . $HOME/bash-insulter/src/bash.command-not-found
如何使用它?
嘗試鍵入一些無效命令:
$ ifconfigs
$ dates
示例輸出:
自定義
你需要編輯 $HOME/bash-insulter/src/bash.command-not-found:
$ vi $HOME/bash-insulter/src/bash.command-not-found
示例代碼:
command_not_found_handle () {
local INSULTS=(
"Boooo!"
"Don't you know anything?"
"RTFM!"
"Hahaha, n00b!"
"Wow! That was impressively wrong!"
"What are you doing??"
"Pathetic"
"...and this is the best you can do??"
"The worst one today!"
"n00b alert!"
"Your application for reduced salary has been sent!"
"lol"
"u suk"
"lol... plz"
"plz uninstall"
"And the Darwin Award goes to.... ${USER}!"
"ERROR_INCOMPETENT_USER"
"Incompetence is also competence"
"Bad."
"Fake it till you make it!"
"What is this...? Amateur hour!?"
"Come on! You can do it!"
"Nice try."
"What if... you type an actual command the next time!"
"What if I told you... it is possible to type valid commands."
"Y u no speak computer???"
"This is not Windows"
"Perhaps you should leave the command line alone..."
"Please step away from the keyboard!"
"error code: 1D10T"
"ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN."
"Pro tip: type a valid command!"
)
# 設置「隨機」種子發生器
RANDOM=$(date +%s%N)
VALUE=$((${RANDOM}%2))
if [[ ${VALUE} -lt 1 ]]; then
printf "n $(tput bold)$(tput setaf 1)$(shuf -n 1 -e "${INSULTS[@]}")$(tput sgr0)nn"
fi
echo "-bash: $1: command not found"
# 無效命令,常規返回已存在的代碼
return 127
}
贈品:sudo 嘲諷
編輯 sudoers 文件:
$ sudo visudo
追加下面這一行:
Defaults insults
或者像下面尾行增加一句嘲諷語:
Defaults !lecture,tty_tickets,!fqdn,insults
這是我的文件:
Defaults env_reset
Defaults mail_badpass
Defaults secure_path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
## If set, sudo will insult users when they enter an incorrect password. ##
Defaults insults
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL = (ALL:ALL) ALL
# Members of the admin group may gain root privileges
% admin ALL = (ALL) ALL
# Allow members of group sudo to execute any command
% sudo ALL = (ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
試一試:
$ sudo -k # 清除緩存,從頭開始
$ sudo ls /root/
$ sudo -i
樣例對話:
贈品:你好 sl
sl 或是 UNIX 經典搗蛋軟體 遊戲。當你錯誤的把 ls 輸入成 sl,將會有一輛蒸汽機車穿過你的屏幕。
$ sl
via: https://www.cyberciti.biz/howto/insult-linux-unix-bash-user-when-typing-wrong-command/
作者:Vivek Gite 譯者:CYLeft 校對:wxy
本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive
對這篇文章感覺如何?
太棒了
0
不錯
0
愛死了
0
不太好
0
感覺很糟
0
More in:Linux中國
Let's Encrypt 正式發布,已經保護 380 萬個域名
由於 Let's Encrypt 讓安裝 X.509 TLS 證書變得非常簡單,所以這個數量增長迅猛。
關於Linux防火牆iptables的面試問答
Nishita Agarwal是Tecmint的用戶,她將分享關於她剛剛經歷的一家公司(印度的一家私人公司Pune)的面試經驗。在面試中她被問及許多不同的問題,但她是iptables方面的專家,因此她想分享這些關於iptables的問題和相應的答案給那些以後可能會進行相關面試的人。 所有的問題和相應的答案都基於Nishita Agarwal的記憶並經過了重寫。 嗨,朋友!我叫Nishita Agarwal。我已經取得了理學學士學位,我的專業集中在UNIX和它的變種(BSD,Linux)。它們一直深深的吸引著我。我在存儲方面有1年多的經驗。我正在尋求職業上的變化,並將供職於印度的P
Lets Encrypt 已被所有主流瀏覽器所信任
旨在讓每個網站都能使用 HTTPS 加密的非贏利組織 Lets Encrypt 已經得了 IdenTrust的交叉簽名,這意味著其證書現在已經可以被所有主流的瀏覽器所信任。從這個裡程碑事件開始,訪問者訪問使用了Lets Encrypt 證書的網站不再需要特別配置就可以得到 HTTPS 安全保護了。 Lets Encrypt 的兩個中級證書 ...
SSL/TLS 加密新紀元 – Lets Encrypt
根據 Let's Encrypt 官方博客消息,Let's Encrypt 服務將在下周(11 月 16 日)正式對外開放。 Let's Encrypt 項目是由互聯網安全研究小組(ISRG,Internet Security Research Group)主導並開發的一個新型數字證書認證機構(CA,Certificate ...




















