If your computer has antivirus program can scan all files on the computer, as well as each file individually. You can scan any file by clicking right click by clicking on the file and selecting the appropriate option to perform a virus scan on the file.

For example, in this figure, file my-file.xz, then you need to right-click on this file, and in the file menu select the option "scan from help from AVG» . Selecting this option will open AVG Antivirus which will check given file for the presence of viruses.


Sometimes an error can result from incorrect installation software , which may be due to a problem that occurred during the installation process. It may interfere with your operating system associate your XZ file with the correct application software tool , influencing the so-called "file extension associations".

Sometimes simple reinstalling 7-Zip may solve your problem by properly linking XZ with 7-Zip. In other cases, file association problems may result from bad software programming developer, and you may need to contact the developer for additional help.


Advice: Try updating 7-Zip to latest version to make sure the latest patches and updates are installed.


This may seem too obvious, but often the XZ file itself may be causing the problem. If you received a file via an attachment Email or downloaded it from a website and the download process was interrupted (such as a power outage or other reason), the file may be corrupted. If possible, try getting a fresh copy of the XZ file and try opening it again.


Carefully: A corrupted file may cause collateral damage to a previous or existing malware on your PC, so it is very important that you have an up-to-date antivirus running on your computer at all times.


If your XZ file associated with the hardware on your computer to open the file you may need update device drivers associated with this equipment.

This problem usually associated with media file types, which depend on the successful opening of the hardware inside the computer, for example, sound card or video cards. For example, if you are trying to open an audio file but cannot open it, you may need to update sound card drivers.


Advice: If when you try to open an XZ file you receive .SYS file related error message, the problem could probably be associated with corrupted or outdated device drivers that need to be updated. This process can be facilitated by using driver update software such as DriverDoc.


If the steps didn't solve the problem and you are still having problems opening XZ files, this may be due to lack of available system resources. Some versions of XZ files may require a significant amount of resources (e.g. memory/RAM, computing power) to open properly on your computer. This problem occurs quite often if you are using a fairly old computer. Hardware and at the same time a much newer operating system.

This problem can occur when the computer is having a hard time completing a task because operating system(and other services running in the background) can consume too many resources to open XZ file. Try closing all applications on your PC before opening XZ Compressed Archive. By freeing up all available resources on your computer, you will provide the best conditions for trying to open the XZ file.


If you completed all the above steps and your XZ file still won't open, you may need to run hardware upgrade. In most cases, even with older hardware versions, the processing power can still be more than enough for most user applications (unless you're doing a lot of CPU-intensive work like 3D rendering, financial/science modeling, or intense media work) . In this way, it is likely that your computer does not have enough memory(more commonly referred to as "RAM", or RAM) to perform the file open task.

These days we come across archive files very often and on all platforms: Windows, Mac or Linux. These may be programs backups systems or databases, or just an archive of files. We also often need to create our archives in Linux in order to transfer a few files to friends or upload to a file hosting service. Software packages are distributed in the form of archives, source codes, as well as many other files distributed on the Internet. Learning how to archive files in Linux through the terminal is very important, you may need this when you do not have access to the graphical interface, or it just becomes more pleasant to work in the terminal over time.

In this tutorial, I want to take a closer look at archiving utilities in Linux, we will consider not only the most popular and versatile utility - tar, but also other lesser-known, as well as popular compression algorithms.

It is important to note that linux archiving is not the same as linux file compression. Archiving is the combination of several small files into one for the purpose of more convenient subsequent transmission, storage, encryption or compression. As I said, archiving is performed by special utilities. We will not touch the archiving of files in GUI, you will deal with them yourself, our topic is the terminal.

The most popular archiving utility for Linux is tar. It is used almost everywhere, for archiving sources, packaging packages. Other utilities are used for compression, depending on the compression algorithm, for example, zip, bz, xz, lzma, etc. First, archiving is performed, then compression, by separate programs. The automatic launch of some compression utilities for a newly created archive is supported in tar and other similar programs using special options.

Also useful opportunity archiving is encrypted. But now let's look at what utilities exist that archive linux files and how to use them.

Tar

Tar is the standard utility for archiving Linux files. Gradually from small program archiving, it has become a powerful tool that supports many types of archives and compression algorithms. The program supports a large number of parameters. Let's look at its syntax and main parameters:

$ tar options f file_to_write /folder_files_for_archive

Now let's look at the main options:

  • A- add file to archive
  • c- create archive in linux
  • d- compare archive files and unpacked files in the file system
  • j- compress the archive with Bzip
  • z- compress the archive with Gzip
  • r- add files to the end of the archive
  • t- show the contents of the archive
  • u- update the archive relative to the file system
  • x- extract files from archive
  • v- show detailed information about the work process
  • f- file for archive recording
  • -C- unpack to the specified folder
  • --strip-components- discard n subfolders

