5

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...

Paulos3000
  • 3,355
  • 10
  • 35
  • 68

2 Answers2

9

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
heemayl
  • 39,294
  • 7
  • 70
  • 76
1

the . before the file means it's hidden so that's probably why it didn't show, just like if you do ls from your home folder you won't see it but ls -la will

to edit your file I would suggest using vi instead if gedit is not available

vi ~/.bashrc

Mike
  • 89
  • 4