I am trying to run this zip command on an Ubuntu WSL: zip -r /home/chansen/db-backup/backup.zip /mnt/c/data/db/*

I want the zip to contain all contents of db at the top level, but the resulting zip has those files nested inside all the parent directories. The zip file contains: mnt > c > data > db > myFiles. I just want the myFiles part to be at the top level without all those parent directories.

2 Answers 2


One way to accomplish this would be to cd into the db directory, then run your zip command using a relative path, like this:

cd /mnt/c/data/db/
zip -r /home/chansen/db-backup/backup.zip ./*
  • Wow, alright thanks! I didn't know the CWD actually mattered, I thought it just uses the last part of the path as the top level. Jun 3, 2020 at 18:32

Another approach is to use the -j option. Below is from the zip man page

          Store just the name of a saved file (junk the path), and do not store directory names. By default,  zip
          will store the full path (relative to the current directory).

so in you case, you would do this

zip -r -j /home/chansen/db-backup/backup.zip /mnt/c/data/db/*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .