Debian packages are the most famous packages in all of Linux. 9 times out of 10 when someone is moving a program over to Linux, they’re putting out as a Debian package i.e., a DEB file. Having Linux support, even if it’s only with one type of Linux distribution is nice. That said, not every Linux distribution is designed to run these packages.Â In this article, we’ll be going over a fool-proof way to install a Debian package and make the program work on your Linux distribution.
No “converting” will take place in this guide. Instead, just extracting the data and moving it around. To get started, download a Debian package. In this example, we’ll work with the Google Chrome package. Though this guide focuses on the Google Chrome Debian package, it is a proof of concept. Take the method shown here and apply it to install a Debian package.
Most Linux users don’t realize that DEB packages are just fancy archive files that are extractable. Download the Debian package you want to install and extract it. In this case, we have the Chrome package, downloaded, and extracted on our system. Open up a terminal window and use theÂ mkdirÂ command to make a new folder. This folder will hold all of the package data we need.
mkdir -p ~/deb-extracted
Using mv, put the Chrome file into the new folder.
mvÂ google-chrome-stable_current_amd64.deb ~/deb-extracted
CD into the new folder, and use theÂ arÂ tool to inspect the Chrome package.
‘); if (navigator.appVersion.indexOf(“Mac”)!=-1) document.write(”);
cd ~/deb-extracted ar tvÂ google-chrome-stable_current_amd64.deb
Ar inspects the Chrome DEB file and lets us know there are three compressed files inside. These files are the “debian-binary”, “control.tar.gz”, and “data.tar.xz”. All the data we need is in the data.tar.xz archive, but “control.tar.gz” is also important.
The Ar tool doesn’t just inspect archives. It can also extract them. UseÂ ar xvÂ to extract the three items out ofÂ google-chrome-stable_current_amd64.deb.
ar xvÂ google-chrome-stable_current_amd64.deb
All three items should now be insideÂ ~/deb-extracted. Use theÂ rmÂ command to remove “debian-binary”. It’s not necessary, as we are not using Debian Linux.
From here, we’ll need to extract the file data fromÂ data.tar.xz. It contains everything required to run Chrome as a program on Linux. Extract it to the folder withÂ tar.
tar -xvfÂ data.tar.xz
Extracting the data archive will output 3 folders. The folders are “opt”, “usr” and “etc”.
UsingÂ rm -rf, delete theÂ etc folder. Items in this folder aren’t needed, as it is a Debian update job to check for updates.
Note: Don’t a / in front of the command below. You might accidentally delete /etc/, and not the etc folder extracted in ~/deb-extracted.
rm -rf etc
Next, move the files inside ofÂ usrÂ andÂ optÂ files to where they belong on the PC. For example, to install Google Chrome on a non-Debian Linux distribution, you’d move the files to where they belong, manually:
cd opt sudo -s mv google /opt/ ln -snf /opt/google/google-chrome /usr/bin/ cd ..Â share mv -f * /usr/share/
The above example shows exactly what to do with extracted files fromÂ data.tar.xz. Obviously, other Debian packages might have contents inside the extracted folder that are different from the ones you see in this tutorial. The idea is to look at the folder names inside of aÂ data.tar.xz archive, and pay attention to the names. The folders inside have the same names as folders on your Linux PC’s filesystem, and the items inside go to those locations.
Finding Package Instructions
Sometimes decompiling a Debian package and extracting theÂ data.tar.xz archive isn’t enough and you’re still left confused. Luckily, each Debian package file comes with a set of instructions. These instructions are inside of theÂ control.tar.gz.
Extract theÂ control.tar.gzÂ archive to theÂ ~/deb-extractedÂ folder with theÂ tar command.
tar -xvzfÂ control.tar.gz
The control.tar.gz archive has a lot of scripts that tell the Debian package what to do. The one we’re interested in is labeled “postinst”. Postinst is short for “post installation”, a bash script that runs and puts everything where it needs to go.
In the terminal use theÂ catÂ command to view the text file. Combine it with “more” to view it line by line. Inspect the “postinst” file and pay attention to what the script is doing, especially where it’s putting files. This will help you figure out where the items insideÂ data.tar.xz belong, and what they do.
cat postinst | more
Decompiling a Debian package and moving the data files to the right places often isn’t enough. Sometimes, you’ll need to install the right dependency files or nothing works. Luckily, each Debian package has a small file inÂ control.tar.gz, outlining a detailed list of important library files the user must install for everything to work. To view this file,Â useÂ cat.
cat control | more
For example, to use Google Chrome, the control file asks for ca-certificates, fonts-liberation, libappindicator1, libasound2,Â libatk-bridge2.0-0, and other items.
Read through this file carefully, and use it to install the individual libraries on your Linux PC. When the correct programs are on your PC, the extracted program should work like normal.
If you’re running a Redhat-based Linux system, follow our guide to install a Debian package on it.