General discussion

  • Creator
    Topic
  • #2178986

    How to user command “tar”?

    Locked

    by liujun ·

    How to user command “tar”?

All Comments

  • Author
    Replies
    • #3197398

      here

      by jaqui ·

      In reply to How to user command “tar”?

      is the online manual for the command:

      http://www.gnu.org/software/tar/manual/html_mono/tar.html#SEC33

      at the usage section.

    • #3197350

      Here’s a little something to get you started

      by stress junkie ·

      In reply to How to user command “tar”?

      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.

      • #3196858

        Thank you very much!

        by liujun ·

        In reply to Here’s a little something to get you started

        Thanks for your answer.I have worked with linux for two years,but i’m not be familiar with linux command.I usually used linux command by remember it but not understood it.After read your answer,i understood the tar command and remember it forever.Thanks a lot!

        • #3196839

          I understand how some commands are difficult

          by stress junkie ·

          In reply to Thank you very much!

          It took me a long time to figure out the tar command. I’m happy that I could explain it in a helpful way.

      • #3196745

        A problem with Linux documentation

        by jdclyde ·

        In reply to Here’s a little something to get you started

        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!

        • #3196698

          Grand tradition in Unix

          by stress junkie ·

          In reply to A problem with Linux documentation

          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. 😀

        • #3198198

          Can you share more your Linux Documentation?

          by liujun ·

          In reply to Grand tradition in Unix

          The way you explained linux command helped me a lot.I tried to find more documentation in your discussions or blogs,but i failed.could you tell me where to find it?

        • #3198131

          TR posts get lost in the archives

          by stress junkie ·

          In reply to Can you share more your Linux Documentation?

          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.

          😀

    • #3081825

      Usage of TAR Command

      by kernel.opensource ·

      In reply to How to user command “tar”?

      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

    • #3133070

      I use tar with feathers

      by x-marcap ·

      In reply to How to user command “tar”?

      tar -cvf /filename ./* for example

      -c (create or compress)
      v (verbose)
      f (following)

      ./* (get everthing relative to this path)

Viewing 3 reply threads