Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tar and permissions



Ooops... Of course, the last "tar" command of my example should not have 
the "-p" option...
Copy-paste problem :-)

Bruno Raoult wrote:

> Hector Akamine wrote:
>
>> Hi,
>>
>> I am confused about the meaning of the "preserve permissions" (-p)
>> switch in tar. According to what I have read, using -p keeps the file
>> permissions as the original files. Then, what happens when I use tar 
>> without
>> -p?
>>
>> I want to copy the contents of some user's directory using tar. I think
>> I should make the operation as root. If I use -p, will it keep the
>> file-directory permissions and owners as the original ones? What happens
>> if I don't use -p?
>>
>> Thanks in advance
>
> Here is an example of the difference using or not -p. This is linked 
> to umask.
> Not using -p could give files more restrictive permissions to file, 
> depending on umask value.
>
> pern br> mkdir tar
> pern br> cd tar
> pern br> touch foo
> pern br> ls -l
> total 0
> -rw-r--r--    1 br       users           0 Oct 24 21:52 foo
> pern br> tar cvf foo.tar foo
> foo
> pern br> mv foo foo.orig
> pern br> umask 777
> pern br> tar xpvf foo.tar
> foo
> pern br> mv foo foo-p
> pern br> tar xpvf foo.tar
> foo
> 123 pern br> ls -l
> total 12
> ----------    1 br       users           0 Oct 24 21:52 foo
> -rw-r--r--    1 br       users           0 Oct 24 21:52 foo-p
> -rw-r--r--    1 br       users           0 Oct 24 21:52 foo.orig
> -rw-rw-rw-    1 br       users       10240 Oct 24 21:53 foo.tar
>
>
>
>
> -----------------------------------------------------------------------
> Next Technical Meeting:  Sat, Nov 17 13:30-  Leading Edge, Place Canada
> Next Nomikai Meeting:    Fri, Dec 21 19:30-  Tengu Tokyo Eki-Mae
> -----------------------------------------------------------------------
> more info: http://www.tlug.gr.jp           Sponsor: Global Online Japan
>




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links