Creating a File Archive

To create an archive with tar, use the `−c' ("create") option, and specify the name of the archive file to create with the `−f' option. It's common practice to use a name with a `.tar' extension, such as `my−backup.tar'.

Give as arguments the names of the files to be archived; to create an archive of a directory and all of the files and subdirectories it contains, give the directory's name as an argument. To create an archive called `project.tar' from the contents of the `project' directory, type:

$ tar −cvf project.tar project RET

This command creates an archive file called `project.tar' containing the `project' directory and all of its contents. The original `project' directory remains unchanged. Use the `−z' option to compress the archive as it is being written. This yields the same output as creating an uncompressed archive and then using gzip to compress it, but it eliminates the extra step. · To create a compressed archive called `project.tar.gz' from the contents of the `project' directory, type:

$ tar −zcvf project.tar.gz project RET

This command creates a compressed archive file, `project.tar.gz', containing the `project' directory and all of its contents. The original `project' directory remains unchanged.

NOTE: When you use the `−z' option, you should specify the archive name with a `.tar.gz' extension and not a `.tar' extension, so the file name shows that the archive is compressed. This is not a requirement, but it serves as a reminder and is the standard practice.

Posted on: 16/12/2009








0 Comments
If you want to leave a comment please Login or Register
New Debian stable release......
OpenSuSE 11.3......
The Origins of Linux......
Use fdisk to Create a Swap Partition......
Checking In a File Revision......