Tag: linux bash

  • Compress and Extract Files in Linux

    Extract:

    .tar.bz2
    To extract a tar (Tape ARchiver) file, type the following in the shell prompt:

    tar xvjf yourFileName.tar.bz2

    Which will untar it to the current directory. Depending on the file structure that being compressed, it might create sub-directories.
    Parameters:
    x – extract
    v – verbose output (lists all files as they are extracted)
    j – deal with bzipped file
    f – read from a file, rather than a tape device

    .tar.gz or .tgz

    tar xvzf file.tar.gz
    tar xvzf file.tgz

    Parameters:
    -x, –extract, –get extract files from an archive
    -v, –verbose verbosely list files processed
    -z, –gzip, –gunzip, –ungzip filter the archive through gzip
    -f, –file=ARCHIVE use archive file or device ARCHIVE

    .bz2 file

    tar jxf YOUR_FILE_NAME.bz2

    .zip file

    unzip YOUR_FILE_NAME.zip