Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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.
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
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.
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)?
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.
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.
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.
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
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)
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]
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.