Installing build essentials on Ubuntu
apt-get install -y build-essential  

Which will install the following packages:

  • The following extra packages will be installed:
    • binutils cpp cpp-4.8 dpkg-dev fakeroot g++ g++-4.8 gcc gcc-4.8
    • libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
    • libasan0 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libdpkg-perl
    • libfakeroot libfile-fcntllock-perl libgcc-4.8-dev libgmp10 libgomp1 libisl10
    • libitm1 libmpc3 libmpfr4 libquadmath0 libstdc++-4.8-dev libtimedate-perl
    • libtsan0 linux-libc-dev make manpages manpages-dev patch xz-utils
  • Suggested packages:
    • binutils-doc cpp-doc gcc-4.8-locales debian-keyring g++-multilib
    • g++-4.8-multilib gcc-4.8-doc libstdc++6-4.8-dbg gcc-multilib autoconf
    • automake1.9 libtool flex bison gdb gcc-doc gcc-4.8-multilib libgcc1-dbg
    • libgomp1-dbg libitm1-dbg libatomic1-dbg libasan0-dbg libtsan0-dbg
    • libquadmath0-dbg glibc-doc libstdc++-4.8-doc make-doc man-browser ed
    • diffutils-doc
  • The following NEW packages will be installed:
    • binutils build-essential cpp cpp-4.8 dpkg-dev fakeroot g++ g++-4.8 gcc
    • gcc-4.8 libalgorithm-diff-perl libalgorithm-diff-xs-perl
    • libalgorithm-merge-perl libasan0 libatomic1 libc-dev-bin libc6-dev
    • libcloog-isl4 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-4.8-dev
    • libgmp10 libgomp1 libisl10 libitm1 libmpc3 libmpfr4 libquadmath0
    • libstdc++-4.8-dev libtimedate-perl libtsan0 linux-libc-dev make manpages
    • manpages-dev patch xz-utils
Installing build essentials on CentOS
yum groupinstall "Development Tools"  
  • Installing for group install "Development Tools":
    • autoconf
    • automake
    • bison
    • byacc
    • cscope
    • ctags
    • diffstat
    • doxygen
    • elfutils
    • flex
    • gcc
    • gcc-c++
    • gcc-gfortran
    • gettext
    • git
    • indent
    • intltool
    • libtool
    • make
    • patch
    • patchutils
    • rcs
    • redhat-rpm-config
    • rpm-build
    • rpm-sign
    • subversion
    • swig
    • systemtap
  • Installing for dependencies:
    • apr
    • apr-util
    • avahi-libs
    • boost-system
    • boost-thread
    • bzip2
    • cpp
    • dwz
    • dyninst
    • emacs-filesystem
    • fipscheck
    • fipscheck-lib
    • gdb
    • gettext-common-devel
    • gettext-devel
    • gettext-libs
    • glibc-devel
    • glibc-headers
    • gnutls
    • kernel-devel
    • kernel-headers
    • libdwarf
    • libedit
    • libgfortran
    • libgnome-keyring
    • libmodman
    • libmpc
    • libproxy
    • libquadmath
    • libquadmath-devel
    • libstdc++-devel
    • m4
    • mokutil
    • mpfr
    • neon
    • nettle
    • openssh
    • openssh-clients
    • pakchois
    • perl
    • perl-Carp
    • perl-Data-Dumper
    • perl-Encode
    • perl-Error
    • perl-Exporter
    • perl-File-Path
    • perl-File-Temp
    • perl-Filter
    • perl-Getopt-Long
    • perl-Git
    • perl-HTTP-Tiny
    • perl-PathTools
    • perl-Pod-Escapes
    • perl-Pod-Perldoc
    • perl-Pod-Simple
    • perl-Pod-Usage
    • perl-Scalar-List-Utils
    • perl-Socket
    • perl-Storable
    • perl-TermReadKey
    • perl-Test-Harness
    • perl-Text-ParseWords
    • perl-Thread-Queue
    • perl-Time-HiRes
    • perl-Time-Local
    • perl-XML-Parser
    • perl-constant
    • perl-libs
    • perl-macros
    • perl-parent
    • perl-podlators
    • perl-srpm-macros
    • perl-threads
    • perl-threads-shared
    • rsync
    • subversion-libs
    • systemtap-client
    • systemtap-devel
    • systemtap-runtime
    • trousers
    • unzip
    • zip
    • base

The minimal build essentials installation on CentOS:

yum install -y gcc g++ kernel-devel