1

I have been trying to extract a tar.gz file on my Raspberry Pi Model B+ running Raspbian. I downloaded the file in /home/Pi/downloads, but in the terminal I use the code cd /home to go to /home/Pi/downloads to extract the file. I'm not using xarchiver because it wasn't doing anything when I tried - does anybody know how to get this to work? It succeeds, so I'm in /home. Now I use cd /pi to go to /home/pi, but I get the error bash: cd: /pi: No such file or directory. The same error occurs if I try cd /Pi/downloads or cd /downloads. Then while in /home, I try

tar -xvzf TTRLinux v1.2.0.tar.gz

And I get four successive errors:

tar (child): TTRLinux: 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

What do I do?

A) Why can't I access /home/Pi/downloads? Would I have to run cd as sudo?
B) Would it be better/easier to use xarchiver? How?

8

Changing directory to /pi fails because there is no such directory. You evidently are confused by the nature of a hierarchical filesystem (a term appropriated by Apple for "HFS", but which long pre-dated them and applies to most contemporary filesystems).

Such a filesystem is structured like a tree. The root is /; there is a further standard for its organization on linux; /home is part of that.

/home/pi/whatever

Begins with the root / and is thus an absolute path. Regardless of your current working directory (CWD), that refers to the same place.

home/pi/whatever

Is a relative path. If your CWD is /usr/local, that will refer to /usr/local/home/pi/whatever. So you did this:

cd /home

Your CWD is now /home. If you cd pi, you would be trying to change to /home/pi, since pi is a relative path. But if you try to cd /pi, you are asking for the absolute path /pi, which does not exist.

Then while in /home, I try tar -xvzf TTRLinux v1.2.0.tar.gz (yes, this is the name of the file) and I get four successive errors: tar (child): TTRLinux: Cannot open: No such file or directory

But you said "I downloaded the file in /home/Pi/downloads" -- why would you expect it to be in /home?

cd /home/pi/downloads

These are case sensitive, so be sure that's not Downloads. Check what is in your CWD with ls. It should list the file you want to extract. If not, you are in the wrong place. You can double check your location with pwd ("present working directory", same thing as CWD). When you find it, the tar invocation you have should work.


Another issue in play here are spaces in filenames. They're fine, but you have to take them into account.

tar -xvzf TTRLinux v1.2.0.tar.gz

There's no way for the interpreter to tell the difference here between two separate arguments, and one with a space in the middle. If the file really is called "TTRLinux v1.2.0.tar.gz", use:

tar -xvzf "TTRLinux v1.2.0.tar.gz"
  OR 
tar -xvzf TTRLinux\ v1.2.0.tar.gz

The first form quotes the argument, making it a single string. The second uses a character escape sequence (backslash + space) to indicate the space is part of a contiguous string. Most people will find the first form more intuitive, but the second can be useful in more convoluted circumstances.

Do double check the name to make sure that is a space and not an underscore (TTRLinux_v1.2.0.tar.gz).

  • Just to add to goldilocks brilliant answer, but not really worth a full post on it's own. If your working at a shell command line, you'll find handling tar/gz files much, much easier if you "apt-get install mc" to install midnight commander. With mc, it's then just a simple matter of highlighting the file, pressing F2, then selecting "expand" – shawty Jun 7 '15 at 16:23
  • 1
    mc is one of my fav pieces of software ever -- the quentissential orthodox file manager. You can browse inside compressed tar (.zip, .deb, etc.) files without having to unpack them too. – goldilocks Jun 7 '15 at 18:17
  • +1 to that, it's just awesome :-) I've been known to do live edits in production, to do quick fixes using it... – shawty Jun 7 '15 at 23:00
  • Ok, I was trying to do it step by step, i.e. cd /home, then cd /pi, then cd /downloads. Sorry, but thanks. I'll try this tomorrow. I'll also try the mc you're raving about. – lucs100 Jun 7 '15 at 23:48
  • Okay... Now I'm confused. I haven't tried mc yet, but here is what I've been doing. In- cd /home/pi Out- pi@raspberrypi ~ $ So what does ~ mean? Also, cd /home/pi/downloads returns No such file or directory. But " "/Downloads (capital D) works, unlike what you said. What's going on? – lucs100 Jun 8 '15 at 19:35

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.