Where is My Linux GNU C or GCC Compilers Are Installed?

Where is my GNU C compiler? Where does the GNU C (gcc) compiler reside in the RHEL / Fedora / Debian / Ubuntu / CentOS Linux installation? How do I install GNU c/c++ compiler in Linux operating systems?

The GNU Compiler Collection (GCC) is a compiler system. It was created by the GNU Project supporting various programming languages such as C (gcc), C++ (g++), Objective-C, Objective-C++, Fortran (gfortran), Java (gcj), Ada (GNAT), and Go (gccgo).
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements GNU gcc
Est. reading time 5m

You need to use the which command to locate c compiler binary called gcc. Usually, it is installed in /usr/bin directory.


Open a terminal and then type the following which command to see Linux C Compiler location:
$ which g++
$ which cc
$ which gcc

Sample outputs:


Another option is to use the type command as follows:
$ type -a gcc
$ type -a cc
$ type -a g++

OR use the command command as follows:
$ command -V gcc
$ command -V cc
$ command -V g++

Sample outputs:

Fig.01: Using various shell command to find out GNU compiler location

Fig.01: Using various shell command to find out GNU compiler location

Displying gcc version:

Open terminal app and then type the following command
$ gcc -v
Here is what we see for GNU gcc c and c++ compiler:

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 

Installing GNU compiler collection

You need to use the up2date command or yum command or apt-get command/apt command to install GNI C/C++ (gcc) and required libs as per your Linux distro.

Note: You must login as root using su - or sudo -s command and then use command as per your distro.

If you are using Red Hat Enterprise Linux version 4.0 or older, type the command:

# up2date gcc

If you are using CentOS/Fedora Linux or RHEL version 5.0 or above, type the command:

# yum group install "Development Tools"

If you are using Debian /Ubuntu Linux, type the command:

$ sudo apt-get install build-essential
# apt-get install build-essential

Writing a sample test code

You can create a sample c code as follows:
$ vi foo.c
Append the following code:

/* my C program */
#include <stdio.h>
int main(void){
	char var_name[20];
	printf("May I know your name? ");
	scanf("%s", var_name);
	printf("Hello %s, let us be friends.\n", var_name);
	return 0;

Compile it as follows:
$ cc foo.c -o foo
$ ls -l foo
$ ./foo

Sample outputs:

May I know your name? Vivek
Hello Vivek, let us be friends.


You learned how to locate GNU gcc c and C++ compilers on Linux.

This entry is 6 of 13 in the Linux GNU/GCC Compilers Tutorial series. Keep reading the rest of the series:
  1. Ubuntu Linux Install GNU GCC Compiler and Development Environment
  2. Debian Linux Install GNU GCC Compiler and Development Environment
  3. CentOS / RHEL 7: Install GCC (C and C++ Compiler) and Development Tools
  4. Download and Install C, C++ Compiler on Red Hat Enterprise Linux 5 (RHEL)
  5. Mac OS X: Install GCC Compiler with Xcode
  6. Where is My Linux GNU C or GCC Compilers Are Installed?
  7. HowTo: Compile And Run a C/C++ Code In Linux
  8. RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers
  9. HowTo Compiling C Program And Creating Executable File Under a Linux / UNIX / *BSD
  10. How To Install ncurses Library on a Linux
  11. Linux Find Out What Compilers Are Installed or Available On The System
  12. Linux Find Out GNU gcc Compiler Version Used To Compile Running Kernel
  13. Howto see output of C program in Linux or UNIX

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 31 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
31 comments… add one
  • Jim Jan 13, 2009 @ 19:41

    Hi this help is awesome it helps me a lot , i was looking for this commands in pages of my country(peru) but i didn’t find anything . thanks a lot .

  • Ash Aug 22, 2009 @ 8:28

    You just saved my life! Thank you so much for the info…

  • Roger Sep 24, 2009 @ 11:07

    Thank you!

  • JAmesBondRobin Oct 24, 2009 @ 11:37

    Excellent work… Your help is really appreciate………….
    it helped me a lot

  • xoerk May 17, 2010 @ 11:21

    Thanks….save me tons of time,, :)

    • sagar sukumar Aug 30, 2010 @ 10:19

      thank u very much for the help

  • Mohammad Osman Goni May 3, 2011 @ 8:38

    This tutorial helped me much. Thanks

  • Bob Ebbert Dec 13, 2011 @ 19:41

    1000 Thank Yous.

  • Eb Bobbert Mar 18, 2012 @ 0:57

    thx, i just installed it, much appreciated.

  • nkartik Mar 23, 2012 @ 8:14

    The smallest question “what is the gcc version” and u had it…Thanx a ton!

  • shimeles May 7, 2012 @ 7:55

    when I install faad2-2.7 in Optiplex 780 in fedora 13 window the compiler display
    shime@localhost softwares]$
    [shime@localhost softwares]$ cd faad2-2.7
    [shime@localhost faad2-2.7]$ su
    [root@localhost faad2-2.7]# ./configure
    hecking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for gawk… gawk
    checking whether make sets $(MAKE)… yes
    checking build system type… i686-pc-linux-gnu
    checking host system type… i686-pc-linux-gnu
    checking for style of include used by make… GNU
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details.
    please help me how to solve this problem????

  • vidhu Jul 21, 2012 @ 9:25

    hi, when i type the command ‘ yum install gcc’ , i got a reply as ‘you need to be a root to perform this command…”
    what does it mean??

    • Brian Nov 17, 2012 @ 14:05

      It means you need to be superuser by using the command:

      Then it will prompt for a password, then you will be able to install using the same command.

      As an alternative log in as the root user.

  • vidhu Jul 21, 2012 @ 14:03

    when i giv the command “yum install gcc”, it says i need to be a root to perform this command… wht shld i do??

    • Halluka Aug 2, 2013 @ 16:22

      It means you need to google “you need to be a root to perform this command…”.

  • Ucok Jul 26, 2012 @ 2:10

    I have centos installed,
    ls -l glibc-*
    -rw-r–r– 1 root root 4596084 Jul 25 15:31 glibc-2.5-34.i386.rpm
    -rw-r–r– 1 root root 5459594 Jul 25 15:31 glibc-2.5-34.i686.rpm
    -rw-r–r– 1 root root 17249412 Jul 25 15:31 glibc-common-2.5-34.i386.rpm

    error when install rpm packet.
    rpm -ivh glibc-2.5-34.i386.rpm
    error: glibc-2.5-34.i386.rpm: rpmReadSignature failed: region trailer: BAD, tag 15872 type 2047 offset 28672 count 4238
    error: glibc-2.5-34.i386.rpm cannot be installed

    error when install tar.gz
    configure: error: no acceptable C compiler found in $PATH
    ]# gcc
    -bash: gcc: command not found
    (gcc not install).

    How to install gcc ?
    thx a lot

  • cameron Aug 29, 2012 @ 4:17

    I had the need to be in root to perform this command error so I thought Id share the solution I found (im using centOS). I used the command – sudo yum install gcc-c++

    BUT that is for c++ compiling so for C use sudo yum install gcc

    It seems that you need to put sudo in front of the command to use root 0.o maybe.

    • Brian Nov 17, 2012 @ 14:08

      Sudo will raise the priv level of the currently logged in user to execute the task listed after it (you can also find out more with: man sudo), it is like right clicking in Windows and selecting to run as administrator.

  • Mir Dec 6, 2012 @ 12:46

    I have several error to comiple SPEC2006. can you help
    specmake: icc: Command not found
    Error with make ‘specmake build’
    specmake: *** [spec.o] Error 127
    Command returned exit code 2
    Error with make!

  • gaurav saini Mar 24, 2013 @ 13:40

    how i get my c++ compiler in linux please give me steps n how i will compile my program

  • vidya Mar 28, 2013 @ 8:12

    hey what should we give for password? it’s not taking any characters

    • ad Apr 8, 2014 @ 8:30

      just enter your password(log in one)
      it will not show any thing on display but type your password & press enter .
      installation will start

  • babak Apr 9, 2013 @ 21:03

    i want to clean gcc4.3 in ubuntu and install gcc2.96 .
    i dont know how do .
    please help me .

  • Rajesh Aug 12, 2013 @ 12:11

    I have few problems with my gcc,I feel its not installed at all,when I type the following commands I get the following response

    # gcc -v
    -bash: gcc: command not found

    # sudo apt-get install gcc
    sudo: apt-get: command not found

    Please let me know how can I install gcc on my RHEL6

  • sachin kate Sep 12, 2013 @ 10:37


    i got error msg -can not access archive while insataling gcc
    what i have to do

  • sumit Oct 14, 2013 @ 10:28

    I found below error. Please help.

    [root@localhost objdir]# yum install gcc
    Loading “rhnplugin” plugin
    Loading “installonlyn” plugin
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Setting up repositories
    No Repositories Available to Set Up
    Reading repository metadata in from local files
    Parsing package install arguments
    Setting up repositories
    No Repositories Available to Set Up
    Reading repository metadata in from local files
    No Match for argument: gcc
    Nothing to do

  • Swapnil Apr 29, 2014 @ 12:02

    yum install gcc is not working in rhel 6 server.

    Please help

  • nagesh Aug 11, 2014 @ 7:15

    I am using Kubuntu
    When I am giving command “# apt-get install gcc”
    It will give error like this,
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package gcc is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package ‘gcc’ has no installation candidate
    Can you help me ?

  • Patrick Apr 23, 2016 @ 16:51

    Hi when I type in yum it says command not found. Help!!!

  • Ayushi Jun 8, 2016 @ 17:42

    I got exactly what i was looking for in this tutorial, Thanks!

  • Zina Jan 7, 2021 @ 10:58

    Thank you for the useful information. I have an issue when I use the “type” command, it gives the following output:

    gcc is /usr/bin/gcc
    gcc is /bin/gcc

    The same case is repeated when I run type cc and g++. Can you please help me to resolve this because Im having compiling issues.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum