LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   compress a directory using tar (https://www.linuxquestions.org/questions/linux-general-1/compress-a-directory-using-tar-463061/)

muskiediver 07-11-2006 03:50 PM

compress a directory using tar
 
Hello everyone.

What command do I give to compress an entire directory and it's sub folders to a tar file?

I want to log in via ssh, go to inside the directory I want to tar, then issue this command.

What exact command do I need to do? Do I need to tar the files first on the old sever?

I have searched these forms, and found nothing that would help answer this question. I apologize if this is an easy answer. I am unsure of what to do at the moment and appreciate any help.

ctkroeker 07-11-2006 04:31 PM

Do
man tar

haertig 07-11-2006 04:49 PM

(1) cd to the directory you want to tar
(2) choose your output files and directory ... I used /tmp for this example

No compression (larger output file):
Code:

$ tar cvf /tmp/outputfile.tar .
Gzip compression (smaller output file):
Code:

$ tar zcvf /tmp/outputfile.tar.gz .
Bzip compression (still smaller output file usually, but slower typically):
Code:

$ tar jcvf /tmp/outputfile.tar.bz2 .
Extract the archives created above by replacing the "c" option with "x" (c = create, x = extract). Leave off the trailing "." from the create command. Files will be extracted to your current directory.

manishsingh4u 07-11-2006 04:59 PM

To compress any folder / file
Code:

tar zcvf newtarfile.tar /path/to/folder
To extract this fife back in current directory
Code:

tar zxvf newtarfile.tar
To extract this fife back to a specific directory
Code:

tar zxvf newtarfile.tar -C /path/to/extract

muskiediver 07-18-2006 10:24 AM

For those who provided examples, thank you very much. Examples are easier to follow than the manual. I learn faster by example as I believe everyone does.

Thank you.


All times are GMT -5. The time now is 07:03 PM.