Developer Cheatsheet Cheat Sheet by karthikmgs via cheatography.com/41761/cs/12623/

Zip Files Uncompress Files -cvf sample1​ .tar /home/s​ amp​ le1​ dir/ tar -xvf sample2​ .ta​ r.gz Uncompress tar.gz files where, tar -xvf sample3​ .ta​ r.bz2 Uncompress tar.bz2 files c – Creates a new .tar . tar -tvf sample1​ .tar Lists content of tar file (t- list content) v – Verbosely show the .tar file progress. f – File name type of the archive file. tar -tvf sample2​ .ta​ r.gz Lists content of tar.gz file (t- list content) Above command creates a "s​ amp​ le1​ .ta​ r" file by zipping tar -tvf sample3​ .ta​ r.bz2 Lists content of tar.bz2 file "/​ hom​ e/s​ amp​ le1​ dir​ /" directory.

Untar single file from tar archive file archive To extract only specific file from archive file: To create a compressed gzip archive file we use the option as z: For *.tar: tar cvzf sample2​ .ta​ r.gz /home/s​ amp​ le2​ dir tar -xvf sample1​ .tar process​ .sh or (or) tar cvzf sample3​ .tgz /home/s​ amp​ le3​ dir tar --extract --file=​ sam​ ple​ 1.tar process​ .sh For *.tar.gz: tar.bz2 archive tar -zxvf codedir​ .ta​ r.gz pom.xml (or) The bz2 feature and create archive file less than the size of the tar --extract --file=​ cod​ edi​ r.ta​ r.gz pom.xml gzip. The bz2 compres​ sion takes more time to compress and decompress For *.tar.bz2 files as compared to gzip which takes less time. To create highly tar -jxvf phpfile​ s.ta​ r.bz2 home/ph​ p/i​ nde​ x.ph​ p compressed tar file we use option as j. (or) tar cvfj sample4​ .ta​ r.bz2 /home/s​ amp​ le4 tar --extract --file=​ php​ fil​ es.tar​ .bz2 /home/p​ hp/​ ind​ ex.php OR tar cvfj sample5​ .ta​ r.tbz /home/s​ amp​ le5 OR Untar multiple files ​ ​ ​ ​ tar cvfj sample6.tar.tb2 /home/sample6 To extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file. For example the below command will extract “file 1” “file 2” from the Add Files or directo​ ries to tar Archive files archive files. tar -xvf sample1​ .tar "file 1" "file 2" To add files or directo​ ries to existing tar archived file we use the option r tar -zxvf sample2​ .ta​ r.gz "file 1" "file 2" (append) tar -jxvf sample3​ .ta​ r.bz2 "file 1" "file 2" tar -rvf sample1​ .tar xyz.txt

Extract group of files using wildcard untar archive file tar -xvf sample1​ .tar --wildc​ ards '*.php' To untar or extract a tar file, just issue following command using option x tar -zxvf sample2​ .ta​ r.gz --wildc​ ards '*.php' (extract). tar -jxvf sample3​ .ta​ r.bz2 --wildc​ ards '*.php' tar -xvf sample1​ .tar This command extracts the file in current directory untar file in different directory

To untar in a different directory then use option as "-C "​ tar -xvf samle1.tar -C /target​ Dir/

By karthikmgs Not published yet. Sponsored by Readability-Score.com cheatography.com/karthikmgs/ Last updated 26th August, 2017. Measure your website readability! Page 1 of 2. https://readability-score.com Developer Cheatsheet Cheat Sheet by karthikmgs via cheatography.com/41761/cs/12623/

Check size of tar file

Following command shows the size of archive file in KB: tar -czf - sample1​ .tar | wc -c tar -czf - sample2​ .ta​ r.gz | wc -c tar -czf - sample3​ .ta​ r.bz2 | wc -c

Tar command attributes c – create a archive file. x – extract a archive file. v – show the progress of archive file. f – filename of archive file. t – viewing content of archive file. j – filter archive through . z – filter archive through gzip. r – append or update files or directo​ ries to existing archive file. W – Verify a archive file. wildcards – Specify patterns in unix tar command

By karthikmgs Not published yet. Sponsored by Readability-Score.com cheatography.com/karthikmgs/ Last updated 26th August, 2017. Measure your website readability! Page 2 of 2. https://readability-score.com