Today, I probably did the most stupid thing I have ever done on a Linux machine.
But let's start from the beginning, how the story unfold:
How not to use rustup's filesystem layout
rustup
(by default) installs toolchains under ~/.rustup
and all the important binaries are available under ~/.cargo
.
Because I am having some trouble with getting Android Studio to reach my Rust toolchain, I tried to symlink all binaries in ~/.cargo/bin
to /usr/bin
. I knew this was going to be bad practice, I did it anyway. Only to realize that this hack did not work and now I wanted to revert my changes. But how? Easy right: Just remove all files beginning with cargo
or rust
and any other file (read: symlink) from ~/.cargo/bin
. Now one can see how bad my decision was to just 'try it out' and symlink all those files.
How not to remove files
For my 'fix' to work, I would obviously have to use sudo
. Thus, extra caution is necessary. But now see what I did:
What I wanted to do:
sudo rm cargo*
What I did instead:
sudo rm cargo *
...
So, basically, I just deleted everything in /usr/bin
.
Seriously, that's how I just broke my system.
What we learned
- NEVER 'try this out' when you modify your system level filesystem
- ALWAYS backup your system
- ALWAYS read your command twice if it combines
rm
andsudo
- even better: use something like
rm -i
ortrash-cli