Categories
GNU/Linux

$PATH variable sometimes different

Recently I had a problem with one of the utilities I use giving a command not found bash error.
It was unfathomable as just yesterday it had worked, but today it didn’t.

When I checked the $PATH variable, the folder with the binary of the command I was calling was not present.
I then had to fiddle with the environment, .bashrc and even use commands each time I logged in.

I recently discovered that the $PATH variable sometimes different problem arises because of the
su command.

The Super User command.

What is the difference between su - and su, if you had asked me yesterday I wouldn’t have know but I came across:
su gives you root power but with only the user’s path. su - gives you root power and root’s path. For the most part you are better off always using su -.

I had become lazy, I was taught to use su - originally but thought that su did the same thing.
Unfortunately not and that is the reason why the $PATH variable is sometimes different.