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

techouse

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





how to create a ZIP file

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

How to extract the ZIP file

[email protected]:~$ unzip filename.zip

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

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

How to extract zip file while excluding particular files.

[email protected]:~$ unzip filename.zip -x “exclude filename”
[email protected]:~$ zip -r zipped.zip directory -x “*.svn*”
[email protected]:~$ unzip -l chirag.zip -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}




Or

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

Or

[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.