Script with privilege check

Some scripts requires root privileges (or sudo). Here is an example about a script which checks the privileges before running.

#!/bin/bash
# RJP 8.2.2025 An example script
# Checking if script is run as sudo
#
#
if [ "$EUID" -ne 0 ]; then
x-terminal-emulator -e /bin/bash -c "read -p \"This script needs superuser permissions. Please run it using sudo or as root.\"" &
else
x-terminal-emulator -e /bin/bash -c "sudo apt update && sudo apt upgrade && read -p \"
#################################################
########## System upgraded ######################
#################################################\"" &
exit 0
fi

Case no privileges:

Case with privileges: