Do you want to convert a Linux package to some other format? Perhaps the package you're looking for isn't available for your distro but you still want it no matter what. Or maybe you are a developer and want to save your time by quickly repackaging your program to other formats without having to build the package again.

Fortunately, Linux has got the tool you need. With Alien, you can easily convert your existing Linux package to other formats through the command line. Let's start by installing the tool on your system first.

How to Install Alien on Linux

Alien is available in the Ubuntu universe repository. To install it, first enable the universe repository and update your system's package list. Then, install the alien package using APT as you'd normally do.

        sudo add-apt-repository universe
sudo apt update
sudo apt install alien

Debian users can simply install the package using APT:

        sudo apt install alien
    

Alien isn't available in the official Arch repositories yet. However, you can install it from the AUR using an AUR helper. For the purpose of this guide, we'll use yay.

        yay -S alien
    

On Fedora, CentOS, and other RPM-based distros, you can install Alien using DNF as follows:

        sudo dnf install alien
    

Once done, verify the installation by typing alien --version in the terminal. If the command returns version information for the package, the installation is successful. However, if not, try going through the installation steps again.

Convert Between Linux Packages Using Alien

Using Alien, you can convert between a number of Linux packages. To list a few:

  1. DEB (Debian-based distros)
  2. TAR.GZ (Packaged Archive)
  3. RPM (Fedora, CentOS, and other distros)
  4. PKG (Solaris package format)
  5. SLP
  6. LSB

Alien can interpret the following options:

  1. -d or --to-dpkg: Convert the specified package to the DEB package format
  2. -r or --to-rpm: Convert the package to RPM format
  3. -t or --to-tgz: Generate a TAR.GZ archive file from the specified package
  4. -l or --to-lsb: Create an LSB (Linux Standard Base) package
  5. -p or --to-pkg: Convert the specified package to the PKG format
  6. --to-slp: Create an SLP package

Related: How to List Installed Packages in Ubuntu Using APT

How to Use Alien on Linux

The basic syntax of the utility is:

        sudo alien options filename
    

...where options are the various flags you can use with the command and filename is the absolute or relative path to the package you want to convert.

To convert an RPM package to DEB:

        sudo alien --d file.rpm
sudo alien --to-deb file.rpm

To demonstrate how you can convert a package to all the other formats, we will convert a DEB file to other Linux packages.

DEB to RPM:

        sudo alien -r file.deb
sudo alien --to-rpm file.deb

DEB to TAR.GZ:

        sudo alien -t file.deb
sudo alien --to-tgz file.deb

DEB to LSB: sudo alien -l file.deb sudo alien --to-lsb file.deb DEB to PKG:

        sudo alien -p file.deb
sudo alien --to-pkg file.deb

DEB to SLP:

        sudo alien --to-slp file.deb
    

Note that you can also convert any package format to any other format. For example, RPM to LSB, SLP to PKG, PKG to DEB, etc.

Converting a package to multiple formats using a single command is also possible. All you have to do is specify the flags for the conversion as follows:

        sudo alien --to-deb --to-rpm --to-tgz file.pkg
sudo alien -d -r -p file.tar.gz

If the package contains scripts specific to the format, you can convert those scripts using the --scripts or -c flag.

        sudo alien --scripts --to-deb file.rpm
sudo alien -c --to-deb file.rpm

Install Packages After Conversion

Apart from converting packages, Alien can also install the packages for you. You can add the --install or -i flag with the command to immediately install the package after conversion.

For example:

        sudo alien --to-rpm --install file.deb
sudo alien -r -i file.deb

Handling Version Information During Conversion

By default, Alien automatically increments the version details of the package. If you convert a package with version number 1.17.1 using Alien, the generated package will have version number 1.17.2.

You can override this default behavior using the -k or --keep-version flag as follows:

        sudo alien --to-rpm -k file.deb
sudo alien --to-rpm --keep-version file.deb

You Can Now Convert Packages in Linux

As a developer, rebuilding a package for different Linux distros can be tough. To tackle this issue, you can use Alien to convert your package to other Linux formats easily.

Although Alien is a reliable utility, it is not recommended if you want to properly develop native packages for distros. Also, while publishing a package, you should always list down the dependencies required by the program.