LinuxCommandLibrary

erl

Start Erlang runtime environment

TLDR

Compile and run sequential Erlang program as a common script and then exit

$ erlc [path/to/file1 path/to/file2 ...] && erl -noshell '[mymodule:myfunction(arguments)], init:stop().'
copy

Connect to a running Erlang node
$ erl -remsh [nodename]@[hostname] -sname [custom_shortname] -hidden -setcookie [cookie_of_remote_node]
copy

Tell the Erlang shell to load modules from a directory
$ erl -pa [path/to/directory_with_beam_files]
copy

SYNOPSIS

erl [flags] [-- [init_args]]

PARAMETERS

-name Name
    Starts a fully qualified distributed node name (DNS-style)

-sname Name
    Starts a short-named distributed node (hostname limited)

-boot BootFile
    Specifies alternative boot file instead of start_clean

-boot_var Var Value
    Substitutes variables in boot file paths

-config ConfigFile
    Configures loaded applications via .config file

-args_file ArgFile
    Reads additional flags from file

-detached
    Runs daemonized, detached from terminal

-noinput
    No input; for embedded systems

-s Mod [Func [Args]]
    Starts application or evaluates function

-env Var Value
    Sets emulator environment variable

-extra Arg
    Passes argument to init process

-pa Path
    Adds path to code search path

-pz Path
    Adds path to end of code search path

DESCRIPTION

The erl command launches the Erlang runtime system (emulator), which executes Erlang bytecode compiled from .beam files. Primarily used to start an interactive shell for development, testing, and debugging Erlang/Elixir applications, it supports distributed nodes, custom boot scripts, and embedded systems.

When invoked without arguments, it enters the interactive Erlang shell (Erlang/OTP version prompt), allowing evaluation of Erlang expressions, module loading, and process management. Options enable node naming for distribution (-name or -sname), detached execution, environment variables, and application startup via -s.

It integrates with OTP (Open Telecom Platform) for fault-tolerant, concurrent systems. Common in telecom, web servers (e.g., Cowboy), and Elixir (via iex). Supports hot code loading, supervision trees, and remote shell access. Exits via halt() or Ctrl+C twice.

CAVEATS

Requires Erlang/OTP installed; long option lists can exceed arg limits on some systems. Distributed nodes need epmd running. Interactive shell halts on EOF unless -noinput. Not for Windows native.

DISTRIBUTED NODES

Use -name erl@host.example.com for global visibility; connect via net_adm:ping/1.

REMOTE SHELL

erl -remsh node@host attaches shell to remote node.

EMBEDDED MODE

erl -noshell -sname none -boot start_clean -s init stop for no-shell startup.

HISTORY

Introduced with Erlang 1.0 (1980s Ericsson prototype); stabilized in OTP R1 (1993). Evolved with OTP releases for concurrency, distribution. Now at OTP 27+; core to Elixir ecosystem since 2012.

SEE ALSO

erlc(1), escript(1), dialyzer(1), beam(1), epmd(8)

Copied to clipboard