I am using Ubuntu 14.04. Recently I decided to install gcc-5.4.0 (from source, i.e. i downloaded a tar ball and followed instructions to install) since it was needed to run CAMB and CosmoMC.

However, I am in need of using a new program: CosmoSIS (https://bitbucket.org/joezuntz/cosmosis/wiki/Manual%20Install), this code requires gcc-4.8 to run.

Whenever i try to install CosmoSIS, the code crashes because when it is searching for gcc-4.8 in /usr/local/bin it conflicts with gcc-5.4 which is installed in the same directory (i am new to this, i'm guessing i made a mistake by installing 5.4 in the same directory in which 4.8 is installed)

I'm looking for help on uninstalling gcc-5.4 since my priority is running CosmoSIS and gcc-4.8 is needed. I know there is no "uninstall" command for source-installed programs, but i need help on this: How can i uninstall a source-installed program?

Thank you in advance

3 Answers 3


Indeed, there is no "uninstall" command when installing from source, unless the developer has decided to put one in. (i.e., it's not impossible for a developer to create a script that undoes everything)

Your only option is to go into /usr/local/bin/ and remove each file yourself. But which ones to remove?

One solution is to reinstall 5.4, but specify a new directory that isn't /usr/local/bin/. This will give you a list of files that 5.4 installed. Then, using the list of files, go into /usr/local/bin/ and remove them manually. Note that it probably installed libraries and documentation into other directories, so to remove it completely, you will have to do more than just /usr/local/bin/.

An alternative is to not do an uninstallation and just install gcc 4-8 on top of 5.4. It's the same program, but just a different version. So gcc version 4.8 will overwrite 5.4. The "downside" is that you might have 5.4 files lying around, but they will just occupy (relatively little) space. It'll solve your problem and you can move ahead with what you want to do.

Of the two options, I'd pick the second one. The 5.4 files that remain won't affect your system. Relative to images, video, or almost any type of data, the space they occupy is fairly little (i.e., compiler, libraries, documentation is probably small). In the future, you should install it in another directory and add symbolic links manually. update-alternatives would do that for you if it's a package installed compiler; but for a compiler installed from source, that isn't an option.

(Aside: Ubuntu 14.04 has reached end of life, I think. You might consider upgrading some day... If so, then what /usr/local/bin/ looks like won't matter anymore!)

  • Security paches for ubuntu 14.04 are available through 2022 through the (maybe free) Canonical ESM support. See ubuntu.com/blog/…
    – ubfan1
    Jul 23, 2020 at 18:18
  • @ubfan1 Hmmmm, I'm not sure if it's free. But thanks for pointing that out. At the time that I wrote the above, I was referring to this news.
    – Ray
    Jul 24, 2020 at 13:56

Just create a symbolic link to gcc-4.8

cd /usr/bin
sudo rm gcc
sudo ln -s gcc-4.8 gcc

now try

gcc --version

And see if you got the desired result

  • while /usr/bin/gcc is very likely to be a symlink, it would be advisable to check first. Also, OP wants to uninstall gcc-5.4 so it would be nice if your answer addressed that...
    – Zanna
    Aug 3, 2017 at 9:35

I advise to use update-alternatives command as described in the answer How to choose the default gcc and g++ version?

You must log in to answer this question.

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