/etc/profile or $HOME/profile

/etc/profile or $HOME/profile

Post by ehabaziz2.. » Thu, 18 May 2006 06:38:41



I do not know when the system execute /etc/profile and when it executes
the &HOME/profile?
 
 
 

/etc/profile or $HOME/profile

Post by Crazy Eye » Thu, 18 May 2006 09:33:58



Quote:>I do not know when the system execute /etc/profile and when it executes
> the &HOME/profile?

/etc/profile is read for all users
${HOME}/.profile is read for individual users

--
Rodrick R. Brown
Senior IT Consultant
http://www.rodrickbrown.com

In 1986 Apple bought a Cray X-MP and announced that they would use it to
design the next Apple Macintosh, Seymour Cray replied, "This is very
interesting because I am using an Apple Macintosh to design the next Cray-2
supercomputer."

 
 
 

/etc/profile or $HOME/profile

Post by ehabaziz2.. » Fri, 19 May 2006 03:29:47


Is /etc/profile executed when any user login to the system ?
 
 
 

/etc/profile or $HOME/profile

Post by News » Fri, 19 May 2006 05:17:22



> Is /etc/profile executed when any user login to the system ?

Only those users with sh, ksh or bash as their login shell.  Then
$HOME/.profile gets processed (it gets more complex but that is the general
order.)
 
 
 

/etc/profile or $HOME/profile

Post by google » Fri, 19 May 2006 07:37:22




> > Is /etc/profile executed when any user login to the system ?

> Only those users with sh, ksh or bash as their login shell.  Then
> $HOME/.profile gets processed (it gets more complex but that is the general
> order.)

I have a similar question. I created an user account and then changed
its shell to bash (from sh). Everything is fine. Now I wanted to add
more directories to my PATH variable. So in ~/.profile, I added the
lines:

PATH=/opt/SUNWspro/bin:${PATH}
export PATH

After this I changed the permission of .profile to enable x mode and
ran (from $HOME) ./.profile . This _did not_ change the PATH variable
as was evident from "echo $PATH". So I put "echo $PATH" in .profile
just after setting PATH, and it displays the correct value. At this
point, I logged off and logged back in and saw that PATH has been set
correctly. Why isn't it changing on running ./.profile in the earlier
case?

 
 
 

/etc/profile or $HOME/profile

Post by Dave Uhrin » Fri, 19 May 2006 07:46:11



> Why isn't it changing on running ./.profile in the earlier
> case?

Try . ./.profile
 
 
 

/etc/profile or $HOME/profile

Post by google » Fri, 19 May 2006 08:50:42




> > Why isn't it changing on running ./.profile in the earlier
> > case?

> Try . ./.profile

Sorry, but I don't understand why that dot (.) is required at the
beginning.

Also, I want to know where PATH is set (that is, before executing
.profile). I checked /etc/profile. It does not set this variable, just
'export's it. So where is it actually being set? I didn't find any
~/.bash_profile or ~/.bash_login file.

Thanks.

 
 
 

/etc/profile or $HOME/profile

Post by Dave Uhrin » Fri, 19 May 2006 09:45:38





>> > Why isn't it changing on running ./.profile in the earlier
>> > case?

>> Try . ./.profile

> Sorry, but I don't understand why that dot (.) is required at the
> beginning.

Did you even bother to try my suggestion?  If you don't like the dot
then use

source ~/.profile

Quote:> Also, I want to know where PATH is set (that is, before executing
> .profile). I checked /etc/profile. It does not set this variable, just
> 'export's it. So where is it actually being set? I didn't find any
> ~/.bash_profile or ~/.bash_login file.

Will you please just read the man page for bash(1), particularly the
section titled INVOCATION?

Those files you ask about are not created by default unless you enhance
your /etc/skel/ directory.

 
 
 

/etc/profile or $HOME/profile

Post by Richard B. Gilber » Fri, 19 May 2006 10:27:31





