LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Best way to preserve ownership in tar compress? (https://www.linuxquestions.org/questions/linux-newbie-8/best-way-to-preserve-ownership-in-tar-compress-4175499013/)

dhinged 03-21-2014 03:51 PM

Best way to preserve ownership in tar compress?
 
Is there an easier way than using --same-owner with tar czpf? I'm not finding it anywhere and it's a pain to type every time as I use it often. Also it needs to preserve ownership on extract.

rknichols 03-21-2014 04:16 PM

Usually you don't need to specify that. In Linux, you have to be root in order to create files owned by anyone but yourself, and when tar is run by root it defaults to preserving ownership and permissions.

dhinged 03-21-2014 05:05 PM

Quote:

Originally Posted by rknichols (Post 5138920)
Usually you don't need to specify that. In Linux, you have to be root in order to create files owned by anyone but yourself, and when tar is run by root it defaults to preserving ownership and permissions.

OK thanks. I figured it would do this automatically at least for the files that shared my group and had group read/write permissions on them.

mreff555 03-21-2014 05:22 PM

Quote:

Originally Posted by dhinged (Post 5138897)
Is there an easier way than using --same-owner with tar czpf? I'm not finding it anywhere and it's a pain to type every time as I use it often. Also it needs to preserve ownership on extract.

rknichols is right but just in case the -p flag preserves permissions.


All times are GMT -5. The time now is 04:29 PM.