Linux Know-How provides a collection of introductory texts on often needed Linux skills.


File (de)compression

tar -zxvf filename.tar.gz

(=tape archiver) Untar a tarred and compressed tarball (*.tar.gz or *.tgz) that you downloaded from the Internet.

tar -xvf filename.tar

Untar a tarred but uncompressed tarball (*.tar).

tar czvpf /var/backups/mybackup.tar.gz /home

cd /; tar xzvpf /var/backups/mybackup.tar.gz '*/myfile.rtf'

(as root) Create a backup of /home to a compressed file. The second command shows how to restore a file from the backup. This won't include "dotfiles" (the files or directories with names starting with a dot) in my tarball. To tar everything, I would do:

tar cvzf filename.tgz * .[a-zA-Z]*


gunzip filename.gz

Decompress a zipped file (*.gz" or *.z). Use gzip (also zip or compress) if you wanted to compress files to this file format. Note the funny pronunciation of "gun zip".

zcat filename.gz | more

(=zip cat) Display the contents of a compressed file. Other utilities for operating on compressed files without prior decompression are also available: zless, zmore, zgrep, ...

bunzip2 filename.bz2

(=big unzip) Decompress a file (*.bz2) zipped with bzip2 compression utility. Used for big files.

unzip filename.zip

Decompress a file (*.zip) zipped with a compression utility compatible with PKZIP for DOS.

zip filename.zip filename1 filename2

Compress two files "filename1" and "filename2" to a zip archive called "filename.zip".

unarj e filename.arj

Extract the content of an *.arj archive.

lha e filename.lha

Extract the content of an lharc archive.

uudecode -o outputfile filename

Decode a file encoded with uuencode. uu-encoded files are typically used for transfer of non-text files in e-mail (uuencode transforms any file into an ASCII file).

cat filename | mimencode -o filename.mime

cat filename.mime |mimencode -u -o filname

(2 commands.) Encode and then decode back a file to/from the mail-oriented Internet standard for 7-bit data transfer called "mime". On older distributions, the command that does the work (mimencode) is called mmencode. Usually, you don't have to bother with these commands, your mailer should do the mime encoding/decoding in a transparent way.

ar -x my_archive.a file1 file2

(=archiver). Extract files file1 and file2 from an archive called my_archive.a. The archiver utility ar is mostly used for holding libraries.

ark &

(in X terminal). A GUI (Qt-based) archiver application. Perhaps that's everything what you need to manage your compressed files. An alternative is gnozip.


Last Update: 2010-12-16