We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.10.20. Creating, viewing, testing and unpacking an archive

Adding files and directories to the archive:
zip -r archive.zip file1.txt file2.txt directory1 directory2

In a team:

  • -r - archive the contents of the specified directories.
  • archive.zip - the name of the target archive. If the archive does not exist, it will be created.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.
Adding files and directories to the archive:
7za a archive.7z file1.txt file2.txt directory1 directory2

In a team:

  • a - add files and directories to the archive.
  • archive.7z - the name of the target archive. If the archive does not exist, it will be created.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.

Attention!

tar is an uncompressed format. Archiving does not reduce the size of the files, but simply merges them into one.

Archiving files and directories:

tar -cvf archive.tar file1.txt file2.txt directory1 directory2

In a team:

  • -c - create a new archive.
  • -v - display information during archiving.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the target archive. If the archive already exists, if the key is present -c it will be overwritten.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.

Adding files and directories to the archive:

tar -rvf archive.tar file1.txt file2.txt directory1 directory2

In a team:

  • -r - add files and directories to the archive.
  • -v - display information during archiving.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the target archive. If the archive does not exist, it will be created.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.

Notes:

  • gzip compresses worse than bzip2, but is faster.
  • The archive file can have extensions tar.gz, tar.gzip or tgz.

Archiving files and directories:

tar -czvf archive.tar.gz file1.txt file2.txt directory1 directory2

In a team:

  • -c - create a new archive.
  • -z - compress data using gzip.
  • -v - display information during archiving.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the target archive. If the archive already exists, if the key is present -c it will be overwritten.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.

Notes:

  • bzip2 compresses better than gzip, but is slower.
  • The archive file can have extensions tar.bz2, tar.bzip2, tbz2, tb2 or tbz.

Archiving files and directories:

tar -cjvf archive.tar.bz2 file1.txt file2.txt directory1 directory2

In a team:

  • -c - create a new archive.
  • -j - compress data using bzip2.
  • -v - display information during archiving.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the target archive. If the archive already exists, if the key is present -c it will be overwritten.
  • file1.txt and so on - the files to be archived.
  • directory1 and so on - the directories to be archived.

Note

lsar supports archives in zip, 7z, rar, tar.gz, tar.bz2, etc.

Viewing the contents of the archive:

lsar archive.7z

In a team:

  • archive.7z - the name of the archive.
Viewing the contents of the archive:
unzip -l archive.zip

In a team:

  • -l - display a list of files in the archive.
  • archive.zip - the name of the archive.
Viewing the contents of the archive:
7za l archive.7z

In a team:

  • l - display a list of files in the archive.
  • archive.7z - the name of the archive.
Viewing the contents of the archive:
unrar l archive.rar

In a team:

  • l - display a list of files in the archive.
  • archive.rar - the name of the archive.
Viewing a summary of the contents of the archive:
tar -tf archive.tar

In a team:

  • -l - display a list of files in the archive.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the archive.

View the full contents of the archive:

tar -tvf archive.tar

In a team:

  • -l - display a list of files in the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the archive.

Note

The archive file can have extensions tar.gz, tar.gzip or tgz.

Viewing a summary of the contents of the archive:

tar -tf archive.tar.gz

In a team:

  • -l - display a list of files in the archive.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.gz - the name of the archive.

View the full contents of the archive:

tar -tvf archive.tar.gz

In a team:

  • -l - display a list of files in the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.gz - the name of the archive.

Note

The archive file can have extensions tar.bz2, tar.bzip2, tbz2, tb2 or tbz.

Viewing a summary of the contents of the archive:

tar -tf archive.tar.bz2

In a team:

  • -l - display a list of files in the archive.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.bz2 - the name of the archive.

View the full contents of the archive:

tar -tvf archive.tar.bz2

In a team:

  • -l - display a list of files in the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.bz2 - the name of the archive.
Archive testing:
unzip -tq archive.zip

In a team:

  • -t - test the archive for errors.
  • -q - display a minimum of information.
  • archive.zip - the name of the archive.
Archive testing:
7za t archive.7z

In a team:

  • t - test the archive for errors.
  • archive.7z - the name of the archive.
Archive testing:
unrar t archive.rar

In a team:

  • t - test the archive for errors.
  • archive.rar - the name of the archive.

Note

The archive file can have extensions tar.gz, tar.gzip or tgz.

Archive testing:

gzip -t archive.tar.gz

In a team:

  • -t - test the archive for errors.
  • archive.tar.gz - the name of the archive.

Note

The archive file can have extensions tar.bz2, tar.bzip2, tbz2, tb2 or tbz.

Archive testing:

bzip2 -t archive.tar.bz2

In a team:

  • -t - test the archive for errors.
  • archive.tar.bz2 - the name of the archive.

Note

unar supports archives in zip, 7z, rar, tar.gz, tar.bz2, etc.

Unpacking the contents of the archive into the current directory:

unar archive.7z

In a team:

  • archive.7z - the name of the archive.

Unpacking the contents of the archive into the specified directory:

unar archive.7z -o /path/to/dir

In a team:

  • archive.7z - the name of the archive.
  • -o - unpack to the specified directory.
  • /path/to/dir - path to the specified directory.

Attention!

To avoid possible problems with encoding, unpack archives containing files with Cyrillic names using unar.

Unpacking the contents of the archive into the current directory:

unzip archive.zip

In a team:

  • archive.zip - the name of the archive file.

Unpacking the contents of the archive into the specified directory:

unzip archive.zip -d /path/to/dir

In a team:

  • archive.zip - the name of the archive.
  • -d - unpack to the specified directory.
  • /path/to/dir - path to the specified directory.

Attention!

To avoid possible problems with encoding, unpack archives containing files with Cyrillic names using unar.

Unpacking the contents of the archive into the current directory:

7za x archive.7z

In a team:

  • x - unpack the contents of the archive.
  • archive.7z - the name of the archive.

Unpacking the contents of the archive into the specified directory:

7za x archive.7z -o/path/to/dir

In a team:

  • x - unpack the contents of the archive.
  • archive.7z - the name of the archive.
  • -o - unpack to the specified directory. Attention! There should be no space after the key.
  • /path/to/dir - path to the specified directory. Attention! The path does not have to start with ~.

Attention!

To avoid possible problems with encoding, unpack archives containing files with Cyrillic names using unar.

Unpacking the contents of the archive into the current directory:

unrar e archive.rar

In a team:

  • e - unpack the contents of the archive.
  • archive.rar - the name of the archive.

Unpacking the contents of the archive into the specified directory:

unrar e archive.rar /path/to/dir

In a team:

  • e - unpack the contents of the archive.
  • archive.rar - the name of the archive.
  • /path/to/dir - path to the specified directory.
Unzip the contents of the archive into the current directory:
tar -xvf archive.tar

In a team:

  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the archive.

Unzip the contents of the archive to the specified directory:

mkdir /path/to/dir
tar -xvf archive.tar -C /path/to/dir

In a team:

  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar - the name of the archive.
  • -C - unpack to the specified directory.
  • /path/to/dir - path to the specified directory.

Note

The archive file can have extensions tar.gz, tar.gzip or tgz.

Unpacking the contents of the archive into the current directory:

tar -zxvf archive.tar.gz

In a team:

  • -z - unpack the contents of the archive.
  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.gz - the name of the archive.

Unpacking the contents of the archive into the specified directory:

mkdir /path/to/dir
tar -zxvf archive.tar.gz -C /path/to/dir

In a team:

  • -z - unpack the contents of the archive.
  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.gz - the name of the archive.
  • -C - unpack to the specified directory.
  • /path/to/dir - path to the specified directory.

Note

The archive file can have extensions tar.bz2, tar.bzip2, tbz2, tb2 or tbz.

Unpacking the contents of the archive into the current directory:

tar -jxvf archive.tar.bz2

In a team:

  • -j - unpack the contents of the archive.
  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.bz2 - the name of the archive.

Unpacking the contents of the archive into the specified directory:

mkdir /path/to/dir
tar -jxvf archive.tar.bz2 -C /path/to/dir

In a team:

  • -j - unpack the contents of the archive.
  • -x - unzip the contents of the archive.
  • -v - display detailed information.
  • -f - means that the next argument in the command is the name of the archive.
  • archive.tar.bz2 - the name of the archive.
  • -C - unpack to the specified directory.
  • /path/to/dir - path to the specified directory.