I am using Ubuntu 16.04 LTS. I am really new to Linux.

I created a softwares directory within the Downloads dir for all the software and added it to my PATH. Then I was advised that it's better to create a bin directory in your home, instead of keeping directories such as Downloads in the PATH. So, I did it. Now, my problem, I have both the directories in the PATH and some of my tools are not running due to this reason.

I did try some of the suggestions given in the posts here but it didn't work for me and since I am new, I am bit scared to experiment that I'll mess up every thing.


$ echo $PATH 

I want to remove the softwares dir and duplicates and want to keep /home/gjjha/bin since all softwares are in bin dir now.

Commands I tried:

PATH=echo $PATH | sed -e 's/:\/home\/wrong\/dir\/$//'
PATH= echo $PATH | sed -e 's/:/home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin/$//'

I checked (even after rebooting), the softwares dir is still there.

  • 1
    Where did you set your path? You must have edited some config file.
    – Zanna
    Mar 12, 2017 at 11:29
  • 2
    Trying to edit variables on the fly with sed or parameter substitution is not the right way to approach this. Revert the changes you made then logout and login. Mar 12, 2017 at 13:32
  • 1
    Please remove this crossposting.
    – Cyrus
    Mar 12, 2017 at 16:22
  • @Zanna I have added the path using vim .bashrc every time.
    – Mirza
    Mar 14, 2017 at 9:54
  • well you need to remove whatever you added to your .bashrc to set the PATH. Then it will be overidden by /etc/environment when you log out and back in. Then you can put the path you want in .profile (more appropriate than .bashrc)
    – Zanna
    Mar 14, 2017 at 9:58

1 Answer 1


On my vanilla install of 16.04, the PATH variable is set from .profile for login shells

First save your current PATH to a text file:

echo $PATH > currentpath.txt

I find it easiest to then open a new shell and do

sudo vi .profile

now edit or add the line to set the correct path


with the path that you want inside the quotes.

The default path:


(And it works from left to right - if an executable with the same name exists in /usr/local/sbin and /usr/bin, the version in /usr/local/sbin will be called when you type the name)

Press esc and write and quit with


If you don't know vi you could use nano to edit the .profile file. Might be easier.


I did this so that my local bin folder was in the path for executables. Dunno why it wasn't by default, but hey.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .