Packing and Unpacking Files

From LQWiki
Jump to navigation Jump to search

Packing files

To pack means to unite several files in one file, called an archive. Practically the data can be compressed in the same step. There are two ways to del with compressed files:

1- GUI tools (with Graphical user interface):

  • Ark: default archive manager of KDE.
  • Archive Manager(Formerly known as File Roller): the default manager of GNOME.
  • Engrampa: the default archive manager of MATE desktop environment.
  • Xarchiver: the default archive manager of lightweight desktop environment like Xfce and LXDE
  • PeaZip: a cross-platform archive manager. In addition to Linux, this tool also supports other operating systems including Windows and macOS.

2- Command line tools and commands:

Typical commands for packing under Linux are

  • zip -- for .zip files

Example:

zip -r targetfile sourcedirectory
  • tar -- for .tar and .tar.gz files

Example (creates a .tar.gz file):

tar cvzf targetfile.tar.gz sourcedirectory

Example:

bzip2 sourcefile

Unpacking files

How to unpack files depends on their suffix:

  • .tar.gz

unpack with the command

tar xvzf archive.tar.gz

where archive is the archive's name without suffix

  • .tar

unpack with the command

tar xvf archive.tar

where archive is the archive's name without suffix

  • .zip

unpack with the command

unzip archive.zip

where archive is the archive's name without suffix

  • .bz2

unpack with the command

bunzip2 archive.bz2

where archive is the archive's name without suffix

  • .rar

unpack with the command

unrar x archive.rar

where archive is the archive's name without suffix


Many more archive formats exist. Most of them are recognized by file_unpack

See also