Apple - I accidentally used "touch .." , is there a way to safely delete this document?
Do not delete it! In unixish filesystems (including macOS), ..
is a link to the parent directory. So if you were in the directory /Users/Serax/Desktop
and you ran touch ..
, that's equivalent to touch /Users/Serax
, which just marks your home directory as being modified.
Similarly, when you're in /Users/Serax/Desktop
, trying to delete ..
is equivalent to trying to delete your home directory. If you succeeded, you'd lose all your files. You do not want to do this.
Running that touch
command will not have damaged anything, so there's nothing that needs to be fixed, deleted, or cleaned up. Just go about your business.
BTW, do you have a good backup? If not, I'd strongly recommend you make one. Because accidents happen, and sometimes you delete your entire home directory by mistake.
touch ..
didn't create a file. That is impossible on macOS because the name ..
is already taken and refers to the parent directory.
So, you have not created a new file, and you don't need to delete anything.
Your touch ..
actually only edited some of the metadata associated with the parent directory (sounds like that's the Desktop directory itself in your case):
It updated the
- last change time
- last modified time
- last accessed time
To the time that it was when you ran touch ..
. You should be able to see these changes by running stat -x ..
.
Sometimes Finder may show files called ..
, for example perhaps like this:
However, this file is not truly named ..
, it's just that Finder is hiding its extension.
Open Finder > Preferences... > Advanced, and enable the "Show all file extensions" checkbox to see what its name truly is (for example, it may be ...png
)
touch
just creates a new empty file if a previously extant file is not specified. If specified it will update the last modified date.
As you created it on your desktop, I'm sure it would be simplest to just grab it and drag it to the trash… saves making any further errors ;)
It will cause no issues at all.
rm
has consequences for the unwary that a simple drag & drop doesn't.
.
means the current directory..
means the directory above the current location
If you're not sure where you are, rm ..
could be somewhat chaotic, as it will delete (potentially all) files from the next directory up.