1

I am trying to follow the installation instruction for a piece of software:

cp SOFTWARE-yyyymmdd.linux.tar.gz /usr/local/.
cd /usr/local
gunzip -c SOFTWARE-yyyymmdd.linux.tar.gz > SOFTWARE-yyyymmdd.linux.tar

But when I try to do that, I get the following error:

-bash: SOFTWARE-yyyymmdd.linux.tar: Permission denied

What could be the problem here?

Zanna
  • 72,312
Lona Gy
  • 27

1 Answers1

2

The target directory of the file redirection in your last command is owned by root and your current user account doesn't appears to have super-user privileges to create files in it. Hence you need to use sudo to decompress the file.

  • To decompress the file without extracting the archive:

    sudo gunzip -k SOFTWARE-yyyymmdd.linux.tar.gz
    

    The option -k prevents the deletion of the source file just like -c. Otherwise gunzip deletes SOFTWARE-yyyymmdd.linux.tar.gz after its successful decrompression.

  • To decompress and extract the archive:

    sudo tar -xf SOFTWARE-yyyymmdd.linux.tar.gz
    
  • If you really want to use file redirection to decompress the file you need to perform the redirection as super-user. A common way to achieve that is the “abuse” of tee:

    gunzip -c SOFTWARE-yyyymmdd.linux.tar.gz | sudo tee SOFTWARE-yyyymmdd.linux.tar > /dev/null
    

    For alternative approaches see When using sudo with redirection, I get 'permission denied'.

David Foerster
  • 36,890
  • 56
  • 97
  • 151