Tar exits on “Cannot stat: No such file of directory”, why

tar

I'm trying to create tar.gz file using the following command:

sudo tar -vcfz dvr_rdk_v1.tar.gz dvr_rdk/

It then start to create files (many files in folder), but then I get the following error:

tar: dvr_rdk_v1.tar.gz: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

I don't see any description of this error, what does it mean?

Best Answer

Remove - from vcfz options. tar does not need hyphen for options.

With a hyphen, the argument for the -f option is z. So the command is in effect trying to archive dvr_rdk_v1.tar.gz and dvr_rdk into an archive called z. Without the hyphen, the semantics of the options changes, so that the next argument on the command line, i.e. your archive's filename, becomes the argument to the f flag.

Also check your write permission to the directory from which you are executing the command.

Related Question