LinHES Forums
http://forums.linhes.org/

per-user autoexec.bat equivalent in LINUX?
http://forums.linhes.org/viewtopic.php?f=5&t=16782
Page 1 of 1

Author:  graysky [ Sat Sep 29, 2007 3:11 pm ]
Post subject:  per-user autoexec.bat equivalent in LINUX?

I'd like to have several commands get executed every time a particular user successfully logs in via an ssh or locally. I'm sure there's a dot file I can edit to accomplish this?

Thanks for the info!

Author:  BradBass [ Sat Sep 29, 2007 5:54 pm ]
Post subject:  Re: per-user autoexec.bat equivalent in LINUX?

It depends on the shell. For sh, the file would be .profile ;
For bash, it's .bashrc ; for c-shell, it's .cshrc

To find out which shell you're running, use the 'ps' command.
You'll see something like this:

brad@mythtv:~$ ps
PID TTY TIME CMD
4989 ttyp0 00:00:00 sh
4998 ttyp0 00:00:00 ps
brad@mythtv:~$

So, I'm running 'sh', so the file I want is .profile

Author:  graysky [ Sat Sep 29, 2007 5:57 pm ]
Post subject: 

Killer man, just what I needed. Thanks.

Author:  tjc [ Sat Sep 29, 2007 9:46 pm ]
Post subject:  Re: per-user autoexec.bat equivalent in LINUX?

BradBass wrote:
It depends on the shell. For sh, the file would be .profile ; For bash, it's .bashrc

Not quite... sh (aka Bourne Shell) always looks for ~/.profile, however, bash looks for ~/.bash_profile first, and if that's not found it looks for ~/.profile. There is nothing built in that uses ~/.bashrc. That's only a convention established in you .bash_profile or .profile file, either by setting BASH_ENV or explicitly sourcing or dotting in the file. Both shells also fall back on /etc/profile if no local file is found.

Reading the bash man page and/or info pages will provide more details:
Code:
man bash
info bash

Author:  BradBass [ Mon Oct 01, 2007 8:55 am ]
Post subject: 

tjc wrote:
There is nothing built in that uses ~/.bashrc. That's only a convention established in your .bash_profile or .profile file.

My mistake -- looking back, I don't remember
whether I was on my Knoppmyth box, Kubuntu
box or some other Unix system. Different
distributions sometimes use different
conventions, but tjc is correct -- there is a "one
true way" that they all follow. Nice catch!

Brad

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/