Zip and Unzip Files on Linux (With zip and unzip)
Compress Uncompress Archive on linux
Zip and Unzip Files on Linux (With zip and unzip)
Ziping files/directories
zip file *
zip -r file *
Unziping files/directories
unzip file.zip
extract a file
unzip file.zip file.doc
Extract all files into a directory
unzip file.zip -d /home/dir
List all files from file.zip
unzip -l file.zip
Compress Uncompress Archive on linux
Tar Command in Linux
- c - Creates a new .tar archive file
- v - Verbosely show the .tar file progress
- f - File name type of the archive file
- z - Compressed
- C - Specified directory
- x - Extract
- t - List
Create tar Archive File
tar -cvf file.tar /home/dir/
Create tar.gz Archive File
tar -cvzf file.tar.gz /home/dir
tar -cvzf file.tgz /home/dir
Create tar.bz2 Archive File
tar -cvfj file.tar.bz2 /home/php
tar -cvfj file.tar.tbz /home/php
tar -cvfj file.tar.tb2 /home/php
Untar tar Archive File
tar -xvf file.tar
#Extract to a directory
tar -xvf file.tar -C /home/dir
Uncompress tar.gz Archive File
tar -xvf file.tar.gz
List Content tar.gz Archive File
tar -tvf file.tar.gz
List Content tar.bz2 Archive File
tar -tvf file.tar.bz2
Compress
$ gzip file1 file2 file3
NOTE : gzip
used to compress a single file and it is unable to compress a folder . To compress a folder, use tar -z
Extract GZ file (Using gzip / guzip)
$ gzip -d file.gz
OR
$ gunzip file.gz
Other Tar Zip Operations on Linux CLI
Delete a File From a Tar file
tar --delete -f example.tar file_to_delete.txt
Comments