In this tutorial, you will learn how to install Lua programming language on Linux.
Lua is a popular programming language that is used by many developers all around the world.
Lua is easy to learn, and very powerful at the same time.
You can use lua to build anything you want, whether it is an app, web app or even a game, you can easily achieve it by using Lua.
Install lua on Linux
Lua can be easily installed on any Linux distro, all you have to do is follow the steps below, and you should be able to use Lua on your machine, no matter the distro you are using.
For example, in this tutorial, we are running Ubuntu 22.04, and we'll be installing Lua on it.
Step 1 - Download Lua
First, you need to download the official tarball that contains Lua's source. This is the source that we'll be using to install Lua.
So to download Lua official tarball source, run the command below.
curl -R -O http://www.lua.org/ftp/lua-5.4.6.tar.gz
Step 2 - Install Lua
Install lua via terminal
Lua is available on universe repository of Ubuntu 22.04, which means you can install lua on your Ubuntu 22.04 machine via the terminal.
sudo apt install lua5.4
Install Lua from source
Now that you downloaded the official source from the official Lua's website. You can proceed to install Lua now.
1)First, you need to extract the tarball file. To do so, you can use the
tar zxf lua-5.4.6.tar.gz
2) Next, navigate to Lua's directory where the source was extracted.
3) Once you are in the Lua's source directory, you can now install Lua.
Simply run the command below, and you should be able to install Lua.
make all test
4) Lua should be now installed on your machine.
Step 3 - Add Lua to PATH
When you install Lua from the source, it won't be added automatically on your PATH variable, which means even after installing Lua, if you don't add the Lua's PATH on your
~/.bashrc file you cannot use lua from your terminal.
To be able to use Lua in your terminal, so you don't have to use the full path in order to run Lua, simply run the command below to add Lua to your PATH.
/home/owlhowto/lua-5.4.6/src with your path. This is the path where you installed Lua.
Step 4 - Use Lua
Now that Lua is in your PATH, proceed to source your
~/.bashrc file in order to save changes and make them permanent, so you are able to use Lua right away without having to reboot.
Next, simply use Lua
In this tutorial, you learned how to install Lua programming language on Linux.