How To Install Erlang on Ubuntu 22.04

This tutorial intends to teach you to Install Erlang LTS on Ubuntu 22.04. Erlang is a functional programming language and runtime environment. If you have asked yourself Why should you use Erlang in your project? Here are some amazing features of Erlang that you can interest in this programming language:

  • Concurrency
  • Scalability
  • Fault-Tolerance
  • Hot Swapping
  • High Availability
  • Reliability

In this guide, you will learn to Install Erlang in the latest version by importing its repository to your Ubuntu 22.04.

How To Install Erlang on Ubuntu 22.04?

To complete this guide, you must log in to your server as a non-root user with sudo privileges. For this purpose, you can follow this guide on Initial Server Setup with Ubuntu 22.04.

Now follow the steps below to complete this guide.

Step 1 – Add Erlang GPG Key on Ubuntu 22.04

To install the Erlang LTS, you must import the GPG key and its repository. First, run the system update with the following command:

sudo apt update 

Then, install the required packages with the command below:

sudo apt install software-properties-common apt-transport-https lsb-release

Next, use the following curl command to import the Erlang GPG key:

curl -fsSL https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/erlang.gpg

Step 2 – Erlang Installation on Ubuntu 22.04

At this point, run the system update and install Erlang by using the following command:

# sudo apt update 
# sudo apt install erlang

Step 3 – How To Access Erlang Shell?

Now to access your Erlang shell on Ubuntu 22.04, simply run the command below:

erl

In your output, you will see:

Output
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]

Eshell V12.2.1  (abort with ^G)
1>

Step 4 – Test Erlang Programming Language

At this point, you can create a test program to see that your Erlang is working correctly.

To do this, create a sample hello world file with the following command:

vi hello.erl

Add the following Erlang code to the file:

% This is a test Hello World Erlang Code
-module(hello).
-import(io,[fwrite/1]).
-export([helloworld/0]).

helloworld() ->
   fwrite("Hello, Erlang World!\n").

When you are done, save and close the file.

Then, log in to your Erlang shell with the command below:

erl

Then, from your Erlang shell compile your program with the following command:

c(hello).

Next, run your program with the command below:

hello:helloworld().

You can see the steps as shown below:

Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]

Eshell V12.2.1  (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:helloworld().
Hello, Erlang World!
ok
3>

As you can see your Erlang is working correctly on your server.

Conclusion

At this point, you have learned to Install Erlang LTS on Ubuntu 22.04 and access your Erlang sell and test your app that is working correctly or not. Erlang has amazing features that you can use to create your programs.

Hope you enjoy it. You may be interested in these articles on the orcacore website:

Install Gnome Desktop Environment on Ubuntu 22.04

Set up OpenJDK 17 on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!