Create a Debian (.deb) Package (Hello World)
This is a minimal, real example you can use immediately.
We will package one shell script into a .deb and install it with dpkg.
1) Create package folder layout
mkdir -p hello-deb_1.0.0/{DEBIAN,usr/local/bin}
2) Add the Hello World script
Create hello-deb_1.0.0/usr/local/bin/hello-deb:
#!/bin/sh
echo "Hello from my .deb package"
Make it executable:
chmod 755 hello-deb_1.0.0/usr/local/bin/hello-deb
3) Add package metadata (control file)
Create hello-deb_1.0.0/DEBIAN/control:
Package: hello-deb
Version: 1.0.0
Section: utils
Priority: optional
Architecture: all
Maintainer: Your Name <you@example.com>
Description: Minimal hello world package example
Set permissions for metadata:
chmod 755 hello-deb_1.0.0/DEBIAN
chmod 644 hello-deb_1.0.0/DEBIAN/control
4) Build the .deb
dpkg-deb --build hello-deb_1.0.0
Output file:
hello-deb_1.0.0.deb
5) Install and test
sudo dpkg -i hello-deb_1.0.0.deb
hello-deb
Expected output:
Hello from my .deb package
6) Remove package
sudo dpkg -r hello-deb
Quick notes
- If you update the script, bump
Versionbefore rebuilding. - Use
dpkg-deb -c hello-deb_1.0.0.debto inspect package contents. - This same structure works for real tools, not only Hello World.