Hi guys in this article we'll learn how to Install, Compile and Run C++ program in Ubuntu. Just follow this basic steps:

  • Open Terminal in Ubuntu OS.
  • If you are new to Ubuntu then, first you have to execute following command.


sudo apt -get update



  • Now, you have to check for g++ compiler.Type g++ in Ubuntu Terminal.
  • If it say "g++ not found".
  • Run following Command.

sudo apt install g++


  • After Installing g++.
  • Type Following Commands.
  • Create File:

touch filename.cpp
  • Write Code:
cat  > filename.cpp
  • Now write your code and exit writing mode by pressing Ctrl+C.
  • Compile Code:

g++ filename.cpp
  • This will create a output file "a.out" in your current working directory.
  • Run output file:
. /a.out
Video Tutorial: