The shell

Jaume Olivé Petrus edited this page May 5, 2018 · 33 revisions

Lua RTOS has an integrated shell that allows you to execute commands in a linux similar way. The shell is disabled by default, but you can enable it typing in the prompt, or putting in the system.lua file.

The shell command are organised into the following categories:

Utility commands


Clear the terminal screen.

luac source [destination]

luac is the Lua compiler. It translates programs written in the Lua programming language (source argument) into binary files ([destination] argument) that can be later loaded and executed.

The main advantages of precompiling chunks are: faster loading, protecting source code from accidental user changes, and off-line syntax checking.

Precompiling does not imply faster execution because in Lua chunks are always compiled into bytecodes before being executed. luac simply allows those bytecodes to be saved in a file for later execution.

destination argument is optional, and if it's not provided the compiled filename is the source filename postfixed with the "c" character.


-- Compile test.lua into test.luac file
luac test.lua test.luac

-- Compile test.lua into test.luac file
luac test.lua

File system commands

cat file

Print the file on the standard output.

/ > cat system.lua
-- system.lua
-- This script is executed after a system boot or a system reset and is intended
-- for setup the system.

-- Main setups
os.loglevel(os.LOG_INFO)   -- Log level to info
os.logcons(true)           -- Enable/disable sys log messages to console             -- Enable/disable shell
os.history(false)          -- Enable/disable history
/ > 

cd directory

Change the working directory to directory.

/ > cd examples
/examples > 

cp source destination

Copy the source file to the destination file.

/ > cp autorun.lua autorun.old

edit filename

Edit the filename.

ls pattern

Lists directory contents of files and directories that matches the pattern.

/ > ls *.lua
f	       0		autorun.lua
f	    2446		system.lua
f	    2445		config.lua
f	     252		test.lua
f	     280		test2.lua

mkdir directory

Creates a new directory named directory in the current directory.

more file

Print the contents of file one screen at a time.

mv source destination

Move (rename) the source file to the destination file.


Print name of current/working directory.

/examples > pwd
/examples > 

rm pattern

Remove the files that match the pattern.

Network commands


Prints information about the status of the network interfaces.

/ > netstat
wf: mac address 24:0a:c4:01:96:ec
   ip address / netmask
   gw address
  ip6 address fe80:0000:0000:0000:260a:c4ff:fe01:96ec

en: mac address 00:00:00:00:00:00
   ip address netmask
   gw address

ping host

Send ICMP ECHO_REQUEST to network hosts to test connectivity between Lua RTOS an the host.

/ > ping
PING ( 32 data bytes
60 bytes from icmp_seq=1 time=35.515 ms
60 bytes from icmp_seq=2 time=39.351 ms
60 bytes from icmp_seq=3 time=35.153 ms
60 bytes from icmp_seq=4 time=35.429 ms
60 bytes from icmp_seq=5 time=35.362 ms
60 bytes from icmp_seq=6 time=35.490 ms
60 bytes from icmp_seq=7 time=35.216 ms
60 bytes from icmp_seq=8 time=35.389 ms
60 bytes from icmp_seq=9 time=35.739 ms
60 bytes from icmp_seq=10 time=35.223 ms
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 35.153/35.787/39.351/1.199 ms

System commands


Print the syslog contents on the standard output.

Note: dmesg is only available if the underlying storage for your root filesystem is not the SPI FLASH.


Changes the root password, used to establish a ssh connection to Lua RTOS.


Prints the Lua RTOS up time (the time that Lua RTOS is up since last reboot).

/ > uptime
23:42 up  0:04:14


Reboot the system.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.