0

I have one script that will run when a specific user logs in. Where should this script and its assets be placed? I was planning to put it in /usr or /bin or /var, but I was wondering if there's a standard for this sort of thing, and where they should be placed to be out of the way but accessible.

  • Usually it is put in the user's home directory. Is there some reason you don't want to do this? If so, change the question to expand upon this. – rocky Jun 23 '15 at 3:38
  • No, that basically answers the question. Thanks! – evamvid Jun 23 '15 at 3:39
2

Startup scripts and assets are usually put in the user's home directory.

(The home directory can either be found by getent passwd username or by logging in as the user and inspecting the value of $HOME.)

  • 1
    When searching for user information, remember to use getent passwd (instead of only greping /etc/passwd) to cover cases where the user information might have been loaded from a remote user directory like LDAP or NIS. – n.st Jun 23 '15 at 7:25
2

As this is a executable script, it is good to place it at /usr/bin or /usr/local/bin

Advantage:

  • avoid typing full path of the script like /var/opt/anything/my_script
  • ever you want to test it from terminal , just type my_script

I think there is no standard of doing this, place it anywhere (obviously not at /dev, /proc, /sys, /var/www, etc.) you like, finally it depends on your choice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.