Run bash script after login

All interactive sessions of bash will read the initialization file ~/.bashrc.

So you can just add the script at the end of the root's .bashrc i.e. /root/.bashrc, assuming the script is executable:

echo '/path/to/whiptail.sh' >>/root/.bashrc

Now the script will be always run when root opens a new interactive shell. If you only want to run while login only, not all all interactive sessions you should rather use ~/.bash_profile/~/.bash_login/~/.profile (the first one available following the order).


If you want it to be global, add you script to

/etc/profile 

If you want it to be user-specific, add you script to

/home/$USER/.profile

Consider upvoting the original answer here: https://unix.stackexchange.com/a/56088/343022

Tags:

Linux

Bash

Ubuntu