To unzip the epub, move the ePub to a folder, cd to it then simply:
unzip MyEbook.epub
E-book readers require that the mimetype file is the first one in the zip document. What's more, to be fully compliant, this file should start at a very specific point - a 30-byte offset from the beginning of the zip file (so that the mimetype text itself starts at byte 38). If this sounds intimidating, don't worry. It's actually quite easy to achieve if you're careful.
zip -X MyNewEbook.epub mimetype
zip -rg MyNewEbook.epub META-INF -x \*.DS_Store
zip -rg MyNewEbook.epub OEBPS -x \*.DS_Store
Some explanations necessary here. We start each line with two flags:
-r
(recursive) This means move down through any directories/folders recursively, ensuring that everything in the folders specified gets included-g
(grow file)
comment by @phoenixeliot