tar command create directory without 777 permission

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I run into an error while extracting a tar file, the created directory are created with the chmod 666 instead of 777. Therefore it will not extract inside this folder.



Here is my command:



$umask 000 && tar -xvzf compress.tgz
tar: dist/assets: Cannot mkdir: Permission denied
tar: dist/assets/favicon.ico: Cannot open: Permission denied

$ls -ll
drw-rw-rw- 2 user grp 4096 Mar 14 16:43 assets


I used this module on local to compress the file:



https://www.npmjs.com/package/tar



When I create a directory with mkdir it gives 777 mode, what am I missing?



As requested:



-bash-4.2$ tar tzvf compress.tgz
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/
-rw-rw-rw- 0/0 13117 2018-03-15 12:17 dist/3rdpartylicenses.txt
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/assets/


I use --strip 1 to extract.







share|improve this question


















  • 4




    you never, ever, ever need to have 777 rights.
    – Carpette
    Mar 14 at 17:22










  • @thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
    – Frennetix
    Mar 14 at 17:28










  • tar does have a p flag to preserve permissions however poor they may be
    – thrig
    Mar 14 at 17:34






  • 1




    @Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
    – roaima
    Mar 14 at 19:24






  • 1




    @RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
    – Frennetix
    Mar 15 at 16:33














up vote
0
down vote

favorite












I run into an error while extracting a tar file, the created directory are created with the chmod 666 instead of 777. Therefore it will not extract inside this folder.



Here is my command:



$umask 000 && tar -xvzf compress.tgz
tar: dist/assets: Cannot mkdir: Permission denied
tar: dist/assets/favicon.ico: Cannot open: Permission denied

$ls -ll
drw-rw-rw- 2 user grp 4096 Mar 14 16:43 assets


I used this module on local to compress the file:



https://www.npmjs.com/package/tar



When I create a directory with mkdir it gives 777 mode, what am I missing?



As requested:



-bash-4.2$ tar tzvf compress.tgz
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/
-rw-rw-rw- 0/0 13117 2018-03-15 12:17 dist/3rdpartylicenses.txt
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/assets/


I use --strip 1 to extract.







share|improve this question


















  • 4




    you never, ever, ever need to have 777 rights.
    – Carpette
    Mar 14 at 17:22










  • @thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
    – Frennetix
    Mar 14 at 17:28










  • tar does have a p flag to preserve permissions however poor they may be
    – thrig
    Mar 14 at 17:34






  • 1




    @Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
    – roaima
    Mar 14 at 19:24






  • 1




    @RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
    – Frennetix
    Mar 15 at 16:33












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I run into an error while extracting a tar file, the created directory are created with the chmod 666 instead of 777. Therefore it will not extract inside this folder.



Here is my command:



$umask 000 && tar -xvzf compress.tgz
tar: dist/assets: Cannot mkdir: Permission denied
tar: dist/assets/favicon.ico: Cannot open: Permission denied

$ls -ll
drw-rw-rw- 2 user grp 4096 Mar 14 16:43 assets


I used this module on local to compress the file:



https://www.npmjs.com/package/tar



When I create a directory with mkdir it gives 777 mode, what am I missing?



As requested:



-bash-4.2$ tar tzvf compress.tgz
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/
-rw-rw-rw- 0/0 13117 2018-03-15 12:17 dist/3rdpartylicenses.txt
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/assets/


I use --strip 1 to extract.







share|improve this question














I run into an error while extracting a tar file, the created directory are created with the chmod 666 instead of 777. Therefore it will not extract inside this folder.



Here is my command:



$umask 000 && tar -xvzf compress.tgz
tar: dist/assets: Cannot mkdir: Permission denied
tar: dist/assets/favicon.ico: Cannot open: Permission denied

$ls -ll
drw-rw-rw- 2 user grp 4096 Mar 14 16:43 assets


I used this module on local to compress the file:



https://www.npmjs.com/package/tar



When I create a directory with mkdir it gives 777 mode, what am I missing?



As requested:



-bash-4.2$ tar tzvf compress.tgz
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/
-rw-rw-rw- 0/0 13117 2018-03-15 12:17 dist/3rdpartylicenses.txt
drw-rw-rw- 0/0 0 2018-03-15 12:17 dist/assets/


I use --strip 1 to extract.









share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 11:27

























asked Mar 14 at 17:18









Frennetix

1033




1033







  • 4




    you never, ever, ever need to have 777 rights.
    – Carpette
    Mar 14 at 17:22










  • @thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
    – Frennetix
    Mar 14 at 17:28










  • tar does have a p flag to preserve permissions however poor they may be
    – thrig
    Mar 14 at 17:34






  • 1




    @Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
    – roaima
    Mar 14 at 19:24






  • 1




    @RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
    – Frennetix
    Mar 15 at 16:33












  • 4




    you never, ever, ever need to have 777 rights.
    – Carpette
    Mar 14 at 17:22










  • @thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
    – Frennetix
    Mar 14 at 17:28










  • tar does have a p flag to preserve permissions however poor they may be
    – thrig
    Mar 14 at 17:34






  • 1




    @Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
    – roaima
    Mar 14 at 19:24






  • 1




    @RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
    – Frennetix
    Mar 15 at 16:33







