Adding spice to your sudo session with a lecture file on Linux or Unix

groot

groot
Despite some severe bugs in sudo, it remains the defacto tool to gain root shell or run command as another user on Linux, macOS, and Unix-like systems. The sudo command allows the system administrator to grant an individual user access to unprivileged commands. For instance, I can give developers the ability to restart the Apache webserver or PHP/Python process on a Linux server. Let us see how to remind developers and unprivileged users about the power of sudo for fun and profit. In this quick tip, I will show you how to add some spice to your sudo session with a lecture file on Linux or Unix.

cat command:
sudo cat /etc/sudoers
Adding spice to your sudo session with a lecture file on Linux or Unix

Adding spice to your sudo session with a lecture file on Linux or Unix

Creating /etc/sudo_lecture.txt

Run:
sudo vim /etc/sudo_lecture.txt
Append stuff (download sudo_lecture.txt file to avoid printing garbish on screen):

 
 
  ^[[00;31m
┌──────────────────────────────────────────┐
│ │
│ mmmm │
│ # "m mmm m mm mmmm mmm m mm │
│ # # " # #" # #" "# #" # #" "│
│ # # m"""# # # # # #"""" # │
│ #mmm" "mm"# # # "#m"# "#mm" # │
│ m # │
│ "" │
└──────────────────────────────────────────┘
^[[0m
 
Please be cautious while using sudo as you could end up damaging the system.

Our fancy sudo warning or lecture is here:
sudo lecture file demo on Linux

sudo lecture file demo on Linux
Let us use the toilet command:
sudo sh -c 'toilet -f bubble --metal "Be careful with sudo" > /etc/sudo_lecture.txt'
sudo -k
sudo -i

sudosudo

Groot prompt so spice up to your sudo session

Try groot prompt (download the groot.txt file using curl command or wget to avoid printing escape characters on screen):

 ^[[00;32m ^V// ^[[00;33m |^[[01;37m. ^[[01;37m.^[[00;33m| ^[[01;34m I AM (G)ROOT! ^[[00;32m- ^[[00;33m - / ^[[00;32m_ ^[[00;33m _| |_/ ^[[00;33m ^[[00;31m __^[[00;33m/^[[00;31m_^[[00;33m/^[[00;31m__ ^[[00;31m|_______| ^[[00;37m With great power comes great responsibility. ^[[00;31m / ^[[00;37m Use sudo wisely. ^[[00;31m ___/
^[[0m

grootgroot

Conclusion

The lecture_file is a cool idea when combined with ANSI escape code for colors and other CLI utilities such as toilet and figlet. The credit for the spying up sudo with Groot goes to Chris.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far… add one

Category List of Unix and Linux commands
cat ncdu
Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
NetHogs dig host ip nmap
CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
apk apt
bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
grep whereis which
groups id lastcomm last lid/libuser-lid logname members users whoami who w
Alpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Posted by Contributor