>>>Is /etc/profile executed when any user login to the system ?

>>Only those users with sh, ksh or bash as their login shell.  Then
>>$HOME/.profile gets processed (it gets more complex but that is the general
>>order.)

> I have a similar question. I created an user account and then changed
> its shell to bash (from sh). Everything is fine. Now I wanted to add
> more directories to my PATH variable. So in ~/.profile, I added the
> lines:

> PATH=/opt/SUNWspro/bin:${PATH}
> export PATH

> After this I changed the permission of .profile to enable x mode and
> ran (from $HOME) ./.profile . This _did not_ change the PATH variable
> as was evident from "echo $PATH". So I put "echo $PATH" in .profile
> just after setting PATH, and it displays the correct value. At this
> point, I logged off and logged back in and saw that PATH has been set
> correctly. Why isn't it changing on running ./.profile in the earlier
> case?

Because ./.profile spawned a subprocess to execute .profile.  The PATH
environment was set in the suprocess and lost when the subprocess
terminated.  You CAN NOT alter the environment of a another process.

Try "source .profile" if the shell you are using supports it.

 
 
 

/etc/profile or $HOME/profile

Post by google » Fri, 19 May 2006 11:19:34






> >> > Why isn't it changing on running ./.profile in the earlier
> >> > case?

> >> Try . ./.profile

> > Sorry, but I don't understand why that dot (.) is required at the
> > beginning.

> Did you even bother to try my suggestion?  If you don't like the dot
> then use

> source ~/.profile

I thought about using "source ~/.profile". I had used it in csh, but
was not sure if it works for bash. On doing "man source", it gave
information only for the shells sh, csh and ksh (not bash), and the
source command was listed only under csh. So I thought it's not
supported under bash, but turns out that I was wrong.

Quote:> > Also, I want to know where PATH is set (that is, before executing
> > .profile). I checked /etc/profile. It does not set this variable, just
> > 'export's it. So where is it actually being set? I didn't find any
> > ~/.bash_profile or ~/.bash_login file.

> Will you please just read the man page for bash(1), particularly the
> section titled INVOCATION?

> Those files you ask about are not created by default unless you enhance
> your /etc/skel/ directory.

Actually my question was where is PATH being originally set. By
mentioning about ~/.bash_profile and ~/bash_login not present, I meant
to say that it wasn't being set there. I didn't mean to ask why these
files are not present. Sorry if I didn't put that clearly enough. I
read through the section titled INVOCATION, but still don't find the
answer to my question.
 
 
 

/etc/profile or $HOME/profile

Post by Dave Uhrin » Fri, 19 May 2006 11:50:41



> I read through the section titled INVOCATION, but still don't find the
> answer to my question.

Is this all that difficult to understand?

     When bash is invoked as an interactive login shell, or as  a
     non-interactive  shell  with  the  --login  option, it first
     reads and executes commands from the file  /etc/profile,  if
     that  file  exists.   After  reading that file, it looks for
     ~/.bash_profile,  ~/.bash_login,  and  ~/.profile,  in  that
     order,  and  reads  and executes commands from the first one
     that exists and is readable.  The --noprofile option may  be
     used when the shell is started to inhibit this behavior.

     When a login shell exits, bash reads and  executes  commands
     from the file ~/.bash_logout, if it exists.

     When an interactive shell that  is  not  a  login  shell  is
     started, bash reads and executes commands from ~/.bashrc, if
     that file exists.  This may be inhibited by using the --norc
     option.   The  --rcfile  file option will force bash to read
     and execute commands from file instead of ~/.bashrc.

Now, just which question do you mean with "my question"?

 
 
 

/etc/profile or $HOME/profile

Post by google » Fri, 19 May 2006 12:11:26




> > I read through the section titled INVOCATION, but still don't find the
> > answer to my question.

<snip>

Quote:> Now, just which question do you mean with "my question"?

I had mentioned that clearly if you read my previous post:
"Actually my question was where is PATH being originally set."

I want to know where PATH is being set before I am adding more
directories to it in ~/.profile by
PATH=/opt/SUNWspro/bin:${PATH}
export PATH

My idea is that the files /etc/profile, ~/.bash_profile and
~/.bash_login are executed before ~/.profile (and this is exactly what
you had copy pasted from man page of bash). As I had said before, I
don't see PATH being set in /etc/profile (this file only 'export's
PATH) and the other two files in ~ are missing. So where exactly is it
getting set before we are modifying its value in ~/.profile ?

 
 
 

/etc/profile or $HOME/profile

Post by Dave Uhrin » Fri, 19 May 2006 12:30:29





>> > I read through the section titled INVOCATION, but still don't find the
>> > answer to my question.

> <snip>

>> Now, just which question do you mean with "my question"?

> I had mentioned that clearly if you read my previous post:
> "Actually my question was where is PATH being originally set."

/etc/default/login

man login

 
 
 

/etc/profile or $HOME/profile

Post by News » Fri, 19 May 2006 14:35:20



> After this I changed the permission of .profile to enable x mode and
> ran (from $HOME) ./.profile . This _did not_ change the PATH variable
> as was evident from "echo $PATH". So I put "echo $PATH" in .profile
> just after setting PATH, and it displays the correct value. At this
> point, I logged off and logged back in and saw that PATH has been set
> correctly. Why isn't it changing on running ./.profile in the earlier
> case?

Do you also have a $HOME/.bash_profile ?

If so you must man bash to see what will happen.

 
 
 

/etc/profile or $HOME/profile

Post by Jim » Tue, 23 May 2006 06:13:47





>>> Why isn't it changing on running ./.profile in the earlier
>>> case?
>> Try . ./.profile

> Sorry, but I don't understand why that dot (.) is required at the
> beginning.

Try
man .
then try figuring that one out :-)

Jim

 
 
 

1. Telnet login doesn't run /etc/profile or $HOME/.profile

Hi,

A minor but irritating problem I'm having with my system (Linux-FT 1.1,
kernel 1.2.13, Pentium 90). When logging in from a remote machine by
telnet (e.g. MS-telnet in Windoze for workgroups), the telnet correctly
logs the user in, complete with starting the right shell etc, but doesn't
run /etc/profile or $HOME/.profile, so the paths, prompts and environment
variables don't get set correctly.

I'm a bit puzzled by telnet logins : they don't seem to be handled by a
getty, so I presume the telnet daemon is responsible for negotiating the
login. So, is this a problem with telnet daemon configuration, or a
compile option, or just not possible ? The telnet and telnetd man pages
are very sparse and don't say anything about this. I also couldn't find
anything in the NET-HOWTO or network configuration guide.

Any advice very gratefully received,

Steve

-----------------------------------------------------------------------------
| Steve Mottram                                                             |
|                                                                           |
| University Department of Anaesthesia  |    Internal Phone : LRI 5694      |
| Leicester Royal Infirmary             |    Phone  :  +44 (0)116 258 5291  |
| Leicester LE1 5WW                     |    Fax    :  +44 (0)116 285 4487  |

|---------------------------------------------------------------------------|
| Witty bit deleted due to budget cuts.                                     |
|---------------------------------------------------------------------------|

2. Linux Security Alert #1

3. ksh not reading /.profile or /etc/profile

4. Moving files between Mac HFS+ and Linux--possible?

5. cmdtool doesn't source /.profile or /etc/profile

6. cross platform LDAP, default shell and rfc2307

7. KDE won't start if my .profile or /etc/profile has stty commands

8. pppd hangs machine

9. Not reading /etc/profile or .profile

10. "Screen" prgram: New shells won't read /etc/profile or ~/.profile?

11. How do you make CDE source .profile, .bashrc in home dir and /etc?

12. Profile/.profile/.bash_rc/et al.

13. changing bash profile into csh profile?