Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permissions when extracting from a tar file 1

Status
Not open for further replies.

ChrisPhillips

Programmer
Aug 1, 2000
11
NL
Is there a way to keep the permissions of the files contained in a tar file, rather than retaining the current file permissions?

For example:
1. I have a tar file that contains a file with execute permissions
2. I then change the permissions of the file on disk to remove the execute permissions
3. If I then extract the file from the tar file it does not have execute permissions


 
with gnu tar I believe you can pass the -p option to tar. More info:
--mode=PERMISSIONS'
When adding files to an archive, `tar' will use PERMISSIONS for
the archive members, rather than the permissions from the files.
The program `chmod' and this `tar' option share the same syntax
for what PERMISSIONS might be. *Note Permissions: (fileutils)File
permissions. This reference also has useful information for those
not being overly familiar with the Unix permission system.

Of course, PERMISSIONS might be plainly specified as an octal
number. However, by using generic symbolic modifications to mode
bits, this allows more flexibility. For example, the value `a+rw'
adds read and write permissions for everybody, while retaining
executable bits on directories or on any other file already marked
as executable.

`--preserve-permissions'
`--same-permissions'
`-p'
When `tar' is extracting an archive, it normally subtracts the
users' umask from the permissions specified in the archive and
uses that number as the permissions to create the destination
file. Specifying this option instructs `tar' that it should use
the permissions directly from the archive. *
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top