Ubuntu: Permanently Remove Item from `$PATH`


I've dug around forums trying to find a way to get rid of some default items in my path, but to no avail. Here is what it gives right now:


And the offending items are the the two with games in them:


neither of which I use, but that really isn't the core of my question. I want to get rid of these items (and to know how to do similarly in the future), but I can't find where these defaults are being set. There's no mention of PATH when I grep these files:

/etc/profile  /etc/profile.d/*  ~/.bashrc  ~/.bash_profile  

I'm using Ubuntu 13.04


The PATH is set up in /etc/environment file, but if you want to remove some items from it, better to do this in your ~/.bashrc file. So, if you want to remove /usr/games and /usr/local/games directories, set up again the PATH like this:



Changes to ~/.bashrc will apply to every new shell.

Edit ~/.bashrc and add these two lines:

PATH=${PATH/":/usr/games"/""}  PATH=${PATH/":/usr/local/games"/""}  



In an expression of this kind, the / separates the variable, the string to find, and the string to use as a replacement. In the actual application the UNIX path separator / would be interpreted so it is necessary to quote the string ":/usr/games" to make a literal. The "" is the empty replacement.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »