How To Install Lua Scripting Language on Ubuntu 20.04 | 22.04 LTS

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

In this tutorial, we will show you how to install Lua Programming Language in Ubuntu systems

Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications.  Lua is cross-platform, since the interpreter of compiled bytecode is written in ANSI C, and Lua has a relatively simple C API to embed it into applications.

Lua originated in 1993 as a language for extending software applications to meet the increasing demand for customization at the time. It provided the basic facilities of most procedural programming languages, but more complicated or domain-specific features were not included; rather, it included mechanisms for extending the language, allowing programmers to implement such features. As Lua was intended to be a general embeddable extension language, the designers of Lua focused on improving its speed, portability, extensibility, and ease-of-use in development.

Install lua on Ubuntu-APT method

Follow the steps below to get started with lua :

  • Update your Ubuntu system packages with running the below command:
sudo apt update -y && sudo apt upgrade -y
  • lua package is available on Ubuntu base repository. So You can install it directly as follows:
sudo apt install lua5.3 -y

Install lua on Ubuntu-Source file method

  • You can also install lua via running the following below commands to download the Lua source file from the official page:
mkdir lua
cd lua/
curl -R -O http://www.lua.org/ftp/lua-5.4.4.tar.gz
  • Then extract the downloaded package as follows:
tar zxf lua-5.4.4.tar.gz
cd lua-5.4.4
  • Compile the source code as shown below:
make linux test
  • Then run the make install command as follow:
sudo make install
  • Once installed, run Lua shell as shown:
lua

Create a lua program

After accessing the lua interpreter, type the below as a name of your program:

unixcop.lua

Then add the following file:

print("Hello Visitors!")
print("unixcop.com")
  • Make a lua file using your favorite editor:
vim unixcop.lua

Then add the following:

print("Hello Visitors!") 
print("unixcop.com")

Save and close the file, then run your program:

lua unixcop.lua

Install lua -Conclusion

That’s it

Thanks.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook