289

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.

Eliah Kagan
  • 117,780
Tj Cooke
  • 2,899
  • Are you limited to command line? What folder are you trying to extract to? Is the extension .zip? – Dan Sep 05 '14 at 16:38
  • yes the extension is .zip im trying to extract the zip file to plex media server plug ins ...its in my downloads folder but when i try and extract to new directory it says i dont have permission – Tj Cooke Sep 05 '14 at 16:41
  • Into which folder are you trying to extract it to? – Parto Sep 05 '14 at 16:51
  • var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins to be exact is where i want it to go – Tj Cooke Sep 05 '14 at 16:55

3 Answers3

387

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.

Jan
  • 12,291
  • 3
  • 32
  • 38
  • ok now i guess im typing wrong pathname ....feel stupid asking this but what would be the default path to my downloads folder in terminal? – Tj Cooke Sep 05 '14 at 16:50
  • basically i want to add a plug in to my plex media server i just need to add this bundle there so i can install channels to my server – Tj Cooke Sep 05 '14 at 16:51
  • See my edit on how to find your file. I believe you only have a permission problem. – Jan Sep 05 '14 at 16:55
  • yeah its a permissions problem and having no luck finding it in terminal i can see it under files under my name /home/Downloads but cant find in terminal says no such file or directory – Tj Cooke Sep 05 '14 at 17:08
  • isnt there a program or something that will just unzip to appropriate folder with permissions already set? – Tj Cooke Sep 05 '14 at 17:09
  • Added info on file managers – Jan Sep 05 '14 at 17:12
  • ok i have opened it using file roller and that's where i get permission issues when extracting...can you recommend an easy quick file manager i can install and use? – Tj Cooke Sep 05 '14 at 17:18
  • Open Nautilus as super user. gksudo nautilus – Dan Sep 05 '14 at 17:19
  • That did it! thanx so much it was baffling but its in and working as far as i can tell anyways lol – Tj Cooke Sep 05 '14 at 17:33
  • Thanks. The option is on the right section of the command help. That's why I couldn't see it – Peter Chaula Nov 13 '17 at 07:04
  • I didn't find it again for the second time – Peter Chaula Jan 15 '18 at 08:00
  • from the docs (man unzip): The default behavior (with no options) is to extract into the current directory (and subdirectories below it) all files from the specified ZIP archive. – Timo Mar 13 '21 at 10:58
  • I just get a directory with one directory (the old name) inside. How do I remove that level? –  Mar 26 '22 at 20:04
  • you could shorten your answer and add as first line: use -d flag to extract to a given dir – Timo Mar 22 '23 at 12:13
  • mkdir temp_for_zip_extract is not necessary since first thing unzip will do is creating: temp_for_zip_extract, or if there are sub-folders maybe creating: temp_for_zip_extract/some_sobfolder. – gluttony Oct 25 '23 at 08:36
44

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.

Astrophe
  • 107
roadmr
  • 34,222
  • 9
  • 81
  • 93
  • 1
    I end up with /tmp/whatever/whatever that actually has all the files. How do I remove that if I don't know the name of the second whatever? –  Mar 26 '22 at 20:06
0

Try this: extract to the current directory, and then move to the directory you want:

ls zipped_folder output:

- folder1
- file1
- file2
...
unzip zipped_folder.zip;
mv zipped_folder destination_folder/;

ls destination_folder will give:

zipped_folder
- folder1
- file1
- file2
...
existing_folder
- ...
- ...
existing_file1
existing_file2
...