1827439 Members
5757 Online
109965 Solutions
New Discussion

sourcing /etc/profile

 
SOLVED
Go to solution
Shivkumar
Super Advisor

sourcing /etc/profile

Hi,

How to source /etc/profile ?

I have read about sourcing .profile only.

Thanks,
Shiv
4 REPLIES 4
Jeff Schussele
Honored Contributor
Solution

Re: sourcing /etc/profile

Hi Shiv,

The standard login utilities automatically source /etc/profile.
But if you wish to do it manually after login do

. /etc/profile

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
James R. Ferguson
Acclaimed Contributor

Re: sourcing /etc/profile

Hi Shiv:

To source (read) a file, for instance, '/etc/profile', do:

# . /etc/profile

That is a "dot", followed by a space (blank), followed by the name of the file to be read.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: sourcing /etc/profile

Normally, when you run a script, the shell firks a new copy of the shell which then runs the script. All changes to shell environment are left with this shell. When the script terminates, the forked shell also terminates and nothing is passed back to the current shell except a numeric exit code.

Sourcing causes the current shell to run all the instructions locally, which leaves all the changes in the current environment. Any script can be sourced. The source command is just the character . (dot or period). You put the dot in front of the script with at least one space.


Bill Hassell, sysadmin
Daavid Turnbull
Frequent Advisor

Re: sourcing /etc/profile

How a script is sourced is dependent upon the current shell. While most shells use a dot (.) I know of at least one that uses the command "source".

If you read the man pages for the shells you are likely to use they will tell you which files get sourced and in what order.
Behold the turtle for he makes not progress unless he pokes his head out.