They all are effective. One isn't drastically better than the other, but I prefer:
export PATH=$PATH:/usr/local/bin
It takes care of the export and the setting of the path in one line. I also tend to not put the new path before the existing $PATH
, but there are cases when that might be necessary to load newer self-compiled libraries before older system ones.
If you are trying to export variables then yes, you want to quote them, for instance:
export myservers="server1 server2 server3"
Now when you echo $myservers
you will see:
[user]# echo $myservers
server1 server2 server3
But since this question relates to $PATH
and not shell variables, then my original post still stands since there will never be a time where you are printing 'hello world'
into your system path.
[user]# echo $PATH ## Something you shouldn't be doing
/usr/local/bin:HELLO WORLD/sbin:/bin:/usr/sbin:WHY AM I DOING THIS?/usr/bin:/root/bin