tar: cannot open: no such file or directory

6

0

I am trying to follow the instructions here to install Jetty on ubuntu but I am running into a problem when I try to use tar.

cd /usr/local/src
sudo wget http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.1.0.v20131115.tar.gz&r=1

But when I try

sudo tar -xfz etty-distribution-9.1.0.v20131115.tar.gz

I get the error

tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

What am I doing wrong? (I also tried as root but it did not help)


EDIT

None of the suggested answers is working for me. Below I copy my attempts from the command line. What am I doing wrong?

a@b:/usr/local/src$ ls
download.php?file=%2Fjetty%2F9.1.0.v20131115%2Fdist%2Fjetty-distribution-9.1.0.v20131115.tar.gz
download.php?file=%2Fjetty%2Fstable-9%2Fdist%2Fjetty-distribution-9.1.0.v20131115.tar.gz

a@b:/usr/local/src$ tar -tfz jetty-distribution-9.1.0.v20131115.tar.gz
tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

a@b:/usr/local/src$ tar -tfz /usr/local/src/jetty-distribution-9.1.0.v20131115.tar.gz
tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

a@b:/usr/local/src$ sudo tar xfz download.php?file=%2Fjetty%2F9.1.0.v20131115%2Fdist%2Fjetty-distribution-9.1.0.v20131115.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
a@b:/usr/local/src$ sudo tar xfz jetty-distribution-9.1.0.v20131115.tar.gztar (child): jetty-distribution-9.1.0.v20131115.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
a@b:/usr/local/src$ ^C
a@b:/usr/local/src$ 

Zeynel

Posted 2013-12-20T13:56:16.137

Reputation: 1 195

You may want to check this answer; the order of your flags as -xfz seem to be the issue; the f needs to come last.

– nyedidikeke – 2018-11-24T05:43:27.040

Similar to http://superuser.com/q/150777/38005 (but not exactly)

– Joseph Quinsey – 2013-12-20T16:35:15.130

And similar to http://superuser.com/q/211941/38005

– Joseph Quinsey – 2013-12-20T22:11:30.033

Run file download.php... long filename omitted. This should at least tell you if you have an actual archive. A common error with wget is a login or redirect (or 404) HTML page being saved instead of the target file. Then it would not be recognised as a gzip as you are seeing. – Greg – 2013-12-22T12:44:04.360

Answers

7

The use of the dash and the order of the arguments seems to be the problem:

$ tar tfz foo.tar.gz
foo
$ tar -tfz foo.tar.gz
tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
$ tar -tzf foo.tar.gz
foo
$ tar --version
tar (GNU tar) 1.15.1

Edit: The following two commands seem to work for me:

wget http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-9.1.0.v20131115.tar.gz
tar tzf jetty-distribution-9.1.0.v20131115.tar.gz

Of course, you'll need to replace tar tzf with tar xzf, and may have to add sudo.

Joseph Quinsey

Posted 2013-12-20T13:56:16.137

Reputation: 542

none of these appear to work. See my edits. Thanks. – Zeynel – 2013-12-20T20:28:56.993

1

The only 'working' command in your edits is sudo tar xfz download.php?file=..., which returns the error gzip: stdin: not in gzip format. So my answer is correct, as far as it goes. But I have no further suggestions. wget does seem to default to binary. Perhaps http://stackoverflow.com/q/12350515/318716 might help?

– Joseph Quinsey – 2013-12-20T20:54:03.603

4

The problem might be the position of the f argument. The name of the archive is supposed to follow the f argument, which is why the errors talk about not being able to open a file called z.

Try:

tar -tzf jetty-distribution-9.1.0.v20131115.tar.gz

James R. Twine

Posted 2013-12-20T13:56:16.137

Reputation: 41

1

The command sudo wget http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.1.0.v20131115.tar.gz&r=1 is wrong for two reason :

  1. The download link needs to be quoted since you use & which is a special in Bash. See http://www.gnu.org/software/bash/manual/bash.html#Definitions
  2. You're using an old dead link. Going to jetty's download page ( http://download.eclipse.org/jetty/ ) indicates http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.1.3.v20140225.tar.gz&r=1 as the right download link.

Thenceforward you've to use the following command :

sudo wget "http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.1.3.v20140225.tar.gz&r=1" -O jetty-distribution-9.1.3.v20140225.tar.gz`

The -O argument helps in outputing to the right filename.

After that, tar xvf jetty-distribution-9.1.3.v20140225.tar.gz should work.

Here, option x use extract mode, v shows more information (name of file being extracted) and f specifies that the following argument is the path to the archive to extract.

You don't need the z option which indicates a gzip compressed archive since tar will recognize it automatically.

Finally, the - preceding options is deprecated AFAIK.

Another thing: I don't recommend using sudo when it's not really needed. Here you just want to download and extract an archive, that doesn't need root privileges and you can do it in your home directory. It avoids doing mistakes which can lead to severe problems, especially when you don't really know what you're doing.

piernov

Posted 2013-12-20T13:56:16.137

Reputation: 1 796

-1

I have the same issue, then google bring me here, now the issune solved. one is about capital letter of your filename second is folder authoriz. change it to 777. Hope it helps.

haitao

Posted 2013-12-20T13:56:16.137

Reputation: 1

How is this better than other answer? – Toto – 2018-03-03T13:29:04.013