How to extract a zip file to a specific folder?

I have a zip file that I need to extract into another folder. When I set up extraction to said folder it says "permission denied". I've read here how to log into a terminal as root and superuser but can't find anything to help me.

I need to extract a file from my Downloads directory to /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins.

Please explain how to extract a zip file to the correct folder.


Solution 1:

We'll extract to a different folder to be sure that permissions aren't in our way:

  1. Open a terminal (Ctrl+Alt+T should work).

  2. Now create a temporary folder to extract the file:

    mkdir temp_for_zip_extract
    
  3. Let's now extract the zip file into that folder:

    unzip /path/to/file.zip -d temp_for_zip_extract
    

You should now have the contents of your zip file temp_for_zip_extract and can copy them into the desired folder.

If you can't copy the files to your folder, then check the permissions on your target folder.

The path to the downloads folder depends on what you used to download it to, try ~/Downloads. If you can't find it, then try this in a terminal:

cd ~;  find -name 'filename.zip'

You can also use a file manager, of course. There is Nautilus, Nemo, Thunar and many more, depending on your environment. Start the file manager and double click on your zip file, just like you would do in Windows.

Solution 2:

Your targeted directory is owned by root (/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins), so you cannot write to it as a normal user.

Instead of mucking around with permissions, you can use sudo to unzip as the superuser.

sudo unzip ~/Downloads/whatever.zip -d "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins"

I suggest you do this to a temporary directory first to ensure the files are what you expect and will not damage/destroy your plex installation:

unzip ~/Downloads/whatever.zip -d /tmp/whatever

then cd /tmp/whatever and verify that contents are what you expect. If so, then go ahead with the sudo command I showed above.