Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 806965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:19:42+00:00 2026-05-15T00:19:42+00:00

Just a Question Regarding unix and PHP today. What I am doing on my

  • 0

Just a Question Regarding unix and PHP today.

What I am doing on my PHP is using the Unix system to untar a tarred file.

exec("tar -xzf foo.tar.gz");

Generally everything works fine until I run into this particular foo.tar.gz, which has a file system as follows:

Applications/
Library/
Systems/

After running the tar command, it seems that the file permissions get changed to 644 (instead of 755).

This causes Permission denied (errno 13) and therefore disabling most of my code. (I’m guessing from lack of privileges)

Any way I can stop this tar command completely ruining my permissions?

Thanks.

Oh and this seems to only happen when I have a foo.tar.gz file that Has this particular file system. Anything else and I’m good.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:19:43+00:00Added an answer on May 15, 2026 at 12:19 am

    If you want to keep the permissions on files then you have to add the -p (or –preserve-permissions or –same-permissions) switch when extracting the tarball. From the tar man pages :

    --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.
    

    So PHP code should be :

    exec("tar -xzfp foo.tar.gz");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question regarding RESTful resources similar to this other question . We're also
I have a question regarding updating a MySQL database. I have three tables: Match,
i have few question regarding the return statement. a) is it compulsory to define
I have a question regarding restricted pointer assignments. See the comments in code for
i have bunch of question regarding to boost thread ? How to initialize the
I have a question regarding compiling against SDK's, which I thought I understood until
This is just a question out of curiosity since I have been needing to
Calling the javascript gurus out there. Basically my question is regarding how you structure
I'm brand new to Joomla but after browsing around a demo site and doing
I have Visual C# 2008 Professional and have developed the first half of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.