How to use zip, tar commands to archive files and folders in Linux


How to Compress files and folders using zip, tar, unzip command line

how to create a ZIP file

[email protected]:~$ zip -r dir1
[email protected]:~$ zip -r file1 file2 file3

How to extract the ZIP file

[email protected]:~$ unzip

How to create a ZIP file while excluding a particular file.

[email protected]:~$ zip -x “exclude file name”

How to extract zip file while excluding particular files.

[email protected]:~$ unzip -x “exclude filename”
[email protected]:~$ zip -r directory -x “*.svn*”
[email protected]:~$ unzip -l -x “exclude filename”

Tar Commands for Archive

How to extract tar file

[email protected]:~$  tar -ztvf config.tar.gz
[email protected]:~$  tar -zxvf config.tar.gz etc/default/sysstat
[email protected]:~$  tar -xvf {tarball.tar} {path/to/file}

Example – tar -xvf tarfile.tar /home/viking

How to Extract Single file from tar file

[email protected]:~$ tar –extract –file={tarball.tar} {file}


[email protected]:~$ tar –extract –file={tarball.tar} {file}


[email protected]:~$ tar –extract –file=cbz.tar css

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.