It Happened: Bumblebee does the rm -rf /usr on Linux

Share

In 2011, Bumblebee, a third-party driver that provided support for Nvidia Optimus on Linux, contained a bug in its Bash script that caused the entire /usr directory to be deleted.

install script does rm -rf /usr for ubuntu #123

An extra space at line 351:
rm -rf /usr /lib/nvidia-current/xorg/xorg

causes the install.sh script to do an rm -rf on the /usr directory for people installing in ubuntu.

Totally uncool dude!!! The script deletes everything under /usr. I just had to reinstall linux on my pc to recover.

Removing the space will fix this. Probably should do it quickly!!!

https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/issues/123 (accessed 2025-03-06)

Why it Happened?

The developer intended to delete the directory /usr/lib/nvidia-current/xorg/xorg, but typed a space character between /usr and /lib.... The shell uses space characters to separate arguments, so it parsed the text as two separate arguments instead of a single filepath. For rm, the following terminal command:

rm -rf /usr /lib/nvidia-current/xorg/xorg

Is equivalent to:

rm -rf /usr
rm -rf /lib/nvidia-current/xorg/xorg

Consequently, rm removed /usr, and after that it would try to remove /lib/nvidia-current/xorg/xorg. The latter would likely fail, as this directory's filepath is just a typo and shouldn't exist on the user's machine.

The fix was simple and has one incredible git diff.

A red line numbered 351, with a minus meaning something was removed. It reads rm -rf /usr (a space character is a darker shade of red) /lib/nvidia-current/xorg/xorg.
A gif diff showing a space character bug in a rm -rf Bash script from Github. [https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/commit/a047be85247755cdbe0acce6f1dafc8beb84f2ac#diff-043df5bdbf6639d7a77e1d44c5226fd7371e5259a1e4df3a0dd5d64c30dca44fL351] (accessed 2025-03-06)
Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments