Building and installing a ‘.deb’ package that adds an executable script to all users

This is a part two (link to part one) for my home assignment for Tero Karvinen’s course on linux servers. On this part I will build and install a package that will add an executable shell script and an alias for it for all users.

Now to create a new package with a shell script file.

mkdir mmm-command
cd mmm-command
equivs-control mmm-command

The ‘equivs-control’ command creates a file called ‘mmm-command’, which contains the basic structure for a ‘.deb’ package.

The content I replaced in  ‘mmm-command’ (I removed the other ones, which are not so relevant):

Section: misc
Priority: optional
Standards-Version: 3.9.2

Package: mmm-command
Version: 0.0.1
Maintainer: Miro Metsänheimo <>
Files: /bin # Copy the command file to the bin folder for use of all users
Postinst: # Run the install script to make the alias after installation
Architecture: all
Description: My new command
 My new command

Here we have two lines that do something crucial:

  • Files: list of files to be installed and compiled in to the ‘.deb’ package.
  • Postinst: a script to run after the installation

Then we create the ‘’ file mentioned above with the content:

echo "An example scipt that installs with my .deb package to all users."

This file is just a simple echo line just to make sure the script works.

And then the ‘’ file with the content:


# If the file doesn't exist, create it
if [ ! -f /etc/profile.d/ ]
 touch /etc/profile.d/
# Append the alias to the created file
echo "alias mmm-command='/bin/'" >> /etc/profile.d/
source /etc/profile # Reload the commands

Here we create a new file in the ‘profile.d’, because this will last longer and works after updates. The ’00-‘ is to make sure the script is ran first.

And then we build the package creating a file called ‘mmm-command_0.0.1_all.deb’ and install the package with ‘gdebi’:

equivs-build mmm-command
sudo gdebi mmm-command_0.0.1_all.deb

And then a tryout:

xubuntu@xubuntu:/$ mmm-command
An example scipt that installs with my .deb package to all users.



Class by Tero Karvinen

SH command in a package

Alias for all users

Shell IF


Miro Metsänheimo

A software developer from Finland born in -92. I'm passionate about computers and technology. Feel free to message me about anything!


Leave a Reply