For this example I have used magento2 cli. Asuming magento2 cli is located in /var/www/magento2/bin.
#create the script file
echo "export PATH=$PATH:/var/www/magento2/bin" > /etc/profile.d/magento2_bin.sh
#run the file to load
source /etc/profile.d/magento2_bin.sh