Whenever I login to my Linux server I'd like to have several commands run automatically (set some variables, change location, etc.)
This needs to be done on user login, not on system start.
How can I set it to do this?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Put the commands in
~/.bashrc. Anything in there is executed each time you log in.
If you need commands to only run when logging in via ssh (but not when logging in physically), you could probably test for the presence of the
SSH_CONNECTION environment variable, and only run the commands if you find it exists.