Just for curiosity, what will happen after you run
sudo rm -rf /mnt/c/* in WSL (Windows Subsystem for Linux)? Will it remove whole C drive in my computer? Will WSL keep working or not? If
sudo rm -rf /*, will it remove the
Being root inside WSL does not make you an admin on Windows. So no, it will not remove the entirety of C:. It may however delete enough shared files and/or your stuff in your user profile to do quite some damage. You can still delete a lot there.
It could make it so you either can no longer log in or some of the software you installed fails.
Here’s what happens with protected files:
daniel@db-d-18:/mnt/c/Program Files/Firefox Developer Edition$ sudo rm install.log rm: cannot remove 'install.log': Permission denied
You totally can destroy your WSL distribution this way of course.
what will happend after you run
sudo rm -rf /mnt/c/*in wsl
sudo rm -rf /*will it remove
Both are similar scenarios.
No, it won't remove the whole drive, but it will still do substantial damage (as @DanielB points out as well). See (and pity) this question on Ask Ubuntu, where the user accidentally did exactly what you are asking.
I started getting all sorts of other errors from Windows
Now everything is working weird even in Windows ... too much has been damaged.
While files in
C:\Windows would be protected against deletion, those in
C:\Users\<youruser>) would not, including:
Local and remote settings for most installed applications, including:
- Your Start menu (
- Your browser settings, cookies, saved passwords, etc.
- Ironically, your WSL distributions that were installed from the Store (
- Your desktop.
- Etc. etc. etc.
- Your Start menu (
Documents, Pictures, Downloads, Music, etc.
Files stored on OneDrive, typically at
%userprofile%\OneDrive. Note that the files that are deleted here would go to the OneDrive Recycle Bin, unlike normal files deleted through WSL.
In short, it would be catastrophic. Windows should still be bootable, but you would need to create a new user to recover.
However, if you were running WSL in UAC elevated (Admin) console, then the damage would be even worse. It still wouldn't be able to remove in-use files, but it would wipe away enough of
C:\Windows to make it unbootable.