I set these users' home folders through the /etc/passwd file, but when they log in I would like them to activate a python virtualenv. If they had a personal .bashrc
file, I'd just include the activate
command there, and the directory change as a post-activate hook with virtualenv.
However these users don't have home folders, and don't have personal .bashrc
files.
How can I execute a different command on login for each of these users? (Only one command needs to be executed.)
These users are only logged into using su
, never SSH. The machine is a VPS running Ubuntu 12.04.3 LTS.
Best Answer
You can add a file to the system's
/etc/profiile.d
directory that includes aif/then
statement for each of the users that you want to run thevirtualenv
for.Example
Say I create a file like this,
/etc/profile.d/me.sh
.Make it executable:
And then login as
saml
, usingsu
:If we check to see if the temp file was created, it was: