I had my canonical rm -rf / moment.
Posted by Strazza02@reddit | linux | View on Reddit | 70 comments
Not as bad to be fair as a real rm -rf / but not much better either. So pacman was misbehaving (kept failing downloads) so a quick search revealed users fix that by deleting what's inside /var/cache/pacman/pkg
Fine, I'm not really a Linux expert but what could go wrong, it's just a cache, right? But see, the folder had a ton of files so I thought it was finally time to use the terminal instead of dolphin, so I've written a quick and easy rm -rf var/cache/pacman/pkg which would've been completely fine, BUT I was unsure if I was remembering the command correctly and (funnily enough) I was scared of something going wrong and deleting everything (LOL). So I've made yet another quick search but in the hurry I've made the stupid mistake of reading that pos of the AI summary and it said:
To ensure hidden files are also removed, use:
rm -rf /path/to/folder/{*,.*}
Oh nice, there probably are hidden files in there, let me paste {*,.*} at the end and the rest is correct so send... (turns around to take the phone)
Wait... why is it removing that folder it shouldn't be there...
To cut short, when I ctrl+C'd it already had more than 100 lines on screen. I do not have a Download folder anymore, my themes are gone, my personal folder on the desktop too, hell every folder in my /home is empty, including the folder that I've setup as a mounting point for my secondary SSD that had 800GB of stuff in there... it's empty now.
So yeah I'm a dumbass, and PLEASE for the love of god, never copy-paste stuff from the AI summary ever.
Now you can have a well deserved laugh at me, or drop you rm disaster to make me feel better Xd
Middle-Sand-5222@reddit
This post is the perfect example of how a 2 second decision can create hours of pain. The scary part is that everything started with a simple cache cleanup and ended with half the system getting wiped. Definitely a runable reminder that AI summaries should never replace reading the actual command before pressing Enter.
BigHeadTonyT@reddit
There is an easier, safer way to remove those
SoilMassive6850@reddit
I bet more likely than mirrors being outdated it's more that the local package db was outdated, so something like -Sy would have fixed it.
Strazza02@reddit (OP)
Thank you, I will check that out next
thjbnpbk@reddit
I second this, I also had a problem with pacman downloads failing and I just added more mirror links and now it works every time
_aurel510_@reddit
There's also just the simple
pacman -Scfor unused packages cache orpacman -Sccfor all cache. I personally use the pacman hook that removes all old cache but the previous one so I always have just one fallback cache per installed package.pleasant-peasant859@reddit
Oh my god
amilias@reddit
Never go fancy with rm commands, always keep them simple. If you do need to delete files using complex patterns, use the find command to make sure you hit all your files and rerun adding the -delete parameter after testing.
gerumpy@reddit
I’m confused why this would have deleted your home folders unless you accidentally left a space between /path/to/folder/ and {,.}.
CardOk755@reddit
Even if he didn't put the fatal space:
/path/to/folder/{,.}
=>
/path/to/folder/.*
=>
/path/to/folder/..
=>
/path/to
McDutchie@reddit
This depends on whether the shell includes
.and..in its expansion of.*. POSIX-derived shells are finally moving towards not including these, precisely because of this type of harmful effect.To test, try
echo .*and see if it starts with.and...In newer bash versions, this is controlled by the
globskipdotsshell option forshopt, which is now on by default. When the option is on,.and..are skipped.CardOk755@reddit
Don't rely on what newer shells are moving to.
Airbags are usually good. But wear a seatbelt.
binaryhextechdude@reddit
Airbags rely on a fuse. Seatbelts just work.
Strazza02@reddit (OP)
I did 😞
10MinsForUsername@reddit
My poor summer child...
AncomBunker47@reddit
This is the most wholesome comment i've seen in years, if i was OP i'd feel like my grandma hugged me and made me some cookies to feel less sad about what happened.
TheOneWhoPunchesFish@reddit
Happens. I wanted to rmrf one subfolder in $home/Applications on my mac, and accidentally deleted all my applications.
DT-Sodium@reddit
Gentlemen, it is with great pleasure to inform you that in over 10 years I haven't ruined any Linux installation yet.
icedchocolatecake@reddit
We live and we learn. I NEVER use AI for writing terminal commands. The only time I used it was for double checking stuff I already knew from before.
Either way, today I just removed AI overview in Google completely (its trash and annoying ngl), I've tried to switch but I don't have any search engine that's as good as Google.
Just avoid using AI for terminal commands.
Venylynn@reddit
Didn't you say it was a terrible move for Flathub to ban AI?
Also give Startpage a go.
icedchocolatecake@reddit
Terrible move by banning AI entirely. AI can be useful if used for assistance while coding but should be reviewed by a human and they should know about the language as well. What I'm fully against is 100% vibecoded slop made by someone who doesn't know anything about coding.
Startpage is slow asf, I've tried it.
Venylynn@reddit
So you're applying selective standards on AI? Is that not hypocritical? Terrible move to stop vibe coded garbage from getting on flathub but don't use AI. So what is the meta then.
icedchocolatecake@reddit
You're having trouble understand what AI ASSISTANCE means? Did you read my comment?
I said that I'm against fully generated code.
Venylynn@reddit
If Microsoft can't even get it right despite millions of people relying on them to get it right I just don't know if projects with way less on the line if they screw up are going to be as careful.
Little_Ad_6903@reddit
Duck duck go doesnt use ai for search
icedchocolatecake@reddit
duckduckgo is worse, i tried it and i did not like it, i'll stick to using google without ai overview.
queso184@reddit
maybe try Kagi
icedchocolatecake@reddit
Not paying for a search engine, i already pay for some stuff
DrinkMoreGlorp@reddit
then perish
queso184@reddit
idk, in my opinion the results are much better and more trustworthy since you don't have dogshit ads and SSO polluting the results. for something i use constantly, its worth $5
Zeikos@reddit
It's not that bad to get a gist, however I'd never blindly copy-paste, doubly so if they are commands that make permanent modifications.
Likewise as installing random packages, attackers publish malware under hallucinated package names
SunlightScribe@reddit
Make a
totrashcommand that moves items to the trash bin. Avoid usingrmmost of the time.Strazza02@reddit (OP)
I'll definitely do that, thank you
Wonderful-Citron-678@reddit
`gio trash
RvstiNiall@reddit
Mine is a full script. It even asks "Are you sure?" It also wont run as root.
zladuric@reddit
How does that work?
"script_delete stuff" - "
Are you sure?" - "sudo rm -rf stuff && sudo rm -rf script_delete"RvstiNiall@reddit
If statements mostly. https://github.com/dylanaraps/pure-sh-bible
zladuric@reddit
No I meant that jokingly. As in, if a tool wouldn't obey my stupid self, I'd sudo it. And if it does not support root, I'd delete the delete script itself as a root :)
shogun77777777@reddit
Mistakes happen, no matter how experienced you are. The most important lesson you should learn from this is to backup your system.
getapuss@reddit
This is why I cd into the directory and run the command from there. Then cd up one level and remove the folder.
It's manual labor and unnecessary steps. But I also don't delete all my shit on accident.
Arcon2825@reddit
That‘s why I added `bind 'set enable-bracketed-paste on'` to my `.bashrc`. It prevents pasted stuff from being executed immediately, and you have to press Enter before it actually runs the command.
DrinkMoreGlorp@reddit
Why would this not be the default. Footgun prevention measures go on by default and get turned off if they're getting in the way.
PalpitationHot9375@reddit
i had also delted my document, downloads folder
but thankfully i had accidently copied them into another folder earlier so i was able to recover but since that day i only use gui to do any and all tasks as far as possible
fallenguru@reddit
Happened to me for the first time in 30 years a couple of weeks ago, with ’~’. It decided to go down .cache, and btrfs was so slow I managed to kill it before it did any damage. :-p
Strazza02@reddit (OP)
Damn, I might've been able to stopped it in time too if I 1) didn't watch my phone 2) didn't stare at the terminal removing everything in its way like a dumbaas because I was too stunned to figure out what to do for a couple of seconds... Now I'm reinstalling the OS fresh 'cause at this point I might aswell. Leasson learned :P
Roth_Skyfire@reddit
It's easier to blame AI than it is to blame the user.
mumrik1@reddit
I managed to wipe my system with timeshift, ironically. I thought, let's be a little responsible, and without any further research I installed and ran timeshift. Then I got distracted and decided to deal with it later, so I canceled it. I don't remember exactly what happened, but everything including /home was wiped.
I had a similar accident just yesterday where I wiped my entire .config-folder. I thought, let's be a little responsible. I figured using git would be great for tracking changes and keeping an external backhup of my configs. It's been a while since using git, so I looked up a cheat sheet. I cd into .config and ran git init. Then I did git add . followed by a git commit. Git status returned a mess, but instead of dealing with it. I asked claude to continue where I left off. I blindly accepted every suggestion while watching YouTube drunk. Suddenly I started noticing my desktop shell falling apart and keybonds failing.
This time I actually have timeshift configured, but I forgot to include home-directory and had to rewrite my configs.
ChampionshipIcy7602@reddit
Take this as a lesson to learn about, not being careful, but backing up your data.
djao@reddit
If you can delete it accidentally, it's not a backup.
phoenikso@reddit
Thats why I recommend:
cd /path/to && rm -rf directory
Matheweh@reddit
Your title made me think "what does Ubuntu have to do with
rm -rf /", but that's not it, you meant it as in cannon.AncomBunker47@reddit
One of my biggest pet peeves with this company tbqfh, when i try to search something in fiction that is considered canonical sometimes what appears is some link about them
ConcaveNips@reddit
No, as in canon.
Strazza02@reddit (OP)
LOL unintended pun.
satissuperque@reddit
You probably typed a space between ´´´rm -rf /var/cache/pacman/pkg {,.}´´´ and that's why this is actually rm -rf /var/cache/pacman/pkg + rm -rf {,.}. The LLM provided command did not have the space between.
Strazza02@reddit (OP)
Yeah it was my mistake, the thing is the first command would've been completely fine, but the AI gaslit me into thinking I had to remove hidden files, probably not necessary, and that opened me up for more mistakes. But yeah ultimately my mistake
wfp5p@reddit
A habit I got into long ago is when I'm going to do a potentially risky
rm -rfis that I first runlson your path spec to make sure it's showing what you really want to delete. Then use command line editing to change thelstorm -rf. It's a little more tedious but (hopefully) shows you if you are going to remove what you think your going to remove.Strazza02@reddit (OP)
That's solid advice, thanks. I think, as other user suggested, I'm gonna create a alias to move into the trash and mainly use that, to avoid catastrophic mistakes like this
Flat-Bodybuilder3354@reddit
Are the brackets supposed to be around the astrick? I may be wrong but the astrick serves as a wildcard. So rm -rf would safety remove the folder. But the brackets may have caused it to read the command to delete the entire /car directory.
CardOk755@reddit
Wanna get rid of hidden files in a directory?
rm -fr directory/.[^.]*
But don't do that, you will almost certainly get it wrong.
Sufficient-Dare-5270@reddit
oh god that sinking feeling when the cursor just hangs for a split second too long after pressing enter is lowkey the worst trauma a developer can experience. i did this on a production database volume during my internship and my soul completely left my body lol. hopefully you had a recent snapshot or at least an old backup on a separate drive to salvage the configuration files
Strazza02@reddit (OP)
Oof, at work makes it 100x worse. Thank you for making me feel better XD
RvstiNiall@reddit
Mine is a full script. It even asks "Are you sure?" It also wont run as root.
wiebel@reddit
It happens... https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/issues/123?utm_source=perplexity
RvstiNiall@reddit
Its not just a Canonical Ubuntu thing. People on all sorts of other distros do that! /s
I'm sorry this happened to you.
parzival3719@reddit
you can clear the cache with
sudo paccache -r. i have a cronjob set up to run twice a month to do that since i always forgetStrazza02@reddit (OP)
Ty, I'll definitely do that next time 😄
SunlightScribe@reddit
I never use
-rfand I've aliasedrmto a script that moves files to the trash. There's no such thing as instant and permanent deletion.Barafu@reddit
Midnight commander has this option to first filter the file list, and then select all files and delete.
Also, one time AI told me to move files to backup. I didn't have backup, so I moved them to Trash instead, and now they are gone! AIs are so stupid!
92838388292@reddit
cannon event