Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update $PATH variable permanently

Apologies if this duplicate but a lot of other threads are years old.

I want to update my $PATH variable permanently so it doesn't reset everytime I quit Terminal. I have seen people suggest to run the following:

gedit ~/.bashrc

But this returns:

-bash: gedit: command not found

I have used Spotlight to search my hard disk for the .bashrc file and can't find it. Can anyone help?

Thanks in advance...

like image 220
Paulos3000 Avatar asked Sep 08 '26 14:09

Paulos3000


1 Answers

You don't need an editor for that, you can do this using bash's output redirection operation.

For example, to add /foo/bar you current PATH, append (>>) to ~/.bashrc:

echo 'export PATH="$PATH":/foo/bar' >> ~/.bashrc

To view the content to STDOUT too, use tee -a:

echo 'export PATH="$PATH":/foo/bar' | tee -a ~/.bashrc
like image 63
heemayl Avatar answered Sep 11 '26 10:09

heemayl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!