Make a program in path preferable instead of another - linux

There is a program in the PATH variable installed by root, but I installed a more recent version in my local.
There is any way to make my program preferable instead of the root?
Sorry for my bad english.

export PATH="/path/to/my/local/directory:$PATH"
Set this in your shell's startup file (e.g., ~/.bash_profile or ~/.zshenv) and restart your shell (or just execute it in your terminal).

put the preferred directory in front of the other one. It will pick up the first one it finds.
export PATH=/this/path/is/searched/first:/this/one/is/second:$PATH

Related

zsh option to generate the recomended options

There is a nice option when setting up zsh on Ubuntu
Populate your ~/.zshrc with the configuration recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).
However, on a fresh Arch Linux install the option is missing. Is there a way to have it (or maybe, I am being picky here) ?
This happens when you haven't got a .zshrc and there's a /etc/zsh/recommended.zshrc. If you say yes, it'll just copy that one to .zshrc.
Arch, bare-bones awesomesauce that it is, doesn't bother to ship such a file.

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

Environment Variable not being passed to CruiseControl, specifically the 'nodosfilewarnings' ENV variable from Cygwin

I have a Perl program that someone else created and I am calling on with CruiseControl. The program calls on Unix Commands using Cygwin. However, everytime that the Perl program calls on a Unix like command with a DOS like address, I get the well known error:
cygwin warning:
MS-DOS style path detected: E:\regression
Preferred POSIX equivalent is: /cygdrive/e/regression
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
I have set both the User Variable AND System Variable CYGWIN to nodosfilewarning. This removes the error when I run the program from the command line, but the error still occurs in CruiseControl when called as an automated process from a batch file. I have called on both the batch file from the Desktop AND Command Line and ran as an administrator. Nothing changes.
Other Notes
For purposes of this problem, I don't have access to the Perl Program
I am trying to go back to Cygwin 1.5.*, but since I am using Server 2008, I am encountering compatibility issues
This is occurring on one of the distributed servers, not the main server running the Webdashboard.
I have read somewhere that this issue may stem from a different user calling on CruiseControl, but the issue should have been solved by setting this as an ENV System variable
Is it possible to modify the registery to set the ENV variables?
Thank you in advance
The way I do it is like this
printf 'export CYGWIN=nodosfilewarning' >> ~/.bash_profile
If CruiseControl is connecting to the server via ssh, reinstall sshd and explicitly include nodosfilewarning when prompted for the CYGWIN environment variable during the install.
Re-installing with modified environment will work but if you don't want to or cannot re-install, an alternative is to change the registry instead of re-installing the service.
See: CYGWIN windows cygrunsrv sshd server and MS-DOS style path detected

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

adding a start up via command line (Ubuntu)

Hey, I'm trying to have a graphical program and I want it to start after I log in. How do I do so? I know there's a GUI program, but I want to use a command line here.
GUI tool:
http://www.thegeekstuff.com/2009/07/ubuntu-open-applications-automatically-during-system-startup/
now, there is update-rc.d, however, it seems to run before I log in, while the entire system loads ups (Unless I don't understand what the NN means in the update-rc.d manual).
Any ideas?
There's also an autostart folder in ~/.config/autostart - which is profile (or user) specific. If you put a .desktop file in /etc/xdg/autostart it will become a global startup for any new users created. This assumes you have xdg-user-dirs-gtk installed.
Drop a .desktop file in... /etc/xdg/autostart here, might be different on Ubuntu.

Resources