Add directory to path permanently


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 10-16-2018
Add directory to path permanently

I ssh in and am trying to add a directory permanently to $PATH in centos 7 and having issues. My current $PATH is

Code:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

but when I do a sudo nano ~/.bashrc
Code:
# .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 Smilie.

Code:
export PATH="$PATH":/usr/bin/gatk-4.0.10.1
source ~/.bashrc

# 2  
Old 10-16-2018
I don't see where you added /usr/bin/gatk-4.0.10.1 to your PATH in the .bashrc. I won't ask why it's in /usr/ and not /usr/local/, though Smilie
This User Gave Thanks to Scott For This Post:
cmccabe (10-16-2018)
# 3  
Old 10-16-2018
Code:
export PATH=$PATH:/usr/bin/gatk-4.0.10.1
source ~/.bashrc

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

is this not correct? II don't see where the /root/bin is coming from either. Thank you Smilie

I use/usr/bin to make it easier for others on the server to find. Thank you.

update

Code:
export PATH="$PATH":/usr/bin/gatk-4.0.10.1

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin/gatk-4.0.10.1

but then after exiting and re-logging in
Code:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin


Last edited by cmccabe; 10-16-2018 at 03:50 PM.. Reason: added update
# 4  
Old 10-16-2018
Perhaps I misread your first post. Did you actually edit your .bashrc to add the path to gatk-4.0.10.1, or just change it on the command line?

(second, probably silly question - are you using bash?).

/root/bin was most likely added to PATH from some default bashrc in /etc, or in .bash_profile in root's home directory.
This User Gave Thanks to Scott For This Post:
cmccabe (10-16-2018)
# 5  
Old 10-16-2018
I just ran the below on the command line. Is there a better more optimal way? Thank you Smilie.

Code:
export PATH="$PATH":/usr/bin/gatk-4.0.10.1

I am using bash although that is a bash command to add to path I think. Thank you very much for the clarification and helpSmilie.
# 6  
Old 10-16-2018
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...
Quote:
In ubuntu 14.04 I would do the below and that worked great, but it doesn't seem to in centos 7
This User Gave Thanks to Scott For This Post:
cmccabe (10-17-2018)
# 7  
Old 10-17-2018
added update

I apologize, I would do the below in ubuntu 14.04

Code:
echo export PATH=$PATH:"/usr/bin/gatk-4.0.10.1" >> ~/.bashrc

to update .bashrc, although that doesn't work either. Thank you Smilie.

though if I log out then login, it's fine.

so maybe, source ~/.bashrc after the command?

------ Post updated 10-17-18 at 07:15 AM ------

Thank you very much for your help Smilie.

Last edited by cmccabe; 10-16-2018 at 04:58 PM..
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
NFS with a NAS: permanently inconsistent directory state across clients cosmojetz Solaris 10 05-12-2015 02:30 PM
Extract directory name from the full directory path in UNIX using shell scripting IshuGupta UNIX for Dummies Questions & Answers 5 06-03-2014 09:15 PM
Keep last directory from path Aswex Shell Programming and Scripting 1 11-12-2013 11:03 AM
How to get the current directory Path? Abhishek0683 UNIX for Dummies Questions & Answers 3 06-30-2013 02:14 PM
Can't add directory to path correctly tastybrownies Shell Programming and Scripting 2 02-09-2013 02:28 PM
Setting the path permanently using shell script pjeedu2247 Shell Programming and Scripting 6 01-22-2013 02:22 PM
How to select First two directory in from path name? yadavricky Shell Programming and Scripting 10 11-12-2012 12:33 PM
Add directory to a global PATH miltonrods UNIX for Dummies Questions & Answers 3 06-29-2012 11:38 AM
add path variable permanently burton Shell Programming and Scripting 4 06-15-2012 05:01 PM
"find . -printf" without prepended "." path? Getting path to current working directory? pstein Shell Programming and Scripting 1 10-02-2011 09:23 AM
Retrieve directory path from full file path through sh royzlife Shell Programming and Scripting 7 09-21-2010 09:28 AM
Is there any way to add an exception for a port in the firewall setting, permanently? senrooy IP Networking 1 03-02-2010 10:19 AM
Help with directory path parsing brianjbrady Shell Programming and Scripting 8 02-16-2010 01:58 PM
permanently add static route beaker457 Red Hat 1 04-17-2009 03:16 PM
How to get directory name from its path? ordano UNIX for Dummies Questions & Answers 1 02-12-2009 04:08 AM