I am running Ubuntu 16.04 LTS.

I am trying to extract a tar.gz file using Archive Manager.

When I try to extract to /opt it says "You do not have the permissions to extract to this folder".

How can I overcome this problem?

  • 1
    @edwinksl Bad idea. He uses a graphical program to extract the files. – UTF-8 Dec 31 '16 at 21:06
  • @UTF-8 Ah, right, I missed that. Let me delete it before bad things happen. – edwinksl Dec 31 '16 at 21:55

Most software shouldn't be installed this way.

First you should make sure /opt is really where you want to put it, and that you really want to install the file from that archive at all, rather than another source.

/opt is usually used for software that is not part of Ubuntu and not installed using Ubuntu's package manager (since when it is, it usually goes in multiple subdirectories of /usr.). In addition, most often it's used for software that is provided as pre-built binaries, and not software that you're building from source code (since that usually goes in multiple subdirectories of /usr/local).

A lot of software that is available as pre-built binaries is also packaged officially for Ubuntu (see also this question), is packaged in an unofficial PPA, or is provided in a downloadable .deb file. Those methods are often preferable (usually in that order) to installing unpackaged pre-built binaries.

If you're sure you want to unpack the archive to /opt...

If you know you want to install software in /opt, you should check if there are official guidelines, specific to that application, for how best to do so. The developer or vendor of the software may have specific recommendations that cover installation issues beyond how and where to unpack the files.

With all that said, if you know you want to extract it in /opt, you can do this in the Terminal (Ctrl+Alt+T) by running:

cd /opt
sudo cp /path/to/filename.tar.gz .
sudo tar xf filename.tar.gz

You would replace the italicized /path/to/filename.tar.gz with the actual location and filename of the file you want to put in /opt and extract. Dragging a file from Nautilus (the file browser) into the Terminal application will automatically paste its full path on the current line, which can make things easier.

If you feel you must use the Archive Manager to extract the file...

If you want to extract the software with the Archive Manager, you'll have to run the Archive Manager as root, just as the cp and tar commands in the above example were run as root. It's widely recommended to avoid running graphical programs as root unless you really know you want to--often they are not designed or tested with such use in mind.

If you really do want to run the Archive Manager as root, you can do so by pressing Alt+F2, typing the command gksudo file-roller and pressing Enter. You should be very careful after doing this -- for example, you can access and overwrite important system files. You should make sure to close the program when you're done so you don't later forget that it's running as root (rather than as your user) and use it for something else where it's not needed.

  • If you're using Ubuntu MATE, run engrampa instead of file-roller.
  • If you find you don't have the gksudo command, you can get it by installing the gksu package in the Software Center. (Or you can use one of the other ways to run graphical applications as root.)
  • Of course, you can avoid all this complexity by unpacking archives with sudo tar... in the Terminal (see above) when you need to do as as root, and reserving the Archive Manager for the more typical cases when you want to extract an archive without elevated privileges.

I don't recommend doing it this way, and this section is provided mainly for completeness or in case you're sure you want to run the Archive Manager as root. You do not need to run the Archive Manager as root to install software, even if you choose to install it from a .tar.gz archive file and choose to put it in /opt.

General information about manual installation from downloaded archives:

Often it's better to install software through the other ways listed, with links to guides, in the first section of this post. However, if you are going to install software by unpacking a .tar.gz (or similar) archive, I recommend you read How do I install a .tar.gz (or .tar.bz2) file? before proceeding.

  • As a side-note, in the old days, software to be admitted to software center was required to be installed into a single, self contained directory in opt, apart from the man pages and launcher. Seems nothing wrong with that. – Jacob Vlijm Dec 31 '16 at 21:49
  • @JacobVlijm Are you specifically talking about software, such as proprietary payware applications sold through the Software Center, that didn't make it into Ubuntu's repositories in the usual way? This reminds me of the rules for packaging Quickly apps, but the Software Center had existed for a while when Quickly was introduced. Most packages available through the Software Center are merged from Debian into Ubuntu. My understanding is that no more than a tiny fraction have ever used /opt for anything. – Eliah Kagan Dec 31 '16 at 22:07
  • it was in the days I produced this one (2014) launchpad.net/~vlijm/+archive/ubuntu/qle, I tried to get it through the never ending review procedure. I stopped trying, but kept the required format for the greater part: a self- containg dir in /opt, launcher in /usr/share/applications, man pages in the usual place. It was even told to ignore lintian warnings on the directory. I posted a question here on it, which I cannot find anymore (removed) :/. The requirements I remember clearly though. – Jacob Vlijm Dec 31 '16 at 22:17
  • 1
    @EliahKagan replying to your comment using sudo -H seems the most efficient way really, if messing up local config is the only possible damage that can be done by sudo <xapp>. I read in one answer/comment somewhere that sudo -i was what the devs want us to use for some reason, but I have searched in vain for that post more than once! >_< I have undeleted my answer since, I suppose, it has some different information to yours that might help someone - thank you :) – Zanna Dec 31 '16 at 23:58
  • what do I change for the last command to extract a zip instead of a tar? – ScottF Jan 1 '17 at 22:59

I highly recommend Eliah Kagan's answer

UTF-8's answer also suggests a good approach

You can overcome this problem by launching the archive manager program as root

sudo -i
file-roller 2>/dev/null &

(if using Ubuntu MATE, the program is engrampa instead of file-roller) Navigate to the file, extract to your desired location, and back in the terminal, don't forget to


when done, to drop privileges.

Also worth knowing, you can extract to a target directory with the -C option to the tar command, for example, if the archive is in your Downloads directory:

cd Downloads
sudo tar xvfz name-of-your.tar.gz -C /opt
  • Isn't there gksudo for that because bad things can happen when you just launch graphical applications as root? Configuration files can be created which only root can access or only root can modify. – UTF-8 Dec 31 '16 at 21:36
  • @UTF-8 I believe using sudo -i is the preferred way of avoiding that problem :) gksudo is actually deprecated. See my question which has some links to other posts (still waiting for good answer) – Zanna Dec 31 '16 at 21:41
  • @Zanna: Use of the -H flag is mandatory. Failing to use this flag may corrupt critical system files and prevent you from logging in. - Quoting from Ubuntu community wiki page. – AneesAhmed777 Mar 29 at 7:25
  • @AneesAhmed777 it is not necessary when using sudo -i because that starts a root shell with a clean env and uses root's home. The -H flag simply makes sudo use root's home, which avoids writing to user's own configuration files. – Zanna Mar 29 at 11:46

Extract the files to some folder in your home folder or to a folder in /tmp. Then either of these commands:

sudo mv ~/yourfolder /opt
sudo mv /tmp/yourfolder /opt

You don't have permission to write to /opt as a normal user. Only root can do that. mv moves the files and sudo tells your computer to do it as root. You'll have to enter your password. Note that you won't see your password nor will you see dots, stars, whatever. Just type your password and hit Enter.

  • commenting here because I'm going to delete my answer because Eliah Kagan's is better. I believe using sudo -i is the preferred way of avoiding the problem you mentioned :) gksudo is actually deprecated. See my question which has some links to other posts (still waiting for good answer) – Zanna Dec 31 '16 at 21:47
  • @Zanna, I like to believe you, but never actually found anything sbout gksu or gksudu being deprecated. Do you have any source on that? – Jacob Vlijm Dec 31 '16 at 21:52
  • @JacobVlijm maybe that's the wrong word, but in the answer to the second (I think) linked post in my answer, they explain that gksudo is not installed in Ubuntu by default any more because the devs want us to use sudo -i instead. But gksu(do) still works fine for now. – Zanna Dec 31 '16 at 21:56
  • @Zanna I think people mix up the fact that it is not installed by default anymore with being deprecated.... – Jacob Vlijm Dec 31 '16 at 21:58
  • 1
    @Zanna In a post linked in my answer here about running GUI programs as root I gave sudo -H for systems w/o gksu[do]. Do you know if sudo -i is now preferred to sudo -H, though? I can edit my answer here, or add a note to that one, or post another answer there contrasting bare sudo to sudo -i, etc. Btw, I think your answer (and this one) are helpful--mine's longish and it's nice to have short and focused posts too (plus you show sudo -i). You might consider undeleting it, though of course that's up to you. – Eliah Kagan Dec 31 '16 at 23:29

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.