11 replies
by jaqui
is the online manual for the command:
http://www.gnu.org/software/tar/manual/html_mono/tar.html#SEC33
at the usage section.
When you use the tar command the first thing to remember is that you have to tell it what to do. Do you want to create a tar archive (c) or list the contents of a tar archive (t) or extract the contents of a tar archive (x)? There are other possibilities but these are the main ones.
Then you have to decide if you want to use compression. You can use gzip or bz2 with GNU tar. The letter z means to compress the tar archive using gzip when you are creating an archive. The letter z also means to uncompress the tar archive when you are extracting the archive. Likewise the j tells tar to compress or uncompress the archive using the bz2 compression.
The letter v tells tar to print messages about what it is doing. This is always a good idea.
Lastly you will want to tell tar where to put the archive file when it creates an archive, and tell tar where the archive already exists when you are extracting an archive. This is done with the f parameter. The f parameter ALWAYS points to the archive file.
Here is an example:
tar -czvf /temp/archive.tar.gz /home
This command tells tar to create an archive file. It does this with the letter c. Then it tells tar to compress the archive using gzip. It does this with the letter z. It tells tar to print messages about what it is doing. It does this with the letter v. It tells tar to create the archive file in the /temp directory and name the archive file archive.tar.gz. It does this with the f parameter. Lastly it tells tar what to put in the archive. In this case it will put all of the files in the /home directory tree into the archive file.
Here is an example to list the contents of an archive file named archive.tar.gz. This file was compressed using gzip when it was created.
tar -tzf archive.tar.gz
Here's a command to tell tar to extract the contents of an archive file into your current working directory. The archive file is in the /temp directory and is named archive.tar.gz.
tar -xzvf /temp/archive.tar.gz .
These are the most important operations with the tar command. Just remember that the -f parameter always points to the archive file. It took me a while to figure that out.
by liujun
by jdclyde
Even the documentation is often cryptic.
They will list the name of the command, and then a string of switches you can use, but RARELY show how to string it all together.
Working Examples of how and why to use a command with the different swtiches, what an idea!
When I started working with Microsoft Xenix in 1985 the documentation was very difficult to use. The newest GNU documentation isn't much better. Sometimes the GNU man pages have some examples but GNU man pages are basically not much better than Unix man pages were twenty years ago.
Since I enjoy doing this sort of explanation maybe I should contribute some time to the Linux Documentation Project. That idea just occurred to me. Believe it or not I never thought that I'd have any useful information to contribute. Now I think that I may.
The documentation for DEC VMS was also problematic but in a different way. Although the documentation was written in clear English with a lot of explanation it was not goal oriented. You would often have to read ten or twelve references to piece together the answer that you want. I often said at job interviews that one of my professional skills was to use the DEC VMS documentation effectively. :D
by liujun
I recently started putting links to some of my posts in my blog. Maybe I should link to this discussion in my blog as a start to explaining Unix commands. Almost all of my posts are lost in the TR archives.
I am thinking about donating time to the Linux Documentation Project, or I could write a book.
:D
Backup to Floppy:
#tar cvfzM /dev/fd0 /etc (/etc is source)
Zip Drive:
#mount /dev/sda4 /mnt/zip
#tar zcvf /mnt/zip/etc.tgz /etc (etc.tgz is destination and /etc is source)
Unzipping
#tar zxvf /mnt/zip/etc.tgz
TAP DRIVE:
#tar cvf /dev/qft0 /etc
Unzipp:
#tar xvf /dev/qft0
Only thing is "tar cvf for zip & tar xvf for unzip" followed by destination and source
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending