2

based on Ubuntu 12.04 man page for which

which returns the pathnames of the files (or links) which would be exe- cuted in the current environment, had its arguments been given as com- mands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not follow symbolic links.

I also know that if you want to make sure you have installed a program, you can type dpkg -l | grep myprogram.

Recently, I downloaded gcc41 and g++41 from a deb package. I installed them with the following command : sudo dpkg -i gcc41-compat-4.1.2_i386.deb g++41-compat-4.1.2_i386.deb.

My problem is that when I type dpkg -l | grep gcc I see this

ii  gcc                                    4:4.6.3-1ubuntu5                        GNU C compiler
ii  gcc-4.5                                4.5.3-12ubuntu2                         The GNU C compiler
ii  gcc-4.5-base                           4.5.3-12ubuntu2                         The GNU Compiler Collection (base package)
ii  gcc-4.6                                4.6.3-1ubuntu5                          GNU C compiler
ii  gcc-4.6-base                           4.6.3-1ubuntu5                          GCC, the GNU Compiler Collection (base package)
ii  gcc41-compat                           4.1.2                                   No description
ii  libgcc1                                1:4.6.3-1ubuntu5

As you can see, gcc41-compat is installed, but when I type which gcc41 there is not any result. Based on the man page that I mentioned above, I should see something. Where is it? Or which part of my conclusion is wrong?

1 Answer 1

3
  • which

    which gives location of binary installation directory. It is used as which <pkgname>

    So the command

    which gcc
    

    gives

    /usr/bin/gcc
    
  • dpkg -i

    dpkg -i is used for installation.It has nothing to do with finding a package directory.

  • dpkg -l

    dpkg -l is used to find if a package is installed or not.dpkg -l <pkgname> will give you an output with names of installed packages matching the given name.dpkg -l gives list of all packages.

  • write

    It is used to send message to other user.

    I can't tell why you used this one.

  • grep

    to show only the relevant part of the output.it is useful when piping commands.


  1. If you want to find if gcc is installed, the best shot for you would be to use

    dpkg -l|grep gcc
    

    This will show all packages(installed) containing gcc in it's name,

    You could also use dpkg -l gcc but it gives output showing only those packages which contain only gcc.

  2. If you want to check the location of the gcc binary that is in your $PATH, try

    which gcc
    

    Though there are few others too.

You must log in to answer this question.

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