How to Zip all files in a directory in Linux

To zip all files in a given directory on Linux with the zip tool, you can use * with the zip command. This will take care of files with and without extensions since extensions are not so special on Linux. The * will match zero or more characters, with the dot included. The files that begin with a dot however are not considered when using * (or even *.*) .

Read: How to use the Gzip command in Linux

Another alternative would be to use the -r (recursive) option which will parse a whole directory in one fell swoop. For instance :

zip -r the_directory.                       [linux zip folder]

Where the_directory is the folder which contains your files. The zip command in linux thus formed will have the same directory structure along with the files. Note that when extracting the zip file, it will save all extracted files in one sub-directory.

If you do not want zip to store the paths, you could use the -j/–junk-paths option.

For more on zip command, you can view the documentation on its man page.

If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


ziad nahdy

Ziad Nahdy, fan of open source and programming languages. He is a technical writer, blogger and Linux enthusiast. He loves to read and help others with their problems. He is addicted to open source software but he also loves other technology related subjects.

Leave a Reply