top of page

Installing GraphViz on Linux Ubuntu 18.04LTS

This is a quick and dirty tutorial to get Graphviz loaded on your Linux Ubuntu 18.04LTS. Visit the Graphviz site to learn more about the open-source graphing program.

First, you need to make sure you have the following dependencies installed:

sudo apt-get install flex

sudo apt-get install Perl

sudo apt-get install automake

sudo apt-get install bison

sudo apt-get install libtool

sudo apt-get install byacc

If you get an error at any point saying a dependency is missing, you need to use the "sudo apt-get install" command to update that package. If at any point you get a message indicating you do not have permissions to execute a command, try executing the command preceeded by "sudo".

Before continuing, Graphviz is a set of tools and not an executable IDE, therefore we need to download one. I chose Xdot, which can be installed by:

sudo apt-get install xdot

Next, we will download the Graphviz dependency. Graphviz no longer maintains Linux precompiled packages, so you will need to click on the appropriate link under the downloads tab, and download the package that is appropriate for your machine. In my case, I downloaded the Ubuntu package "cosmic", which can be found in the box on the right side of the page under "Download Source Package".

Open a terminal window (ctrl + alt + t) and navigate to your download directory.

cd ~/Downloads

Unzip the tarball file using the following commands:

tar xvzf filename.tar.gz

Now, move the file from downloads to the /opt folder which is where you should keep "optional" software.

sudo cp -r graphviz-2.40.1 /opt

And then remove the copy of the folder in the ~/Downloads location

sudo rm -r graphviz-2.40.1

Change the directory now to the /opt directory to continue setup.

cd /opt

Now, I suggest reading the INSTALL readme .txt file, but it is not entirely accurate. Before running ./configure, make, etc. To support the automake commands, the following command needs to be run as sudo before proceeding:

sudo aclocal

Then, the following commands can be entered in this order:

sudo automake

sudo ./configure

sudo make

sudo make install

The Graphviz tool set is now installed. Let's walk through a very quick example and note two important resources:


I highly recommend skimming over those resources before continuing.

Let's set up a demo graph file that is presented in the Graphviz pocket reference. Paste the following into a new file and name it "graph1.gv". Note that the white space is meant to denote a tab and not 6 spaces.

graph {

a -- b;

b -- c;

a -- c;

d -- c;

e -- c;

e -- a;


Save the file and close. To create the graph, we run the "dot" tool package and pass the parameters -Tps which specifies a PostScript (.ps) output. To explore this example further, read the "Drawing Graphs with dot" reference. Now, in the terminal change directory (cd) to the directory where you saved your "graph1.gv" file, and run:

dot -Tps graph1.gv -o

A new file named "" will be saved in the same directory as your "graph1.gv" file. Open the "" file using xdot to view.

Assuming everything worked properly, your graph should look like this.

Let's try another example, this time we will create a directed graph, or digraph. Paste the following into a new file and save it as "graph2.gv". Again, note the white space is intended to be a tab.

digraph { main -> parse -> execute; main -> init; main -> cleanup; execute -> make_string; execute -> print_f init -> make_string; main -> print_f; execute -> compare; }

Save and close the file. In the same process as before, change directory (cd) to the location of the "graph2.gv" file in the terminal and run:

dot -Tps graph2.gv -o

Just as before, a new file named "" should have been created in your directory which you can open and view. It should look like the graph below:

Now you can create simple undirected and directed graphs using Graphviz. Graphviz has many capabilities beyond these simple examples and I highly recommend reading over the aforementioned references and trying out a few of those applications on your own.


Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page