Ubuntu – ZIP archive folder

Zip a folder in Ubuntu Linux using the cli

sudo apt install zip unzip

Command to compress a folders and files:

$ zip -r filename.zip folder
$ zip -r filename.zip folder1 folder2
$ zip -r filename.zip /path/to/folder1 /path/to/file2

To create compressed archive named data.zip of data folder in the current directory, run:

zip -r data.zip data/

Verify file with the ls command:

ls -l data.zip

You can encrypt data.zip with a password by passing the -e option:

zip -r -e data.zip data/

zip command has many more options as follows:

-ffreshen: only changed files
-uupdate: only changed or new files
-ddelete entries in zipfile
-mmove into zipfile (delete OS files)
-rrecurse into directories
-jjunk (don’t record) directory names
-0store only
-lconvert LF to CR LF (-ll CR LF to LF)
-1compress faster
-9compress better
-qquiet operation
-vverbose operation/print version info
-cadd one-line comments
-zadd zipfile comment
-@read names from stdin
-omake zipfile as old as latest entry
-xexclude the following names
-iinclude only the following names
-Ffix zipfile (-FF try harder)
-Ddo not add directory entries
-Aadjust self-extracting exe
-Jjunk zipfile prefix (unzipsfx)
-Ttest zipfile integrity
-XeXclude eXtra file attributes
-ystore symbolic links as the link instead of the referenced file
-ndon’t compress these suffixes
-h2show more help

Similar Posts