Score:0

How do you figure out what rm -rf deleted

cn flag

I've accidentally executed rm -rf ~ because I failed to autocomplete a directory and it stayed with my home directory.

I was quick enough to kill the command in time, so no real damage (I think) was done, but the first thing I've noticed in the aftermath was that my desktop background was black.

I've got the following questions:

  1. Why was my desktop background gone?
  2. Is there a way to figure out which files a rm ... command deleted?
  3. If not, does rm -rf somedir start removing files in alphabetical order?
  4. If question 2 is the case, which files are the first files in a ubuntu 22.04 home directory that might've been deleted by rm -rf ~? The alphabetically first directory in my home directory is .android
guiverc avatar
cn flag
Only you are likely to know what contents exist in ~ and how many *nanoseconds* you consider "*quick enough*" to have not done any data. Why not contrast the contents of your ~ with a prior backup? We don't know your OS/release, so we'd only be guessing (with almost no data, 20.22 isn't helpful as it makes no sense, Ubuntu releases are *year.month* in format with no year having 22 months)
Joliver avatar
cn flag
Thanks for your comment, I edited the question to include the correct release (which is 22.04). It's shameful to say, but my last backup is really old. The question was not to help my recover my deleted files, but rather to understand what rm -rf actually did when I executed it (for about 1 second)
Nmath avatar
ng flag
Unix & Linux has a good answer for [How does rm -r go about recursively removing? In what order?](https://unix.stackexchange.com/a/161772)
guiverc avatar
cn flag
The order of deletion is dependent on details you've not provided (esp. *file-system*), but regardless it's usually in the order in which the entries exist in the directory (ie. no sorting at all) I'd just do a quick look of a full directory (*including hidden files*) and contrast with a normal install OR better backup installs you have.. The type of & specific applications you use, plus type of system (ie. Server systems have less data in ~ then a Desktop system does for example) varies the results. Additional note: Depending on how you backup, the order may directory differ on backups too
Joliver avatar
cn flag
I understand that the information which was the lexicographically first directory wasn't really helpful, since my home directory can contain just about anything. That it's usually the order in which the entries exist in my directory was already very helpful, thank you
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.