4 ms·
I think you mean owner rather than permissions. In most cases, you want to maintain permissions/file mode (read/write/execute) but not the original owner.
by delinka 8y ago
I think you mean owner rather than permissions. In most cases, you want to maintain permissions/file mode (read/write/execute) but not the original owner.
- AdmiralAsshat 8y agoExcept it doesn't do either. I've had files that had 666 user:group permissions/owner that I tar into a backup file, then untar, only to find that the file is now 664 with me:me ownership. It's brought production to a halt on more than one occasion if I try to "restore" from a backup by extracting the files and moving into production without manually fixing them first.
- noja 8y agoWhat was your umask?
- delinka 8y agoYour umask affects mode during extraction. You can pass -p to tar asking tar to attempt to restore exactly the modes in the archive. If you extract as root, it'll preserve the owner and group. Otherwise, the default is to assign the owner and group of the user running tar.
- dozzie 8y ago> I've had files that had 666 user:group permissions/owner that I tar into a backup file, then untar, only to find that the file is now 664 with me:me ownership. It was PEBKAC, not tar's fault (GNU tar, anyway). Tar does store the original owner and permissions. But the ownership of the unpacked files -- do you really expect your process to set ownership of the files to another user? The permissions would also be restored to 666 if you ran the tar as root; there are several options whose defaults depend on whether EUID is 0 or not.