自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

命令行樂趣:嘲諷輸錯Bash命令的用戶

系統(tǒng) Linux
你可以通過配置 sudo 命令去嘲諷輸入錯誤密碼的用戶。但是現(xiàn)在,當用戶在 shell 輸錯命令時,就能嘲諷他了(濫用?)。

[[224460]]

你可以通過配置 sudo 命令去嘲諷輸入錯誤密碼的用戶。但是現(xiàn)在,當用戶在 shell 輸錯命令時,就能嘲諷他了(濫用?)。

 

你好 bash-insulter

來自 Github 頁面:

當用戶鍵入錯誤命令,隨機嘲諷。它使用了一個 bash4.x. 版本的全新內(nèi)置錯誤處理函數(shù),叫 command_not_found_handle。

 

安裝

鍵入下列 git 命令克隆一個倉庫:

  1. git clone https://github.com/hkbakke/bash-insulter.git bash-insulter

示例輸出:

  1. Cloning into 'bash-insulter'...
  2. remote: Counting objects: 52, done.
  3. remote: Compressing objects: 100% (49/49), done.
  4. remote: Total 52 (delta 12), reused 12 (delta 2), pack-reused 0
  5. Unpacking objects: 100% (52/52), done.

用文本編輯器,比如說使用 vi,編輯你的 ~/.bashrc 或者 /etc/bash.bashrc 文件:

  1. $ vi ~/.bashrc

在其后追加這一行(具體了解請查看 if..else..fi 聲明source 命令):

  1. if [ -f $HOME/bash-insulter/src/bash.command-not-found ]; then
  2. source $HOME/bash-insulter/src/bash.command-not-found
  3. fi

保存并關閉文件。重新登錄,如果不想退出賬號也可以手動運行它:

  1. $ . $HOME/bash-insulter/src/bash.command-not-found

 

如何使用它?

嘗試鍵入一些無效命令:

  1. $ ifconfigs
  2. $ dates

示例輸出:

一個有趣的 bash 鉤子功能,嘲諷輸入了錯誤命令的你。

一個有趣的 bash 鉤子功能,嘲諷輸入了錯誤命令的你。

 

自定義

你需要編輯 $HOME/bash-insulter/src/bash.command-not-found

  1. $ vi $HOME/bash-insulter/src/bash.command-not-found

示例代碼:

  1. command_not_found_handle () {
  2. local INSULTS=(
  3. "Boooo!"
  4. "Don't you know anything?"
  5. "RTFM!"
  6. "Hahaha, n00b!"
  7. "Wow! That was impressively wrong!"
  8. "What are you doing??"
  9. "Pathetic"
  10. "...and this is the best you can do??"
  11. "The worst one today!"
  12. "n00b alert!"
  13. "Your application for reduced salary has been sent!"
  14. "lol"
  15. "u suk"
  16. "lol... plz"
  17. "plz uninstall"
  18. "And the Darwin Award goes to.... ${USER}!"
  19. "ERROR_INCOMPETENT_USER"
  20. "Incompetence is also competence"
  21. "Bad."
  22. "Fake it till you make it!"
  23. "What is this...? Amateur hour!?"
  24. "Come on! You can do it!"
  25. "Nice try."
  26. "What if... you type an actual command the next time!"
  27. "What if I told you... it is possible to type valid commands."
  28. "Y u no speak computer???"
  29. "This is not Windows"
  30. "Perhaps you should leave the command line alone..."
  31. "Please step away from the keyboard!"
  32. "error code: 1D10T"
  33. "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."
  34. "Pro tip: type a valid command!"
  35. )
  36.  
  37. # 設置“隨機”種子發(fā)生器
  38. RANDOM=$(date +%s%N)
  39. VALUE=$((${RANDOM}%2))
  40.  
  41. if [[ ${VALUE} -lt 1 ]]; then
  42. printf "\n $(tput bold)$(tput setaf 1)$(shuf -n 1 -e "${INSULTS[@]}")$(tput sgr0)\n\n"
  43. fi
  44.  
  45. echo "-bash: $1: command not found"
  46.  
  47. # 無效命令,常規(guī)返回已存在的代碼
  48. return 127
  49. }

 

贈品:sudo 嘲諷

編輯 sudoers 文件:

  1. $ sudo visudo

追加下面這一行:

  1. Defaults insults

或者像下面尾行增加一句嘲諷語:

  1. Defaults !lecture,tty_tickets,!fqdn,insults

這是我的文件:

  1. Defaults env_reset
  2. Defaults mail_badpass
  3. Defaults secure_path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
  4. ## If set, sudo will insult users when they enter an incorrect password. ##
  5. Defaults insults
  6.  
  7. # Host alias specification
  8.  
  9. # User alias specification
  10.  
  11. # Cmnd alias specification
  12.  
  13. # User privilege specification
  14. root ALL = (ALL:ALL) ALL
  15.  
  16. # Members of the admin group may gain root privileges
  17. % admin ALL = (ALL) ALL  
  18.  
  19. # Allow members of group sudo to execute any command
  20. % sudo ALL = (ALL:ALL) ALL  
  21.  
  22. # See sudoers(5) for more information on "#include" directives:
  23.  
  24. #includedir /etc/sudoers.d

試一試:

  1. $ sudo -k # 清除緩存,從頭開始
  2. $ sudo ls /root/
  3. $ sudo -i

樣例對話:

當輸入錯誤密碼時,你會被一個有趣的的 sudo 嘲諷語戲弄。

當輸入錯誤密碼時,你會被一個有趣的的 sudo 嘲諷語戲弄。

 

贈品:你好 sl

sl 或是 UNIX 經(jīng)典搗蛋軟件 游戲。當你錯誤的把 ls 輸入成 sl,將會有一輛蒸汽機車穿過你的屏幕。

  1. $ sl

Linux / UNIX 桌面樂趣: 蒸汽機車

Linux / UNIX 桌面樂趣: 蒸汽機車 

責任編輯:龐桂玉 來源: Linux中國
相關推薦

2017-05-25 10:32:40

命令linux系統(tǒng)

2009-12-25 17:05:09

LINUX Bash

2018-08-22 09:40:27

2010-06-23 14:28:23

LINUX Bash

2014-10-31 10:50:28

Linux命令行工具

2012-05-14 11:20:13

Hyper-VPowerShell

2014-06-17 10:02:58

Bash Getopt命令行

2019-10-12 10:12:13

Bash命令行Linux

2015-07-01 09:15:46

linuxQuora命令行

2020-12-20 17:34:50

Linux命令行終端

2018-03-29 08:30:48

Linux命令BASH

2020-12-10 16:16:08

工具代碼開發(fā)

2020-12-11 06:44:16

命令行工具開發(fā)

2023-06-25 12:00:53

2010-11-16 13:40:52

Oracle命令行

2010-11-24 15:16:12

MySQL命令行登陸

2021-08-30 07:50:42

腳本語言命令行

2015-06-16 10:36:45

Linux命令行

2010-10-12 17:08:16

MySQL命令行

2009-10-26 18:09:31

Oracle用戶解鎖
點贊
收藏

51CTO技術棧公眾號