Now let's look at archiving files in Linux. To create an archive, use the following command:

tar -cvf archive.tar.gz /path/to/files

And to unpack the tar linux archive:

tar -xvf archive.tar.gz

Very easy to remember for packaging option is used c - C reate, and for unpacking - x- e X tract.

A compressed archive is created in the same way, only with the -z option, this is if gizp encryption was used, if bzip is needed, then the -j option is used:

tar -zcvf archive.tar.gz /path/to/files

$ tar -zxvf archive.tar.gz

For example, consider how to zip a folder in Linux:

tar -zcvf home.tar.gz ~/

Although we can do it the other way around, we get the same archive if we first create a regular archive with tar and then compress it with a compression utility, only here we get more control over the compression process:

gzip archive.tar

You can also remove compression:

gunzip archive.tar.gz

Compression utilities will be discussed below.

To add a file to an archive use:

tar -rvf archive.tar file.txt

To extract a single file, the syntax is the same:

tar -xvf archive.tar file.txt

It is possible to extract multiple files by matching pattern using the wildcard parameter, for example, extract all php files:

tar -xvf archive.tar --wildcards "*.php"

By default, you can unpack a tar linux archive to the current folder with the name of the archive to unpack to desired folder use the -C switch:

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

We have considered the standard utility, now we will briefly consider its alternatives. There are not many of them, and most of them are already outdated.

Shar

Shar allows you to create self-extracting archives. It's basically a shell script and needs to be unzipped bash shell or another compatible with Bourne Shell. Shar has several advantages, but it is also potentially insecure because the archive is an executable file.

shar options:

  • -o- save archive to file instead of stdout
  • -l- limit output file size
  • -L- limit output file size and split it into parts
  • -n- the archive name will not be included in the header
  • -a- enable automatic header generation

Examples of using shar to archive a linux folder:

Create a shar archive:

shar file_name.extension > filename.shar

Unpack the shar archive:

Ar

ar is a utility for creating and managing archives. Mainly used for archiving static libraries, but can be used to create any kind of archive. It used to be used quite often but has been superseded by the tar utility. Currently only used to create and update static library files.

  • -d- remove modules from the archive
  • - m- moving members in the archive
  • -p- print specific members of the archive
  • - q- quick add
  • -r- add member to archive
  • -s- create archive index
  • -a- add new file to an existing archive

Now let's look at usage examples. Let's create a static library libmath.a from object files substraction.o and division.o:

ar cr libmath.a substraction.o division.o

Now let's extract the files from the archive:

Thus, any static library can be unpacked.

cpio

cpio stands for Copy in and out. This is another standard archiver for Linux. It is actively used in the Red Hat package manager, as well as for creating initramfs. Archiving in Linux for regular files using this program is not applicable.

Utility options:

  • -a- reset file access time after copying them
  • -A- to add a file
  • -d- create directories if necessary

Usage example. Create a cpio archive:

file1.o file2.o file3.o

ls | cpio -ov > /path/to/output_folder/obj.cpio

Unpack the archive:

cpio-idv< /path/to folder/obj.cpio

Archiving the linux folder is also done by itself.

Compressing archives in Linux

How to create an archive in linux was considered. Now let's talk about compression. As I said, for compression are used special utilities. Let's briefly consider a few of them.

Gzip

The most commonly used is Gzip. This is the standard Unix/Linux compression utility. For decompression use gunzip or gzip -d Let's look at its syntax first:

$ gzip options file

$ gunzip options file

Now let's look at the options:

  • -c- output archive to standard output
  • -d- unpack
  • -f- force decompress or compress
  • -l- show archive information
  • -r- recursively iterate over directories
  • -0 - minimum compression level
  • -9 - maximum compression level

You have already seen examples of usage in the description of the tar utility. For example, let's compress a file:

gzip -c file > archive.gz

Now let's unpack:

gunzip -c archive.gz

But in order to compress a folder in Linux, you have to first zip it with tar and then compress the archive file with gzip.

bzip

bzip2 is another alternative compression utility for Linux. It is more efficient than gzip, but slower. To unpack, use the bunzip2 utility.

I will not describe bzip2 options, they are similar to gzip. To create an archive on Linux use:

The file file.bz2 will be created in the current directory

Lzma

New and highly efficient compression algorithm. The syntax and options are also similar to Gzip. Use unlzma to unpack.

xz

Another highly efficient compression algorithm. Backwards compatible with Lzma. Call parameters are also similar to Gzip.

Zip

Cross-platform utility for creating compressed zip archives. Compatible with Windows implementations of this algorithm. Zip archives are very often used to share files on the Internet. With this utility, you can compress both files and compress the linux folder.

Utility syntax:

$ zip options files

$ unzip archive options

Utility options:

  • -d remove file from archive
  • -r- traverse directories recursively
  • -0 - archive only, no compression
  • -9 - best compression ratio
  • -F- fix zip file
  • -e- encrypt files

To create a Zip archive in Linux use.

Recently I downloaded an image of a fresh 8.2 fry, I was surprised when I saw that the image was packed in .xz, I had never heard of such an archive format before, it turns out that XZ is a compressed data format that uses the LZMA2 algorithm and is designed to replace the LZMA format. Like the gzip and bzip2 formats, it is a single file container, so it is usually used in conjunction with the tar format.

Out of habit, I tried to unpack WinRar, to which I received a response from him, saying that the archive is broken, or is not an archive 🙁 sad!

In tyrnet I found one DOS utility for unpacking such archives, leaked it to myself, well, and posted it on my website, because. These are things you need to have on hand.

We unpack the archiver, throw the xz.exe file into system32, unless of course we want to use it calmly, without entering the full path to it.
Working with the utility is very simple, for example, unpacking a fresh distribution kit:

Xz -d u:\FreeBSD-8.2-RELEASE-amd64-dvd1.iso.xz

You can also view all command keys:

C:\xz --help Usage: xz ... ... Compress or decompress FILEs in the .xz format. -z, --compress compression strength -d, --decompress decompression strength -t, --test check integrity of compressed file -l, --list list information about .xz files -k, --keep save (don't delete) input files -f, --force forced overwriting of output file and (de)compression of references -c, --stdout write to stdout and don't delete input files -0 ... -9 compression preset; default 6; use compressor *and* use decompressor memory before using 7-9! -e, --extreme try to improve the compression ratio using more CPU time; does not affect decompressor memory requirements -q, --quiet suppress warnings; specify twice to suppress errors -v, --verbose be verbose; specify twice for even more detailed reports -h, --help display this short help and exit -H, --long-help display long help (also lists advanced options) -V, --version display version number and exit

Well, how's everything)
Enjoy using the utility!)

Many probably already know about the compression / decompression utility xz. But they don't know more. That's why I wrote this introductory thread.

Xz is a data compression format, along with gzip, bzip2 included in gnu applications.
It uses the LZMA algorithm, the same as in 7z, which means that it is possible to compress many types of data, such as text, binary not yet compressed data, compared to the standard ones mentioned above.
xz is used in the new rpm 4.7.2 to compress .cpio archives in rpm packages (used since Fedora 12).
ArchLinux generally uses .tar.xz as a package.
GNU tar has -J --lzma options, which perform the same role as -z for gzip, -j for bzip2

Pros:
High degree compression

Minuses:
high resource consumption:
cpu time (and actual compression time)
memory (configurable, but still more than gzip, bzip2).
In particular, xz for --best aka -9 consumes up to 700mb! on compression and 90MB on decompression

Features:
The consumption of a large amount of memory is slightly limited by the precomputation of available resources.
integration into GNU tar
work with streams
optional: progressbar via --verbose

I don’t want to clog the introductory topic with charts and other things, but you can’t do without it:
Made a banal run gzip, bzip2, xz regarding the degree of compression, time consumption. WinRar will also take part as a guest (although intoxicated, under wine, it still showed excellent results)

We get 4 squares:
Bottom left - slow and weak: gzip and winrar fastest.
Top left: winning compression/time ratio: bzip2 performs slightly better, xz at compression levels 1 and 2, and
Top right: real press mechanism: long but very tight xz
In the lower right: there is no one, and who needs a long-running and low-compressive archiver?

But in general, the coordinate grid is not well chosen: how do we evaluate time? categories! for example, fast - 10-20 seconds, average from half a minute to a minute, more than 2 minutes - this is a long time.
so the logarithmic scale is clearer here:

And if if we evaluate them as stream compression, on my Core2Duo E6750 @ 2.66GHz,
then the graph looks like this:


those. Using the gzip -1 or gzip -4 pipeline as a compressor, you can drive up to 25 MB / s of uncompressed data in a 100Mbps network. (checked several times - gzip -4 for some reason gives more profit than -3 or -5)
cat /some/data | gzip -1c | ssh [email protected]-c "gzip -dc > /some/data"
xz can only be used on channels<8мбит,

The Obvious Conclusion (Assisted by K.O.)
xz- in view of resource consumption, it occupies a niche of compressor archivers, where the compression ratio can play a big role, and there is enough computing resource and time resource. those. various kinds of backups / archives, distributions (rpm, tar.xz in archlinux). Or data that is very easily compressed: logs, tables with text-numeric csv, tsv data that are not supposed to be changed.

P.S. No matter how happy for xz, WinRar Wins is in the reasonableness of the efforts spent.