my fedora PATH variables went out, how to restore them - linux

I wanted to add php to envirmonment variables
So I wrote:
export PATH=/opt/lampp/bin/
Then I discovered that this was wrong because it relaced the envirmonment variable PATH with only ( /opt/lampp/bin/ ).
Is there a way to restore the path to an earlier version?

restart your shell / exit your terminal. unless you edit your .bashrc file the changes to environment variable via the export command are not permanent

Related

Add express to Path in NodeJS

Hi im working on NodeJS with express in Mac OS,
After install:
with brew: https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
Shows me:
/Users/dortiz/.npm-packages/bin/express -> /Users/dortiz/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js
And if I will execute:
daortiz:~ dortiz$ express
-bash: express: command not found
But:
/Users/dortiz/.npm-packages/bin/express
Its working,
Im trying to export a path with
export PATH=$PATH:/Users/dortiz/.npm-packages/bin/
Its success, but if I close and reopen the terminal don't works command
But doesn't works, any one know what I doing wrong?
Using export sets environment variables for current shell only. Once shell is terminated environment variables for that shell no longer exist.
In order to set environment variables for all shell that are initiated you should put them in ~/.bash_profile as pointed by mailo.
You need to add the line to a file that will be sourced on login, for example: ~/.bash_profile

Export of PATH not permanent

I'm using this command to export the path to use some packages I installed globally.
export PATH=~/.composer/vendor/bin:$PATH
the problem is whenever I restart my machine, I would still need to export it again.
Is there a way to make this export permanent?
Yes, many a times that's the problem with doing export PATH.
You should append the environment variable directly into your .bash_profile file! This will be permanent and solve your purpose,thereby, making your package used globally without any further problem with the package's path.
Append the following to the end of your .bash_profile file,and replace the ~ with the actual path,i.e., /home/user_name :-
PATH=/home/user_name/.composer/vendor/bin:$PATH
export PATH
Add this line to your ~/.bash_profile:
export PATH=$HOME/.composer/vendor/bin:$PATH

customed command not found in a new terminal

everyone.
I had a basic question want to consult, about the environment variable setting.
After closed my one existed terminal which could execute compile(make) and do customed(mksdboot) command, i can't do mksdboot command anymore(I had execute a predefined setting environment variable shell script i.e. $ . ./arndale_envsetup.sh again) in the new terminal.
Cause i am a beginner in Linux, i am not very clearly about the environment variable setting rules.
i had tried to 'su' or 'sudo' to execute mksdboot, but no luck:(
ps. I had another project needs to compile in my PC(i didn't export PATH to .bashrc, only execute export PATH when i open a new terminal every time), may it efforts the original project's environment variable?
thanks.
[UPDATED]
i tried using $source ./arndale_envsetup.sh, relative commands worked finally.
but i still did't figure out the reason between work or not work. >"<
The command
history
will list what your previous commands where.
This might give you a pointer what set the path in the way you needed it.
You could also try to see where you command is via
locate mksdboot

How to set up Environment java variable in Ubuntu bash?

I am trying to set up Java in my new laptop. I have installed java jdk and I am trying to set up the environment variable now, But I am really confused between the file .bash_profile, .bashrc, .profile. I understand the concept behind login and non login shells, but when I wrote the JAVA_HOME, PATH variable in .bash_profile I needed to manually run the command
. .bash_profile
It did not get executed at the start when I restarted the computer to make it run as .bash_profile is supposed to be called by login shells. Can anyone explain to me what is the reason behind .bash_profile not being called up?
Since .bash_profile was not being called, I decide to type the PATH, JAVA_HOME variable to the file .bashrc, While this is working is this the right way to set up environment variables?

global variable but still can't access in linux

i have trying to use some global variable in my ant file.
when i do login through terminal. i can access those variable like JAVA_HOME
but when i am trying to access variable through the ant command i am not able to find them.
global variable declared in .cshrc
setenv JAVA_HOME jdk_full_path
ant code using variable.
<property environment="env"/>
<property name="ear" value= "true"/>
<property name="home" value="${env.HOME}"/>
<property name="java_home" value="${env.JAVA_HOME}"/>
i can access home variable but i am not able to find JAVA_HOME variable ,i am executing this ant through eclipse
Please suggest me where should i declare the variable so i can access them
The problem is probably that Eclipse doesn't have JAVA_HOME in its environment.
Try logging out and back in again, then run Eclipse.
Alternatively, open a terminal, and run Eclipse from there.
The .cshrc file is only run when you start a new C shell, it is not for global variables. Since you are not starting Eclipse from the C shell it will not see any variables you set there.
Try the ~/.login file or the /etc/profile file in case eclipse starts up using bash. Both of these files are only loaded once when the user logs on so they should effect everything. You may require a restart or even a reboot for changes to these files to take effect.
Environment variables are inherited through process execution, they are not global. So, when you edit your shell's RC file to add a variable, it only takes effect for shells executed AFTER that modification, and for programs executed from those shells. If you started Eclipse from KDE/Gnome, and KDE/Gnome was started before you made that change, then KDE/Gnome never had the definition and therefore Eclipse did not either.
I recommend logging out and back in. Also, depending on your default shell setting, you may find that KDE/Gnome is being started through bash or something else, meaning that you'll need to modify .bashrc instead of .cshrc.
You should define this variables at one of the following files:
~/.profile or ~/.bash_profile runs only with login shells i.e when you first log in into system.
~/.bashrc file runs every time you open a new non-login bash shell such as xterm
So, you should add to this files the line:
export JAVA_HOME=jdk_full_path
You must re-login for the changes take efect

Resources