I am using Ubuntu-Mate 20.04 and I have lost most of the contents of my home folder. I think it could be due to using wrongly the “rm” command with sudo, but not sure if it might be something else.
I explain: I was trying to delete a folder ( “targetfolder (something)” ) and its contents at /home/user2 while being logged as user1 (user1 has sudo privileges). So, I did:
sudo rm -r /home/user2/targetfolder (something)/
At first rm gave some error messages due to the parentheses - I mean this: ( ) -, so I substituted part of the folder’s name with *, and did:
sudo rm -r /home/user2/targetfolder */
NOTE: I perhaps used quotes for the name of the folder because of the blank spaces ( 'targetfolder *' ), though last command registered in terminal goes without quotes.
As I understand it, rm should only have deleted any folder with a name starting with “targetfolder” within the home folder of user2, but it seems to have deleted the major part of the home folder of user1. I add that as I was not clear if rm was working or not I closed the terminal killing, I guess, the process.
Just in case it is relevant, both user1 and user2 home folders are encrypted using ecryptfs (the folder to be deleted at /home/user2 was outside .Private and, therefore, unencrypted).
So, my question is if the rm command as I used it could have deleted the contents of the home folder of user1 (or even affected the system).
I have a recent backup of the lost contents, but I wanted to make sure it is not due to some problem other than the rm command.
Thanks in advance and sorry for my English.
/home/user2/targetfolder */
would have been parsed as two separate things to remove: first/home/user2/targetfolder
and then*/
- the latter matching by default any non-hidden directory in the directory in which the command was runrm -r
is unforgiving and extremely dangerous if you make a mistake. It will permanently delete anything in the paths you specify as well as any other directories and files under that path. FYI- it's not necessary to usesudo
for file operations under your own home folder. Restrictingsudo
to only when you actually need it could prevent you from making a catastrophic mistake, although it may not have helped in this particular situation if you ran these commands in your home folder.history
and make sure what you did We like facts ;-)