Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to use the tar command to tar up a directory

Posted on 2010-09-09
4
Medium Priority
?
423 Views
Last Modified: 2012-08-13
I have a directory called webapps, all the contents  i need to compress into a tar file.  How can I do this? Should I use tar or gzip which is the better solution?
0
Comment
Question by:singh101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Assisted Solution

by:Andre Thibodeau
Andre Thibodeau earned 400 total points
ID: 33635574
tar contents of folder foo in foo.tar
tar -cvvf foo.tar foo/
0
 

Expert Comment

by:Gundares
ID: 33635834
You can also gzip (or bzip2) your archive using only one 'tar' command like this:

$ tar -zcf webapps.tar.gz webapps
$ tar -jcf webapps.tar.bz2 webapps

These commands assume that your current folder is one level upper that your 'webapps' folder
0
 

Author Comment

by:singh101
ID: 33636007
tar -zcf webapps.tar.gz webapps
when I run this command it is returning tar: z unknown function modifier. ideally I want to tar up the contents of webapps and not the webapps folder. If I cd to webapps and then replace . with webapps. Is that ok?
0
 

Accepted Solution

by:
Gundares earned 1600 total points
ID: 33636237
OK, try to use it like this:

$ tar -cf - *|gzip > ../webapps.tar.gz

you should do it inside of 'webapp' folder. If you have not write rights to the upper folder (..), put archived file into your home directory: /home/USERNAME/webapps.tar.gz. If you have a 'dot' files (like .htaccess) you should list them after an asterisk:

$ tar -cf - * .htaccess |gzip > ../webapps.tar.gz
Do not use a '.*' pattern, try '.ht*' or something similar.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question