LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-29-2012, 10:16 AM   #1
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Rep: Reputation: 4
How to execute source /etc/profile at start up?


How to execute source /etc/profile at start up. When i reboot, machine must execute source /etc/profile. Bcoz, i have added paths in /etc/profile, its not reflecting upon startup. Only after source /etc/profile command, all works.
 
Old 03-29-2012, 10:22 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
The source command instructs the shell to read the contents of a file as a series of commands. The aforementioned file is automatically sourced (by the bash shell, at least) when the shell starts (in certain modes... see man bash). If you do so later, it has the same effect as it did the first time, and this can be useful if you want to restore the environment variables to (more or less...) their initial state.

There is no "arkane magick" here.
 
Old 03-30-2012, 03:55 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
source works in tcsh, but /etc/profile is not evaluated by tcsh. When you use tcsh you should put those settings into /etc/csh.cshrc and /etc/csh.login
 
Old 03-30-2012, 06:44 AM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator response

Hi,

Quote:
Originally Posted by Iyyappan View Post
How to execute source /etc/profile at start up. When i reboot, machine must execute source /etc/profile. Bcoz, i have added paths in /etc/profile, its not reflecting upon startup. Only after source /etc/profile command, all works.
Please do not resurrect old threads. You resurrected a 9 year old thread. Moved your post & related posts to a new thread.
 
Old 03-30-2012, 08:49 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
What do you want to achieve? The boot scripts are not designed to use /etc/profile which is a logon shell customisation file.
 
Old 03-30-2012, 09:20 AM   #6
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
Actually what my issue is, in /etc/profile i have set java_home, java_path. Its working only if i give source /etc/profile. I rebooted the machine and checked, but still its not working. I have to key source /etc/profile everytime i reboot the machine, so that the users can work thereafter. This issue is only with one machine. I have done the same in many machines before, i have never faced this kinda issue b4
 
Old 03-30-2012, 09:25 AM   #7
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by onebuck View Post
Hi,


Please do not resurrect old threads. You resurrected a 9 year old thread. Moved your post & related posts to a new thread.
Hi i am sorry for that. Will open in new threads from now on
 
Old 03-30-2012, 10:07 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You mean that the users have the problem after logging on?
 
Old 03-30-2012, 10:18 AM   #9
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
If i do not key source /etc/profile after reboot, the users are facing difficulty while starting tomcat, it says there is no java environmental variables defined. When i type java and javac, i get o/p. Only the env variables are not getting set.
 
Old 03-30-2012, 10:13 PM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Iyyappan View Post
If i do not key source /etc/profile after reboot, the users are facing difficulty while starting tomcat, it says there is no java environmental variables defined. When i type java and javac, i get o/p. Only the env variables are not getting set.
Is this after the users have logged on? Are they trying to start tomcat themselves?

If so, what is the user's logon shell (as specified in the last field of their line in /etc/passwd)?
 
Old 03-31-2012, 03:37 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
Quote:
Originally Posted by Iyyappan View Post
If i do not key source /etc/profile after reboot, the users are facing difficulty while starting tomcat, it says there is no java environmental variables defined. When i type java and javac, i get o/p. Only the env variables are not getting set.
As I have already written if your users uses tcsh as login shell the file /etc/profile has no any meaning. This is normal, this is the expected behavior. You need to put those settings into /etc/csh.cshrc or /etc/csh.login, because they are evaluated during the login process.

source /etc/profile is problematic anyway, because /etc/profile is used by bash, but bash does not understand the command source.
 
Old 03-31-2012, 03:59 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Did you read the /etc/profile file? On SLED, it may start with:

# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

Also check if you have an /etc/profile.d/ directory. It will contain startup scripts for the shells your system supports. The scripts with .sh extensions are sourced by /etc/profile (if the sticky bit isn't set on my system).

If a user uses tcsh, csh, pdksh or another shell, another file besides /etc/profile may be sourced instead. So you need to edit the script used for those shells as well.

---

Another possibility is that you didn't export the PATH variable after making your changes.
 
Old 04-02-2012, 12:04 AM   #13
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
This is what i have in /etc/profile. The same entries are there in another machine which works fine. Only in this mac alone i am facing issue. We use only bash shell.

export JAVA_HOME=/usr/jdk1.6.0_21
export JAVA_PATH=/usr/jdk1.6.0_21/bin
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/112
ORACLE_SID=ORCL
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH
export PATH=/usr/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/bin:/bin:/opt/oracle/112/bin:/sbin


In /etc/profile.d directory i have following files, should i create a new file? I use bash shell only
colorls.csh glib2.csh gnome-ssh-askpass.csh krb5-workstation.csh lang.csh less.csh mpi-selector.csh vim.csh which-2.sh
colorls.sh glib2.sh gnome-ssh-askpass.sh krb5-workstation.sh lang.sh less.sh mpi-selector.sh vim.sh
 
Old 04-02-2012, 12:44 AM   #14
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
you know, the problem is that the keyword export is unknown for tcsh and source is unknown for bash.
So source /etc/profile will give you syntax error either in tcsh or in bash.

If you can execute this command it means you have something special in your environment.

By the way, if you use bash than /etc/profile is evaluated, you can insert an "echo /etc/profile" line at the end of the file to see it.
Back to the original problem:
Quote:
Bcoz, i have added paths in /etc/profile, its not reflecting upon startup.
maybe the PATH variable is overwritten in the local ~/.bashrc file (or somewhere else)
 
Old 04-02-2012, 10:40 PM   #15
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by pan64 View Post
you know, the problem is that the keyword export is unknown for tcsh and source is unknown for bash.
bash has source
Code:
c@CW8:~$ help source
source: source filename [arguments]
    Execute commands from a file in the current shell.
    
    Read and execute commands from FILENAME in the current shell.  The
    entries in $PATH are used to find the directory containing FILENAME.
    If any ARGUMENTS are supplied, they become the positional parameters
    when FILENAME is executed.
    
    Exit Status:
    Returns the status of the last command executed in FILENAME; fails if
    FILENAME cannot be read.
c@CW8:~$ bash --version
GNU bash, version 4.1.7(2)-release (x86_64-slackware-linux-gnu)
[snip]
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help? how to execute the /etc/profile without having the user exit then logon? icecoolcorey Programming 3 06-12-2008 09:48 AM
Oracle doesn't start. Problem with .profile aronnok Linux - Software 2 01-05-2006 12:27 PM
source /etc/profile kaon Slackware 13 08-09-2004 10:02 PM
source /etc/profile? why? what is it? piratebiter Linux - General 3 09-09-2003 11:36 AM
.profile not be source when using ksh93. NEED HELP!!!! michaeldm9 Linux - General 0 08-28-2003 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration