indeb - Bash script to install .deb packages

Endrit Qerreti

Endrit Qerreti

Installing .deb packages on linux is easy, however sometimes it can be time consuming when installing them via the terminal, especially when you have a lot of files to go through to find the .deb file that you want to install.

Indeb(Install .deb), is a simple bash script that I wrote that installs the .deb package automatically without having to type anything on terminal, all you have to do is run ./indeb.sh and then set the package name and press enter, this can be a filename.deb or the directory where the .deb file is located, example : /home/owlhowto/downloads/myfil.deb

How does indeb.sh work?

1) You run the bash script ./indeb.sh

2) Indeb lists all .deb files located under the directory from where you launched indeb.sh, to make it easier to copy and paste the file name that you want to install. Assuming the downloads folder is default folder where you download stuff, then you can execute indeb.sh on the same location.

3) You enter the .deb filename and press enter

4) Indeb installs it on your system

#!/bin/bash


#Indeb - Install .deb packages on debian based system
#Written by : Endrit Qerreti
#Version : 1.0
#Copyright (c) 2023 Endrit Qerreti



blue=$(tput setaf 4)
red=$(tput setaf 1)
white=$(tput setaf 7)
yellow=$(tput setaf 3)
reset=$(tput sgr0)


cat <<EOF

███████████████████████████████
█▄─▄█▄─▀█▄─▄█▄─▄▄▀█▄─▄▄─█▄─▄─▀█
██─███─█▄▀─███─██─██─▄█▀██─▄─▀█
▀▄▄▄▀▄▄▄▀▀▄▄▀▄▄▄▄▀▀▄▄▄▄▄▀▄▄▄▄▀▀

Install .deb packages on debian based system
EOF





lsdeb=$(ls *.deb 2>/dev/null) 

if [[ -z "$lsdeb" ]];
then

echo -e "\n${red}no deb file was found${reset}" 
echo -e "\n${white}add the deb file and start indeb again${reset}\n"

else

echo -e "${yellow}\nDeb files found: \n $lsdeb ${reset}\n" 


read -p "Enter ${blue}.deb${blue}${reset} package name and press enter:  " deb

if [[ $deb == *.deb* ]];
then

echo -e "\n$deb Selected\n"

echo -e "\n${white}Installing${white} ${yellow} $deb${yellow} ...${reset}\n"

install_deb=$(sudo dpkg -i $deb)
echo -e "\nInstallation completed\n"
else
echo -e "\n${red}[x]This is not a .deb file${reset}\n"
exit 1

echo -e "\n${red}[x]This is not a .deb file${reset}\n"
exit 1

fi 
fi



How to use indeb.sh

Step 1 - Make indeb.sh executable

Run the command below to make indeb.sh executable

chmod +x indeb.sh

Step 2 - Run indeb.sh

Next, run the script

./indeb.sh

Note: Since the script will check for the deb files located on the same directory from where you are running indeb, then I'd suggest you run indeb from the download folder.

Once you run indeb, the app will list the deb files found on the same folder, you can copy and paste the name of the file that is being showed on the terminal and press enter, then indeb will install that package.

If the package is not a valid .deb file, the app will exit and you will need to run it again in order to install it.  For example, in the folder that I ran indeb I had only virtualbox-7.0_7.0.8-156879Debianbullseye_amd64.deb

You can also set the direct path of the deb file instead of the package name. The direct path looks like this

/home/owlhowto/Downloads/virtualbox-7.0_7.0.8-156879~Debian~bullseye_amd64.deb

And press enter to start the installation process

On this step, you will need to enter your sudo password in order to be able to install the selected .deb package. To avoid this, you can run indeb.sh as sudo and then the app will not ask you to authenticate again.

sudo ./indeb.sh

Conclusion

indeb is a simple bash script that installs the .deb packages on debian based linux distros.