Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A shellscript to create a Postman .deb file, for simple installation on Debian-based Linux distro's. Also creates a .desktop file.

Copy and paste this line into your terminal to run the script:

curl | sh

Or this line if you don't have curl:

wget -O - | sh
curlExists=$(command -v curl)
echo "Testing Postman version"
if [ -z $curlExists ]; then
targetName=$(wget -S --spider "" 2>&1 | grep "Content-Disposition" | awk -F '=' '{ print $2 }')
targetName=$(curl -sI "" | grep "content-disposition" | awk -F '=' '{ print $2 }')
versionMaj=$(echo "$targetName" | awk -F '-' '{ print $2 }' | awk -F '.' '{ print $1 }')
versionMin=$(echo "$targetName" | awk -F '-' '{ print $2 }' | awk -F '.' '{ print $2 }')
versionRev=$(echo "$targetName" | awk -F '-' '{ print $2 }' | awk -F '.' '{ print $3 }')
echo "Most recent Postman version V$version"
current=$(dpkg-query --showformat='${Version}' --show postman 2> /dev/null)
if [ $? -gt 0 ]; then
echo "Postman is not installed"
echo "Installed version V$current"
if [ "$current" = "$version" ]; then
echo "The most recent version of Postman is currently installed"
echo "Updating Postman to the latest version"
targetPWD="$(mktemp -d postman.XXXXXX)"
cd "$targetPWD"
echo "Downloading latest Postman tarball"
if [ -z $curlExists ]; then
wget -q --show-progress "" --content-disposition
curl -# "" -O -J
if [ $? -gt 0 ]; then
echo "Failed to download Postman tarball"
echo "Extracting Postman tarball"
tar -xf $(ls [Pp]ostman*.tar.gz)
if [ $? -gt 0 ]; then
echo "Failed to extract Postman tarball"
echo "Creating 'postman_$version' folder structure and files"
mkdir -m 0755 -p "postman_$version"
mkdir -m 0755 -p "postman_$version/usr/share/applications"
touch "postman_$version/usr/share/applications/Postman.desktop"
mkdir -m 0755 -p "postman_$version/usr/share/icons/hicolor/128x128/apps"
mkdir -m 0755 -p "postman_$version/opt/postman"
mkdir -m 0755 -p "postman_$version/DEBIAN"
touch "postman_$version/DEBIAN/control" "postman_$version/DEBIAN/postinst" "postman_$version/DEBIAN/prerm"
echo "Copying files"
cp "Postman/app/resources/app/assets/icon.png" "postman_$version/usr/share/icons/hicolor/128x128/apps/postman.png"
cp -R "Postman/"* "postman_$version/opt/postman/"
echo "Testing whether to use '-e'"
lines=$(echo "\n" | wc -l)
if [ $lines -eq 1 ]; then
echo "'-e' is required"
echo "'-e' is not required"
echo "Writing files"
echo $e "[Desktop Entry]\nType=Application\nName=Postman\nGenericName=Postman API Tester\nIcon=postman\nExec=postman\nPath=/opt/postman\nCategories=Development;" > "postman_$version/opt/postman/Postman.desktop"
echo $e "Package: Postman\nVersion: $version\nSection: devel\nPriority: optional\nArchitecture: amd64\nDepends: gconf2, libgtk2.0-0, desktop-file-utils\nOptional: libcanberra-gtk-module\nMaintainer: You\nDescription: Postman\n API something" > "postman_$version/DEBIAN/control"
echo $e "if [ -f \"/usr/bin/postman\" ]; then\n\tsudo rm -f \"/usr/bin/postman\"\nfi\n\nsudo ln -s \"/opt/postman/Postman\" \"/usr/bin/postman\"\n\ndesktop-file-install \"/opt/postman/Postman.desktop\"" > "postman_$version/DEBIAN/postinst"
echo $e "if [ -f \"/usr/bin/postman\" ]; then\n\tsudo rm -f \"/usr/bin/postman\"\nfi" > "postman_$version/DEBIAN/prerm"
echo "Setting modes"
chmod 0775 "postman_$version/usr/share/applications/Postman.desktop"
chmod 0775 "postman_$version/DEBIAN/control"
chmod 0775 "postman_$version/DEBIAN/postinst"
chmod 0775 "postman_$version/DEBIAN/prerm"
echo "Validating modes"
if [ $(stat -c "%a" "postman_$version/DEBIAN/control") != "775" ]; then
echo "File modes are invalid, calling 'dpkg-deb' with '--nocheck'"
echo "File modes are valid"
echo "Building 'postman_$version.deb'"
dpkg-deb $nc -b "postman_$version" > /dev/null
if [ $? -gt 0 ]; then
echo "Failed to build 'postman_$version.deb'"
mv "postman_$version.deb" "$originalPWD"
cd "$originalPWD"
echo "Cleaning up"
rm -rf "$targetPWD"
while true; do
read -p "Do you want to install 'postman_$version.deb' [Y/n] " yn
if [ -z $yn ]; then
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
echo "Installing"
sudo apt install -y "./postman_$version.deb"
if [ $? -gt 0 ]; then
echo "Failed to install 'postman_$version.deb'"
echo "Removing 'postman_$version.deb'"
rm -f "postman_$version.deb"
Copy link

fakhamatia commented Apr 21, 2020

Are you using a filesystem that does not support permissions, like NTFS?


Let me know if it still doesn't work.

No, it is OK, thank you 👌 👍

Copy link

lyfewithcode commented Apr 22, 2020

Nice! Thank you :)

Copy link

Victorcasas commented Apr 25, 2020

Thank you very much, it's a very nice shell script!

Copy link

Tantawi commented Jun 6, 2020

You are awesome!! thanks!!

Copy link

me-codes commented Jun 28, 2020

This is awesome thank you!!

Copy link

Killea commented Aug 31, 2020

curl | bash -s -- -e

Could this line be added to the top of this script as a comment?

Copy link

cheirodgato commented Sep 1, 2020


Copy link

SanderTheDragon commented Sep 1, 2020

@Killea I added a curl and wget version as a new file, that way it stands out more than a comment in the script, thanks for the idea!

Copy link

n8eloy commented Sep 1, 2020

Awesome work bro, thank you! 🚀

Just a tip: it may be better to have the -y flag at line 153:
sudo apt install -y "./postman_$version.deb"

Copy link

SanderTheDragon commented Sep 2, 2020

@n8eloy Good idea, when you run the script locally it will already ask to install, and using curl/wget just assumes you want to install it, thanks for the tip!

Copy link

AlvaroCodigo commented Sep 8, 2020

Gracias amigo mio, eres un dios <3

Copy link

ochen1 commented Oct 23, 2020

Thanks! It worked on Linux 5.4.0-52-generic

Copy link

richardwellerson commented Feb 23, 2021

Thanks bro! AWESOME!

Copy link

Sveagruva commented Feb 25, 2021


Copy link

xrxrxr commented Mar 18, 2021


Copy link

MKRNaqeebi commented Apr 15, 2021

Wow (stared)

Copy link

binary-ibex commented May 29, 2021

Thanks Brother

Copy link

Miltonr87 commented Jul 9, 2021

Thanx a lot, I use Linux Mint and flatpack version of Postman is unfortunately very slow.

Copy link

PabloHdzVizcarra commented Jul 15, 2021

Ohhh thanks men

Copy link

AndresJoaquinNino commented Nov 6, 2021

You are a hero!

Copy link

ohmydevops commented Nov 15, 2021

Brilliant! This even downloads the application for you.

Postman should pay you for this sunglasses

I agree

Copy link

mikiTesf commented Jan 21, 2022

I tried the script today and it breaks on line 59. The reason is because the downloaded tar archive is all in lowercase letters (postman instead of Postman). I also came across other errors:

.deb'ing 'postman_x64.tar-gz
/DEBIAN/control' near line 2 package 'postman':gz
 'Version' field value 'x64.tar-gz': version number does not start with digit
.deb'd to build 'postman_x64.tar-gz

Copy link

SanderTheDragon commented Jan 22, 2022

@mikiTesf It looks like Postman changed their naming scheme for tarballs, but it should work again.

Also a small update I forgot to upload, the package is now built in a temporary directory instead of the current working directory.

Copy link

mikiTesf commented Jan 23, 2022

@SanderTheDragon noted. Tried it again this morning. Works like a charm.

Copy link

sgtcoder commented Feb 5, 2022

Thanks guys, I updated my Postman script with some of this (it builds a repo)

Copy link

fakhamatia commented Jul 29, 2022

Testing Postman version
Most recent Postman version Vx64.tar-gz
Postman is not installed
Downloading latest Postman tarball
############################################################################################################################## 100.0%
Extracting Postman tarball
ls: cannot access 'Postman*.tar.gz': No such file or directory
tar: option requires an argument -- 'f'
Try 'tar --help' or 'tar --usage' for more information.
Failed to extract Postman tarball

Ubuntu 22.04

Copy link

SanderTheDragon commented Aug 4, 2022

@fakhamatia That mostly looks like the script is outdated, did you run it directly from the command line using one of the commands from the readme?

Copy link

stillru commented Aug 5, 2022

Problem on lines 7-18.
Returning string is postman-linux-x64.tar.gz wich havent version

Copy link

SanderTheDragon commented Aug 5, 2022

@stillru Thanks for letting me know!

I was just able to look and try it myself, and they dropped version information from the filenames. The only place I can find it now is in "/Postman/app/resources/app/package.json", this means that the only way to get the version is by first downloading the tarball. Or maybe they have a simple API that can be used for version info, I'll need to look into it.

I will update the script as soon as I can.

Copy link

sgtcoder commented Aug 5, 2022

I don't have any issues on my end. I actually included this script in my repository server so updates are automatic

Copy link

stillru commented Aug 5, 2022

I create a fork and change version generation based on date from wget/curl answer

Dirty, but work... How can i create pr for gist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment