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?
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?
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.
/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 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.
engrampa
instead of file-roller
.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.)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
.
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.
opt
, apart from the man pages and launcher. Seems nothing wrong with that.
– Jacob Vlijm
Dec 31 '16 at 21:49
/opt
for anything.
– Eliah Kagan
Dec 31 '16 at 22:07
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
filename.zip
in the current directory, run unzip filename.zip
. In situations where you must do this as root, just add sudo (as with the tar xf
command shown in this answer): sudo unzip filename.zip
. The unzip
command is provided by the unzip
package, which you could install in a terminal using sudo apt-get install unzip
(you should run sudo apt-get update
first if you haven't recently). See How to unzip a zip file from the Terminal? for details and other ways to extract zip files.
– Eliah Kagan
Jan 02 '17 at 15:27
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
exit
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
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
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
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 '19 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.
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
sudo -i
instead. But gksu(do)
still works fine for now.
– Zanna
Dec 31 '16 at 21:56
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