Zip a File or a Folder in Linux CLI

I often require to compress large files or folder to port between servers and often find myself wondering the commands compress them. I usually use “zip” command command to accomplish my task. Option “-9” is used for best compression. This compression is compatible with Microsoft Windows too.

To zip a folder:

zip -9 -r <zip file> <folder name>

To zip a single file:

zip -9 <zip file> <filename>