How To Install Erlang on Debian 11

In this tutorial, you will learn to Install Erlang on Debian 11.

The Erlang programming language is a general-purpose, simultaneous and garbage-collected programming language, which also serves as a runtime system. The sequential derivative of Erlang is a functional language with firm calculation, single assignment, and dynamic data entry, which concurrently follows the Actor model.

Steps To Install Erlang on Debian 11

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Installing Erlang Programming Language on Debian 11

First of all, you need to install some required packages on your server with the following command:

sudo apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https curl -y

Then, use the folloiwng comand to import the Erlang GPG key:

curl -fsSL https://packages.erlang-solutions.com/debian/erlang_solutions.asc | sudo gpg --dearmor -o /usr/share/keyrings/erlang.gpg

Next, import the Erlang repository to your server by using the command below:

echo "deb [signed-by=/usr/share/keyrings/erlang.gpg] https://packages.erlang-solutions.com/debian bullseye contrib" | sudo tee /etc/apt/sources.list.d/erlang.list

Update your local package index with the command below:

sudo apt update

Finally, use the following comamnd to install Erlang:

sudo apt install erlang -y

Now you can easily launch your Erlang shell on Debian 11 with the following command:

erl
Output
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

Eshell V13.0.4  (abort with ^G)
1>

Here are some comon useful commands that you can use:

q(). Quits the shell and the Erlang runtime
c(file). Compiles the specified Erlang file
b(). Displays all variable bindings
f(). Clears all variable bindings
f(X). Clears specified variable binding
h(). Prints the history list of commands
e(N). Repeats the command on line N
v(N). The return value of line N
catch_exception(boolean). Sets how strict the shell will be in passing errors
rd(Name,Definition). Defines a record type Name with contents specified by Definition
rr(File). Defines record types based on the contents of File
rf(). Clears all record definitions. Can also clear specific definitions
rl(). Lists all current record definitions
pwd(). Gets the present working directory
ls(). Lists files at the current location
cd(Directory). Changes to the specified Directory

Build a Test Program with Erlang

At this point, you can test your Erlang installation on Debian 11 by creating a simple hello world program.

First, create a file with your favorite text editor, here we use vi:

sudo vi helloworld.erl

Add the following script to the file:

-module(helloworld).  % The name of our module.

-export([helloworld/0]).  % Declaration of the function that we want to export from the module.

helloworld() -> io:format("Hello World!! Thanks Orcacore.com ~n").  % What is to happen when the function is called, here: Hello world is to be written on the screen.

When you are done, save and close the file.

Then, open your Erlang shell:

erl

Compile the file program Hello World test you just created using the following command:

c(helloworld).
Output
Eshell V13.0.4  (abort with ^G)
1> c(helloworld).
{ok,helloworld}

Next, compile the program:

helloworld:helloworld().
Output
2> helloworld:helloworld().
Hello World!! Thanks Orcacore.com
ok

To exit from your Erl shell, run the command below:

q().

For more information, you can visit the Erlang Documentation page.

Remove Erlang Programming Language

If you no longer want to use Erlang on Debian 11, first, remove the software using the following command:

sudo apt autoremove erlang --purge -y

You should remove the APT repository from your sources list for complete removal:

sudo rm /etc/apt/sources.list.d/erlang.list

Also, you can remove the GPG key:

sudo rm /usr/share/keyrings/erlang.gpg

Coclusion

At this point, you have learned to Install Erlang on Debian 11 and create a sample project.

Hope you enjoy it.

You may be like these articles:

Reset Root Password on Debian 11

How To Enable BBR on Debian 11

Upgrade Debian 10 to Debian 11

2 COMMENTS
  1. As being a newbie, I am exploring online for articles which could be of assistance to me. Yours is very helpful happy to have discovered it. Cheers.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular