Check to see if NGINX is installed on UBUNTU

Solution 1:

if ! which nginx > /dev/null 2>&1; then
    echo "Nginx not installed"
fi

or

if [ ! -x /usr/sbin/nginx ]; then
    echo "Nginx not installed"
fi

or if you want to be Debian/Ubuntu specific:

if ! dpkg -l nginx | egrep 'îi.*nginx' > /dev/null 2>&1; then
    echo "Nginx not installed"
fi

if you're into the whole brevity thing:

! test -x /usr/sbin/nginx && echo "Nginx not installed"

Solution 2:

try this:

command -v nginx

install if not installed:

command -v nginx || sudo apt install nginx