Linux Commands

Managing Archives with Atool Linux Utility

There are various tools that you can use to manage the archive files when using Linux. However, most of the tools are limited to specific archive formats. Luckily, you can use the atool utility, a Perl script available for managing Linux archives and supports multiple formats.

The good thing with atool is that it has different commands such as aunpack, which extract files in an organized manner. Besides, it’s not the only available atool command, and we will go through all the available options and how you can use them for your archive files.

How to Use Atool Linux Command

To use the atool Perl script commands, you need to install the utility from the package manager. Use the following command to install it:

$ sudo apt install atool


Once installed, you can begin by checking the available options that you can use from the help page. It has two sections: the commands section and the options section. The commands can be written in different ways. For instance, a command like atool -x is the same as using aunpack. We will see the usage examples in the succeeding discussion.

The atool command can handle different file archives, including bzip, tar.7z, tar.gz, jar, rar, gzip, deb, etc.

Atool Commands

Atool has various options, and they can all be combined with the different commands.

1. acat

The acat command is used for viewing the contents of a file in an archive. You can access the same command by typing atool -c. In this example, we will use the names.zip archive file.

$ acat names.zip test.txt

The following output displays the contents of a file, test.txt:

2. aunpack

Using the aunpack is similar to using atool –x. It extracts the contents of an archive file in the current directory.

To extract our zip file, use the following command:

$ aunpack names.zip

or

$ atool -x names.zip

Once extracted, we now have a directory with the archive’s contents. In our case, we have the names directory.

3. als

To list the files in the archive file, use the als or atool -l command.

$ als names.zip

The output displays the length of the file, the date and time created, and the total number of files in the archive.

4. apack

You can also create an archive file of any extension using the apack or atoola command. For instance, let’s make a .tar.gz archive using the following command. You need to have the files you need to zip first.

$ apack example.tar.gz names/

We’ve created an example.tar.gz archive.

5. adiff

You can also check the difference between the archive files using the atool -d or adiff command. Besides, the archive files don’t need to have the same extension. In the following example, we will compare a “.zip” and a “.tar.gz” archive to see the difference. Plus, we will add the -v option to add more verbosity.

$ adiff -v names.zip example.tar.gz

From the following output, we see that the archive has some same files, except that the archive numbered 4706, which is the names.zip, has two unique files.


That’s how you can see the difference in the archive files.

6. arepack

At times, you may need to create the same archive file but in a different format. For instance, a “.7z” from a “.zip”. Atool offers the arepack command, which does the job for you. It creates a temporary directory first to extract the original archive and then uses that temporary directory to create the new archive file with the new extension. Let’s check it out.

$ arepack names.zip new1.7z

In our case, we are creating a new1.7z archive from our names.zip. The output will be:


All of the previous commands can be combined with different options provided by atool. The most common options that you will come across include the following:

S: The option runs the command in simulation mode. It shows what will happen without executing the command, and it comes in handy if you are unsure of the changes you want to make.

For instance, if you try to create an archive in simulation mode, you will see an output such as the following:

-E: The options show the commands executing in the background. It explains the command you’ve entered.

In the following output, the command displays the contents of a file in the archive file:

1. -v: To add verbosity when running a command, add the -v option. The opposite is -q, which executes in a quiet mode.
2. -D: You can forcefully create a new directory anytime the files are extracted using the -D flag. In the following example, we’ve extracted names.zip, and a new directory named Unpack-3280 was created:
3. -f: The -f flag forcefully overwrites local files when extracting an archive.

You can run the help option for more options to view them, but the ones listed above are the common ones you will likely encounter.

Conclusion

By using the atool Linux command, you now have a quick and effective way of dealing with archive files of any format. The commands and options available are helpful to achieving all your archive manipulation tasks, and you will easily feel at home with the tool.

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.