4




4




you never, ever, ever need to have 777 rights.
– Carpette
Mar 14 at 17:22




you never, ever, ever need to have 777 rights.
– Carpette
Mar 14 at 17:22












@thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
– Frennetix
Mar 14 at 17:28




@thebtm let's say I have a folder with one file inside dist/assets/favicon.ico. When extracting I got only one folder dist with 666 mode and nothing inside. Also it output the errors above.
– Frennetix
Mar 14 at 17:28












tar does have a p flag to preserve permissions however poor they may be
– thrig
Mar 14 at 17:34




tar does have a p flag to preserve permissions however poor they may be
– thrig
Mar 14 at 17:34




1




1




@Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
– roaima
Mar 14 at 19:24




@Carpette never say never. I can think of several scenarios where 777 is an appropriate permission mode.
– roaima
Mar 14 at 19:24




1




1




@RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
– Frennetix
Mar 15 at 16:33




@RonJohn during the tar it create the subfolder but they haven't the right chmod so the subfolder and subfiles aren't created.
– Frennetix
Mar 15 at 16:33










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.



I assume you still need to extract the files from the broken archive. Try this:



tar xzvf compress.tgz --delay-directory-restore
find dist -type d -exec chmod a+x ;


(We can't use a trailing + in this instance because the chmod must be applied one directory at time so that find can descend into the fixed subdirectories. The semicolon is prefixed with a backslash so that it's not treated by the shell as a special character, but rather it's passed to the find... -exec as a literal.)






share|improve this answer






















  • -bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
    – Frennetix
    Mar 16 at 10:36










  • @Frenentix please change the trailing + to ;. I'll update my question too
    – roaima
    Mar 16 at 10:40

















up vote
0
down vote













With star (from schily-tools), you can extract it with:



star xf file.tgz -no-p -find -type d -chmod a+x


To add the execute permission (for everybody) to the extracted directories to fix those bogus permissions in the archive.



With -no-p, the umask is also applied even if run as root, which assuming your umask is at least 002 would also fix those too wide write permissions (note that the umask takes precedence over the -chmod).



Note that none of the GNU tar, bsdtar nor star implementations of tar in my test have any issue extracting an archive with such broken permissions. Most likely here, you're trying to extract it while there was already a dist directory without search permission (because for instance you have extracted a similar archive with similarly broken permissions).



You'd need to fix those permissions first before extracting the archive.






share|improve this answer


















  • 1




    You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
    – schily
    May 31 at 9:58











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430228%2ftar-command-create-directory-without-777-permission%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.



I assume you still need to extract the files from the broken archive. Try this:



tar xzvf compress.tgz --delay-directory-restore
find dist -type d -exec chmod a+x ;


(We can't use a trailing + in this instance because the chmod must be applied one directory at time so that find can descend into the fixed subdirectories. The semicolon is prefixed with a backslash so that it's not treated by the shell as a special character, but rather it's passed to the find... -exec as a literal.)






share|improve this answer






















  • -bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
    – Frennetix
    Mar 16 at 10:36










  • @Frenentix please change the trailing + to ;. I'll update my question too
    – roaima
    Mar 16 at 10:40














up vote
2
down vote



accepted










As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.



I assume you still need to extract the files from the broken archive. Try this:



tar xzvf compress.tgz --delay-directory-restore
find dist -type d -exec chmod a+x ;


(We can't use a trailing + in this instance because the chmod must be applied one directory at time so that find can descend into the fixed subdirectories. The semicolon is prefixed with a backslash so that it's not treated by the shell as a special character, but rather it's passed to the find... -exec as a literal.)






share|improve this answer






















  • -bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
    – Frennetix
    Mar 16 at 10:36










  • @Frenentix please change the trailing + to ;. I'll update my question too
    – roaima
    Mar 16 at 10:40












up vote
2
down vote



accepted







up vote
2
down vote



accepted






As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.



I assume you still need to extract the files from the broken archive. Try this:



tar xzvf compress.tgz --delay-directory-restore
find dist -type d -exec chmod a+x ;


(We can't use a trailing + in this instance because the chmod must be applied one directory at time so that find can descend into the fixed subdirectories. The semicolon is prefixed with a backslash so that it's not treated by the shell as a special character, but rather it's passed to the find... -exec as a literal.)






share|improve this answer














As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.



I assume you still need to extract the files from the broken archive. Try this:



tar xzvf compress.tgz --delay-directory-restore
find dist -type d -exec chmod a+x ;


(We can't use a trailing + in this instance because the chmod must be applied one directory at time so that find can descend into the fixed subdirectories. The semicolon is prefixed with a backslash so that it's not treated by the shell as a special character, but rather it's passed to the find... -exec as a literal.)







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 16 at 10:41

























answered Mar 15 at 14:13









roaima

39.5k545107




39.5k545107











  • -bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
    – Frennetix
    Mar 16 at 10:36










  • @Frenentix please change the trailing + to ;. I'll update my question too
    – roaima
    Mar 16 at 10:40
















  • -bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
    – Frennetix
    Mar 16 at 10:36










  • @Frenentix please change the trailing + to ;. I'll update my question too
    – roaima
    Mar 16 at 10:40















-bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
– Frennetix
Mar 16 at 10:36




-bash-4.2$ find dist -type d -exec chmod a+x + find: 'dist/assets': Permission denied
– Frennetix
Mar 16 at 10:36












@Frenentix please change the trailing + to ;. I'll update my question too
– roaima
Mar 16 at 10:40




@Frenentix please change the trailing + to ;. I'll update my question too
– roaima
Mar 16 at 10:40












up vote
0
down vote













With star (from schily-tools), you can extract it with:



star xf file.tgz -no-p -find -type d -chmod a+x


To add the execute permission (for everybody) to the extracted directories to fix those bogus permissions in the archive.



With -no-p, the umask is also applied even if run as root, which assuming your umask is at least 002 would also fix those too wide write permissions (note that the umask takes precedence over the -chmod).



Note that none of the GNU tar, bsdtar nor star implementations of tar in my test have any issue extracting an archive with such broken permissions. Most likely here, you're trying to extract it while there was already a dist directory without search permission (because for instance you have extracted a similar archive with similarly broken permissions).



You'd need to fix those permissions first before extracting the archive.






share|improve this answer


















  • 1




    You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
    – schily
    May 31 at 9:58















up vote
0
down vote













With star (from schily-tools), you can extract it with:



star xf file.tgz -no-p -find -type d -chmod a+x


To add the execute permission (for everybody) to the extracted directories to fix those bogus permissions in the archive.



With -no-p, the umask is also applied even if run as root, which assuming your umask is at least 002 would also fix those too wide write permissions (note that the umask takes precedence over the -chmod).



Note that none of the GNU tar, bsdtar nor star implementations of tar in my test have any issue extracting an archive with such broken permissions. Most likely here, you're trying to extract it while there was already a dist directory without search permission (because for instance you have extracted a similar archive with similarly broken permissions).



You'd need to fix those permissions first before extracting the archive.






share|improve this answer


















  • 1




    You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
    – schily
    May 31 at 9:58













up vote
0
down vote










up vote
0
down vote









With star (from schily-tools), you can extract it with:



star xf file.tgz -no-p -find -type d -chmod a+x


To add the execute permission (for everybody) to the extracted directories to fix those bogus permissions in the archive.



With -no-p, the umask is also applied even if run as root, which assuming your umask is at least 002 would also fix those too wide write permissions (note that the umask takes precedence over the -chmod).



Note that none of the GNU tar, bsdtar nor star implementations of tar in my test have any issue extracting an archive with such broken permissions. Most likely here, you're trying to extract it while there was already a dist directory without search permission (because for instance you have extracted a similar archive with similarly broken permissions).



You'd need to fix those permissions first before extracting the archive.






share|improve this answer














With star (from schily-tools), you can extract it with:



star xf file.tgz -no-p -find -type d -chmod a+x


To add the execute permission (for everybody) to the extracted directories to fix those bogus permissions in the archive.



With -no-p, the umask is also applied even if run as root, which assuming your umask is at least 002 would also fix those too wide write permissions (note that the umask takes precedence over the -chmod).



Note that none of the GNU tar, bsdtar nor star implementations of tar in my test have any issue extracting an archive with such broken permissions. Most likely here, you're trying to extract it while there was already a dist directory without search permission (because for instance you have extracted a similar archive with similarly broken permissions).



You'd need to fix those permissions first before extracting the archive.







share|improve this answer














share|improve this answer



share|improve this answer








edited May 31 at 10:05

























answered Mar 16 at 11:44









Stéphane Chazelas

280k53515847




280k53515847







  • 1




    You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
    – schily
    May 31 at 9:58













  • 1




    You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
    – schily
    May 31 at 9:58








1




1




You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
– schily
May 31 at 9:58





You are correct, any decent modern tar implementation implements automated delayed directory setup for permissions and time stamps. When a directory is newly created during extraction, this is done with sane permissions and the permissions from the archive are applied later.
– schily
May 31 at 9:58













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430228%2ftar-command-create-directory-without-777-permission%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?