I have downloaded a .tar.gz file to my Windows computer. I am connected to my Raspberry Pi 3 using mobaXterm. I've opened a terminal session and have access to my Pi.

  1. Where do I place a copy of the .tar.gz file on the Pi?
  2. How do I un-zip & install it?

Any help would be great & thanks!

  • You can't un-zip a tar file. :)
    – eapo
    Nov 1 '17 at 17:44

You can store files on your Pi file system anywhere you have permissions. If you are not root, then typical places are your home directory, directories and sub-directories you create from your home directory and ... the /tmp directory. Note that /tmp will be erased on reboot.

If the file is an installation image or some other media that you wish to extract and install, I would suggest downloading and extracting to /tmp and extract there. To extract a .tar.gz file, you can run:

tar -xvzf <filename>.tar.gz

(see also: https://askubuntu.com/questions/25347/what-command-do-i-need-to-unzip-extract-a-tar-gz-file).

As for installing a downloaded and extracted package, that will usually vary based upon the nature of the package. You may want to see if the package is also available for apt-get download and installation.

  • While I don't think current versions of Raspbian do this by default, /tmp maybe a tmpfs (i.e. RAM based) mount point and unpacking a large archive in it may fail and cause problems for software that need the space. To check, mount | grep "/tmp". If this mentions tmpfs, create a directory somewhere on the actual SD card instead (e.g., $HOME). If it says nothing you are okay. Also beware that /tmp may or may not be cleared by the OS on reboot regardless of its nature.
    – goldilocks
    Jul 17 '16 at 18:29
  • Being kinda new at this and little experience, the easy answers are not always obvious to me. Thanks for the assistance! The answer was in the apt-get function. Jul 17 '16 at 18:38

Note that you may put said tarball anywhere you like. Welcome to the freedom Linux has to offer ;) If it is some software to run I'd go with /opt (it might be necessary to gain elevated privileges to have write access there). See here to find out which directory would serve your needs best.

Untar using this command (as pointed out by Goldilocks, it might be advisable to create an empty directory first and do the dirty works in there in case the tar does not politely unfold into a new directory itself):

tar xfa blub.tar.gz

See also our blog to learn more useful things to get you started with the Pi.

  • Beware while most tar files, like zips, should politely unfold into a new directory, they might not, so unless you have a way to examine them first you may want to create an empty directory and do it in there.
    – goldilocks
    Jul 17 '16 at 18:21
  • I like it when they do that ;) and mingle their files and directories with whatever was already there.
    – Ghanima
    Jul 17 '16 at 18:23
  • Yes it is like being served food without a plate, standing up.
    – goldilocks
    Jul 17 '16 at 18:31

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.