12

I was trying to move a tar.gz file to /opt directory and accidentally move it /root/opt thinking it was the right place. But there was no /root/opt, so the tar.gz file renamed to opt inside the /root folder.

I renamed it back to the tar.gz file; will my files be messed up? I'm concerned if that would still be fine.

  • 9
    In Unix systems, it's entirely possible for a single file to have several names at the same time. The file's name is just a pointer to the separate data structure that contains permissions and the contents. – chrylis -cautiouslyoptimistic- Jun 01 '19 at 07:44

1 Answers1

36

Your file will be fine.

Renaming a file will not alter the file's contents in any way whatsoever.

In fact, you would still be able to successfully extract the contents of your compressed tar archive using

tar -xvz -f opt

where opt is the name you accidentally gave the file. Renaming it to its original name would obviously be of help to you for knowing what the file might be.

The name of a file is usually of minor importance on Unix systems. In particular, it is not the filename or the filename suffix ("extension") that determines how a file's contents is interpreted (although some utilities (often GUI applications) may try to second guess file formats based on the filename suffix sometimes).

Further reading:

Kusalananda
  • 333,661