LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-11-2006, 03:50 PM   #1
muskiediver
LQ Newbie
 
Registered: Mar 2006
Posts: 24

Rep: Reputation: 15
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.
 
Old 07-11-2006, 04:31 PM   #2
ctkroeker
Senior Member
 
Registered: May 2005
Location: Paraguay
Posts: 1,565
Blog Entries: 1

Rep: Reputation: 50
Do
man tar
 
Old 07-11-2006, 04:49 PM   #3
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 1,997

Rep: Reputation: 302Reputation: 302Reputation: 302Reputation: 302
(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.
 
Old 07-11-2006, 04:59 PM   #4
manishsingh4u
Member
 
Registered: Oct 2005
Location: Pune, India
Distribution: OpenSUSE 11.0
Posts: 422

Rep: Reputation: 30
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
 
Old 07-18-2006, 10:24 AM   #5
muskiediver
LQ Newbie
 
Registered: Mar 2006
Posts: 24

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 10 02-23-2008 05:40 AM
.rpms, .tar.gz, .tgz, .src.rpm, & .tar.bz2 whoots Mandriva 10 10-18-2003 12:08 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM


All times are GMT -5. The time now is 11:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration