Creating a deb file
Debian and/or Ubuntu  --  By Rodney Richison

(This is an example to create a deb for the tool "vboxtool" which is a collection of scripts to manage virtualbox)
(It's just an example of how one can setup scripts to run at startup, quickly installable via a .deb file)

Create two directories

mkdir -p ~/vboxtool-0.3/debian

Go to parent directory

cd ~/vboxtool-0.3/

Create a file called


Insert below in the file


control_files="control changelog postinst postrm"
# Files to be installed relevent to destination
data_dirs="usr/sbin/ etc/"

cd $package_dir

# write the control file
cat > control <<END
Package: vboxtool
Version: 0.3
Installed-Size: 32
Priority: optional
Section: base
Essential: NO
Recommends: virtualbox
Architecture: all
Maintainer: Rodney Richison []
Description: Tools for managing virtualbox. Feature auto-start at boot, backup, etc..

cat > changelog <<END
vboxtool (0.3) unstable; urgency=low

  * Initial Release.

 -- Rodney Richison <>  Sat, 25 Oct 2008 08:44:50 -0500

# write the post-installation script
cat > postinst <<END
update-rc.d vboxtoolinit defaults 99 10

echo VBoxTool Installed..
echo You MUST edit BOTH /etc/vboxtool config files.

# write the post-removal script
cat > postrm <<END
update-rc.d -f vboxtoolinit remove

# *********************************************

# create the data tarball
# (the tar options "czvf" mean create, zip, verbose, and filename.)
tar czvf data.tar.gz $data_dirs
#usr/sbin/ etc/

# create the control tarball
tar czvf control.tar.gz $control_files
# control changelog postinst postrm

# create the debian-binary file
echo 2.0 > debian-binary

# create the ar (deb) archive
ar -r $package_name debian-binary control.tar.gz data.tar.gz

# move the new deb up a directory
mv $package_name ..

# remove the tarballs, and cd back up to where we started
rm data.tar.gz control.tar.gz
cd ..
#************* End of ***************************

Of course, edit the file for correct path etc..

Now let's download vboxtool
# Current version on 10/25/08

make a directory for the /etc/ and /usr/
mkdir -p ~/vboxtool-0.3/debian/usr/sbin
mkdir -p ~/vboxtool-0.3/debian/etc/init.d
mkdir -p ~/vboxtool-0.3/debian/etc/vboxtool

Copy files from the vboxtool zip file you downloaded

cp vboxtool ~/vboxtool-0.3/debian/usr/sbin/
cp vboxtoolinit ~/vboxtool-0.3/debian/etc/init.d/
cp changelog.txt ~/vboxtool-0.3/debian/etc/vboxtool/
cp copying.txt ~/vboxtool-0.3/debian/etc/vboxtool/
cp machines.conf ~/vboxtool-0.3/debian/etc/vboxtool/
cp readme.txt ~/vboxtool-0.3/debian/etc/vboxtool/
cp vboxtool.conf  ~/vboxtool-0.3/debian/etc/vboxtool/

This should finish the directory structure.

You should now have something like this

                        ---> vboxtoolinit
                        ---> changelog.txt copying.txt machines.conf readme.txt vboxtool.conf

This is the directory structure template for you .deb file.

Now, go back to the vboxtoo-0.3 directory and run it (make sure to edit this file with your file path prefs.

chmod 755

You should have a .deb file now..

NOTE: your see the create_deb script creates some files like postinst and preinst. These are very useful for commands that should be run after install or after removal etc..  There are other files you can have, but that's enough material for this short tutorial..