With creating of Archive file you want to remove the original files or folders that have been used to create the ZIP archive file of yours, then use -m option.
This command creates an archive “ archive-filename.zip” with the folders “ folder1” and “ folder2” including all subfolders and files in the current directory.Ĭreate Zip archive and delete the original files To add a folder to an archive: zip -r archive-filename.zip folder1 folder2 (.) With this command, an archive “ archive-filename.zip” with the files “ file1” and “ file2” is created or updated in the current directory. If the archive already exists, the files and folders are added to the archive or updated. The archive is not replaced. The syntax of the individual commands is always the same: zip options archive.zip files and folders list Let’s see some common commands that will help us to use this tool for extracting archive files and repacking the ones we want. e encrypt -n don't compress these suffixes y store symbolic links as the link instead of the referenced file T test zipfile integrity -X eXclude eXtra file attributes A adjust self-extracting exe -J junk zipfile prefix (unzipsfx) F fix zipfile (-FF try harder) -D do not add directory entries x exclude the following names -i include only the following names read names from stdin -o make zipfile as old as latest entry c add one-line comments -z add zipfile comment q quiet operation -v verbose operation/print version info 0 store only -l convert LF to CR LF (-ll CR LF to LF) r recurse into directories -j junk (don't record) directory names d delete entries in zipfile -m move into zipfile (delete OS files) # Here are the options that we can use with the ZIP commands-f freshen: only changed files -u update: only changed or new files If zipfile and list are omitted, zip compresses stdin to stdout. The default action is to add or replace zipfile entries from list, whichĬan include the special name - to compress standard input.
Whereas the RPM baes Linux such as RHEL, CentOS, Fedora, AlmaLinux, Rocky Linux and others can use: sudo dnf install zip unzipĢ. If you are using a Linux distro with APT package management such as Ubuntu, Debian, Linux Mint, Kali, Mx Linux, POP! OS etc then use: sudo apt install zip unzip Although, generally ZIP tool comes pre-installed however, if not then use the below given commands as per your distro: In order to be able to create or unpack Zip archives under Linux, you must first ensure that the required tools are available on the system. Removes/Delete folders and/or files from an archive: However, if you are looking for a command-line way then here it is. For that usually, you have to just right-click on the archive file and select the unzip option. In most Linux distributions, standard tools are already installed that allow to extract ZIP files graphically and unpack an archive. Furthermore, various compression algorithms are there to keep the data size as small as possible, which also favors the transfer.
So that other users can easily download them. For example, if want to upload a folder containing multiple files online, then rather than doing this for every single one, we bundled them in an archive.
However, if not then here we let you know not only how to install and use ZIP commands on Linux such as Ubuntu, AlmaLinux, Rocky Linux, CentOS, Linux Mint, etc.Īrchives files are very useful to compress and store multiple files into a single file. It is super easy and the tool we require to do that mostly comes pre-installed.
Extracting zip files on Linux using the command line a piece of cake.