# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
In ubuntu 14.04 I would do the below and that worked great, but it doesn't seem to in centos 7 . Thank you :).
Well, if you modify PATH from the command line it will be lost when you end your current session. To make it stick, you need to modify the path in one of your login scripts (e.g. .bashrc or .bash_profile).
This statement confused me, because I don't know why that would be...
A few clarifications: you can change your environment (of which the PATH variable is a part) on the command line. Enter set or env at the command line to see what your current environment is. Basically, it is a set of declarations of variables in the form:
VARIABLE="some value"
and shell functions. Your PATH statement just modifies this value:
export PATH=$PATH:"/usr/bin/gatk-4.0.10.1"
means: set the variable PATH ("PATH=") to what it contains now ("$PATH"), plus a colon (":") and a fixed string ("/usr/bin/gatk-4.0.10.1").
Again, you can do that on the command line (like you did), but this will be lost when you log out. The file ~/.bashrc now contains such collected command line settings and it is executed every time you log in. That means, to make the change last you will have to modify this file, like you did:
That simply adds (">>") the string export PATH=$PATH:"/usr/bin/gatk-4.0.10.1" to the end of the file ~/.bashrc - well, not quite, actually. Notice, though, that the content of "$PATH" will replace the string "$PATH" when you execute that and if, for instance, your PATH contained before the string:
/usr/bin:/usr/local/bin
then what you wrote into the file ~/.bashrc will be NOT the line
$ cat ~/.bashrc
<...old content of .bashrc...>
export PATH=$PATH:"/usr/bin/gatk-4.0.10.1"
but in fact:
$ cat ~/.bashrc
<...old content of .bashrc...>
export PATH=/usr/bin/usr/local/bin:/usr/bin/gatk-4.0.10.1
and this may or may not (most probably may not) be what you wanted. Anyway, when you want to have this setting not only in your future sessions but also in the current one you indeed have to use source ~/.bashrc because at the time when the file was executed - your login - the change was not there.
Further, appending directories to the path naively has a problem: you don't want the directories to be there several times. Take yours, for example, the existing path is just to show the effect, your will probably be different:
You probably want to avoid that. This is why i set the PATH in my rc-scripts this way:
export PATH="/usr/bin" # here the existing PATH is overwritten
PATH="$PATH:/usr/local/bin"
PATH="$PATH:/some/other/dir"
...etc.
It is easy to add or remove a line with a single directory this way and it is easy to grasp immediately what is what. For not-so-obvious settings i use comments to remind me what it was for (so i can also easily find out if it can be removed again). Also notice that a variable is either exported or not. If it is there is no need to export it again, just because its value has changed.
You first try:
probably didn't work because by "sudo" you changed the environment of user "root", not the environment of the account you use to run the application. So, it "worked" in a way, but not one you could make use of.