Thursday, February 5, 2015

linux command to extract .gz, .tar.bz2, .tar.gz files

I always forget how to decompress/extract certain file types in linux. Below I publish list of linux commands to decompress different archives:

Linux extract commands


.gz:
gunzip filename.gz
coommand will delete original file after extraction

.bz2:
bzip2 -d filename.bz2
coommand will delete original file after extraction
bzip2 -dk filename.bz2
this command also extracts but keep original

.tar.gz
tar -xvzf filename.tar.gz
  • x: tar can collect files or extract them. x does the latter.
  • v: makes tar talk a lot. Verbose output shows you all the files being extracted.
  • z: tells tar to decompress the archive using gzip
  • f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.


2 comments:

  1. Check out dtrx command. Intelligent extraction

    ReplyDelete
    Replies
    1. seems to be a great solution, didn't know before! Thanks!

      Delete