In Ubuntu Linux, software is distributed as a .deb package. Normally, you use a command like sudo apt install file.deb to unpack the software and merge it into your core system files. However, if you download a suspicious .deb file from an untrusted forum, you might not want to install it.
You might simply want to peek inside the package to see what shell scripts it intends to run or extract a single icon file trapped inside. A .deb file is essentially just a specialized ZIP archive. You can safely extract its contents into a standard folder on your desktop without triggering the installation process or requiring administrator privileges.
How to Safely Extract Ubuntu .deb Package Contents Without Installing
You must use the `dpkg-deb` utility to extract the raw archive into a sandbox folder.
- Open your Terminal application (Ctrl + Alt + T).
- Navigate to the folder containing your downloaded package (e.g.,
cd ~/Downloads). - First, create a brand new, empty “sandbox” directory where you will dump the extracted files. Type this command and press Enter:
mkdir extracted_package - To safely rip open the `.deb` file and dump its contents into your new folder, type the following command (replace
filename.debwith the actual package name):dpkg-deb -R filename.deb extracted_package/ - Press Enter. Note that you do not use the
sudocommand here. This guarantees the package cannot modify your system.
The extraction is instantaneous. Open your file manager and look inside the new extracted_package folder. You will see the complete internal structure of the software.
Specifically, look inside the DEBIAN folder to read the postinst and preinst shell scripts to see exactly what commands the software would have executed if you had installed it. You can also browse the usr/bin folder to extract the raw executable binaries. Because you didn’t install the package, your Ubuntu system remains completely untouched and perfectly safe.