How to Zip File in Linux Level of difficulty:
Compressing files is necessary to reduce its size for storage and transfer. Another purpose of compressing the files is to save disk space by temporarily packing the unused file. Zip is a compression utility for Linux, Windows NT, Minix, Atari and Macintosh, VMS, MSDOS and OS/2. Materials Needed:
- Computer with Linux Operating System
- zipped files
Linux contains a Zip program. The application is not installed in the Operating System by default. Open the application to install the zip program using shell prompt. Locate System Tools from Application and go to Terminal.
Type the command '# apt-get install zip' to install the program. Type 'apt-get install unzip' to also install the unzip program for the Linux Operating System. The unzip program may later be used to unpack the compressed files. The unzip application may also test, list, and extract files from zip archive.
Use the 'yum' commands if the computer’s Operating System is Red Hat Linux/Fedora. The commands are '# yum install zip' for the zip tool and '# yum install unzip' for the unpacking tool.
Type the command 'zip' and the name of the data for archiving to create the compressed version of the files. A sample for this is by typing the command $ zip file name. All the files in existing directory of the file name will be compressed with the name filename.zip. There is no need to type .zip in the end of the file name. The zip command will automatically add the zip suffix in the compressed version of the file.
Type the command 'zip –r' and the name of the file. This is for archiving of the whole directory. This will include all subdirectories. A sample for this commands is by typing the '$ zip –r' directory name.
Type the command 'zip -r', the source’s name, and the intended file name for the output. This is to zip a file under a different file name from the original source.
Use the command 'unzip' to extract files from a zip archive. A sample for this is by typing '$ unzip filename.zip'. This will extract all the files from the archive. The location of the extracted files is in current directory and subdirectories.
There is also a command for extracting one or several files only from the archive. The command is '$ unzip archive name.zip filename.fileformat'. A sample for this is by extracting the xx.doc from the yy archive. The command will be '$ unzip yy.zip xx.doc'.