Linux Knowledge Base
Create a .deb to distribute a shell script
Step 1: Directory Structure
.debpackages expect files to be arranged like they will appear on the target system.- Commonly, scripts go in
/usr/local/binor/usr/bin.
mkdir -v mypackage cd mypackage mkdir -v DEBIAN mkdir -pv usr/local/bin
Step 2: Copy your script — without extension — into usr/local/bin/ and make it executable
chmod +x usr/local/bin/myscript
Step 3: Create the Control File
Inside the DEBIAN directory, make a control file:
Package: myscript Version: 1.0.0 Section: utils Priority: optional Architecture: all Maintainer: Your Name <youremail@example.com> Description: My sample shell script
Step 4: Build the Package
Navigate to the your package's parent directory and build:
dpkg-deb --build mypackage
This creates mypackage.deb.
Step 5: Install the package
sudo dpkg -i mypackage.deb