-3

Say, I would like to change my editor system-wide to nano. I was doing this with

echo 'export EDITOR=/usr/bin/nano' >> /etc/bashrc

As I learned, it was a bad idea, because if you accidentally omit one >, you will overwrite bashrc and won't be able to log in. In addition to being error-prone, is this in any other way a bad idea and which way is better?

2 Answers2

4

Actually edit the file with an editor like nano, or vim.

David
  • 343
4

You can add system-wide environment variables in the file /etc/environment instead of adding commands to /etc/bashrc.

The entries would then be like

FOO=bar
BAZ=quux

The rest of your question pretty much comes down to "how to edit a file without messing it up", which to some degree comes down to personal preference.