1

I am studying for a Linux certification from the Linux foundation but I have some questions about one lab. Here is the lab:

Create a directory called backup and in it place a compressed tar archive of all the files under /usr/include, with the highest level directory being include. You can use any compression method (gzip, bzip2 or xzip).

I started with mkdir backup and then tar -C /usr -zcf include.tar.gz include:

harrydevries@harrydevries-410-100nd:/usr$ tar -C /usr -zcf include.tar.gz include
tar (child): include.tar.gz: Functie open() is mislukt: Toegang geweigerd
tar (child): Error is not recoverable: exiting now

Can anyone help? I'm using Ubuntu 14.04 Harry de Vries

7
  • My dutch is not very good but I think tar tells you that it was denied permission to the /usr folder. Try sudo tar zcvf include.tar.gz include . – HATEthePLOT Feb 19 '16 at 11:21
  • I actually wanted to comment since I can't I've to do this way.What you're doing is compressing the actual /use/include folder which is wrong I guess because of dependencies issues. Instead what you have to do is make a copy of all the files and folders to your backup folder and compress it. – arvind Feb 19 '16 at 11:23
  • Please edit your question and include the output of the same command with LC-ALL=C before it: LC_ALL=C tar -C .... – terdon Feb 19 '16 at 11:24
  • seems reasonable i will try , copy and than tar everyting – Mokum Feb 19 '16 at 11:25
  • What dependency issues? The tar command won't replace any of the existing files, it will make a copy. – terdon Feb 19 '16 at 11:26
2

Having put your error through Google translate, the problem is (obviously enough) a question of permissions. Next time, please either translate the error messages or —even better—prepend LC_ALL=C to any command you run so the errors can be in English.

Anyway, the error is:

$ cd /usr ; tar zcvf include.tar.gz include
tar (child): include.tar.gz: Cannot open: Permission denied
tar (child): Error is not recoverable: exiting now
include/
include/cairomm-1.0/
include/cairomm-1.0/cairomm/
include/cairomm-1.0/cairomm/win32_surface.h
include/cairomm-1.0/cairomm/surface.h

This is because you are trying to run this from the /usr directory and are specifying that the archive should be created in /usr as well. To avoid this, either give a path for the tar ball:

mkdir ~/backup; cd /usr ; tar zcvf ~/backup/include.tar.gz include

Or, even better, don't cd to /usr at all:

mkdir ~/backup; tar zcvf ~/backup/include.tar.gz /usr/include
1
  • Thanx terdon this worked out fine, i understand now . – Mokum Feb 19 '16 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.