Rorschach Rorschach - 4 months ago 12
Bash Question

Execute command if su to a certain user

If I enter

sudo su - Rorschach
and login as Rorscach. I would like a command to be executed automatically.

Such as
echo "Hello Rorschach"
or
cd ~


Where do I put these scripts in order for them to be performed upon login of that user?

I am using an ubuntu 14.04 command line and
echo $0
outputs
-bash

Answer

~/.bash_profile (recommended) or ~/.bashrc (will work, but this file should rather contain functions and aliases, not commands).