Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I log into my linux user through ssh, the user should automatically execute a set of commands. Same thing when I log out of my user. How can I accomplish this?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Assuming your user's shell is bash, put commands to be executed in the files ~/.bash_login and ~/.bash_logout. The former is executed at login time (modulo certain configuration choices), and the latter at logout. There are analogues for most other shells.

share|improve this answer
    
What if I'm logging into /bin/false and my user doesen't have a home directory? –  Schutzstaffel Nov 15 '12 at 15:16
1  
If your user has no shell, (s)he can't log in, so the question doesn't apply. –  MadHatter Nov 15 '12 at 15:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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