Skip to main content

Specific: effect of rm -r /./* [Resolved]

I was trying to delete files inside the current directory with rm -r /./* command. When executed it warned me about removing "...Siri..Application". I kind of panicked, thinking it's trying to delete all files from system and immediately terminated the terminal process. I want to know if this command deleted any other files. I see most files there and am able to restart iMac so all seems good but just to be sure.

PS: sorry for lack of full warning message. I quickly closed the terminal and not going to try command again to get it.

Question Credit: User 10482
Question Reference
Asked August 13, 2019
Posted Under: Apple
1 Answers

The path you gave rm to delete was /./*. Let’s break this down:

  1. / The root mount point, such as Macintosh HD. This is the root of the disk, therefore an absolute path was given rather than a relative path operating on the current directory.
  2. ./ The current directory, which is now / by the path given so far. /. is equivalent to /, so // is the path so far, except duplicate directory delimiters are combined to a single delimiter, so / so far, the same as step 1.
  3. * Glob all files and folders at this level.

Therefore, the command given was to delete all files and folders starting at the root mount point, i.e. delete all files and folders on the entire volume.

macOS System Integrity Protection will prevent this mischief from causing much damage to the system’s core components, but your own files won’t be protected if you have given full disk access to the Terminal app. I hope you have a backup of the files you need, especially from the beginning of the disk depending when you stopped the command.

credit: grg
Answered August 13, 2019
Your Answer