Tuesday 2 October 2012

Archive & Unarchive linux commands

TAR Command

Creating a tar file from directory or file
   # tar -cvwf [tar_file] [directory | file]

Extracting/Unarchive/Untar the *.tar files from a tar file
   # tar -xwf [tar_file] -C [to_specific_folder]

Extracting/Unarchive/Untar the *.tar files from a tar file
   # tar -xvwf [tar_file] -C [to_specific_folder]

Extracting/Unarchive/Untar the *.gz files from a tar file
   # tar -xvwzf [gz_file] -C [to_specific_folder]

Creating a tarred file that is compressed
   # tar -cvjf [tbz_file] [directory | file]

Extracting the files from a tbz file
   # tar -xjf [tbz_file] -C [to_specific_folder]

Listing the tar contents without extracting any of the files
   # tar -tvf [tar_file]

GZI, GUNZIP Command

Compress the file
   # gzip [file]

Uncompress the compressed file
   # gunzip -c [compressed_file]                             // the compressed file will no longer on the drive
   # gunzip -c [compressed_file] > [file]                 // the compressed file won't be deleted

ZCAT Command

Uncompress a file
   # zcat [file]

ZIP, UNZIP Command

Archive file
   # zip [archive_file] [file_to_be_archived...]

Archive a directory
   # zip -r [archive_file] [directory_to_be_archived]
   # zip -rm [archive_file] [directory_to_be_archived]    //the to-be-archived directory will be
                                                                                             //removed
Unarchived an ZIP archive
   # unzip [archive_file]

BZIP2, BUNZIP2 Command

Compress a file
   # bzip2 [file_to_be_compressed]                            // the uncompressed version will be deleted
   # bzip2 -c [file_to_be_compressed] > [compressed_file]
  
Compress a directory
   # bzip2 -r [directory]

Uncompress compressed file
   # bunzip2 [compressed_file]
   # bzip2 -d [compressed_file]


No comments:

Post a Comment