The Command Line
The Omega’s operating system (OS) is based on Linux, a popular open-source OS that powers servers and computers all over the world. The version on the Omega is a minimalistic and lightweight distribution called LEDE, which stands for Linux Embedded Development Environment. It supports many programming languages and and can run all kinds of complex projects while still being small enough to fit in the Omega’s memory.
The Command Line Interface
We interact and operate the Omega by using the command line interface (CLI). The CLI is the user’s access point into the operating system using a text-based terminal program. All user interaction is interpreted and executed by the OS through instructions, or commands. A user enters a command into a terminal to make something happen.
The CLI can look something like the picture below. In this terminal program on Windows, the green box is where the commands you type will be displayed on the screen.
We’ll cover how to do the following:
- Navigating through the filesystem
- Creating (and deleting) files and directories
- Creating and modifying text files
In Linux, everything is a file. So naturally, the file system is where a great deal happens. The filesystem of LEDE is organized like a tree. At the very bottom of a tree is the root, and so it is with our filesystem.
/ is the universal symbol for the very bottom of the filesystem - the root directory. All the files that the OS has access to can be found under some directory under
This is not to be confused with the
root directory. In LEDE, every user gets their own ‘home’ directory to store all their personal files. On the Omega, this is located at
/root/ by default. When we connect to Omegas’ command line via
ssh, we connect as the root and get placed inside the
/root/ folder. (Connecting via serial will place us in
In Linux systems,
~ is an alias for the home directory, and can be used in scripts and programs. For example, calling a file in
~/myProject is equivalent to calling
On the Omega, all the contents in the
/root/ directory will be preserved through any firmware updates. So for our experiments, we’ll try to store our files in there so they stay put!
The home directory on other Linux systems may look like
Interacting with the Filesystem
Navigating is very useful, but doing things with files is what gets projects working! So to do that, we’ll go over commands to create and delete directories, and creating and removing files.
We’ll cover the
touch commands to create things, and the
rm command to get rid of them.
mkdir command allows us to create empty directories. Run it like so:
You can use both relative and absolute paths. See the example below:
root@Omega-ABCD:~# mkdir hello # relative path root@Omega-ABCD:~# ls hello root@Omega-ABCD:~# mkdir /root/hello/world # absolute path root@Omega-ABCD:~# cd hello root@Omega-ABCD:~/hello# ls world
touch command can be used to create files. The syntax looks like this:
- If the file doesn’t exist yet, it creates an empty file.
- If the file already exists, it updates the time it was last modified to when you ran the command.
You can check the file’s last modified time using
ls -l like in the example below:
root@Omega-ABCD:~# touch hello.txt root@Omega-ABCD:~# ls -l -rw-r--r-- 1 root root 0 Mar 23 23:38 hello.txt # we've created our file root@Omega-ABCD:~# cat hello.txt root@Omega-ABCD:~# # nothing happens, the file is empty ... (wait a minute or two) ... root@Omega-ABCD:~# touch hello.txt # update the time it was last modified root@Omega-ABCD:~# ls -l -rw-r--r-- 1 root root 0 Mar 23 23:41 hello.txt # the modified time updated!
Deleting Files and Directories
Delete a file using the
rm command like so:
To delete a directory and all of the files inside it, run:
rm -rf <DIRECTORY>
These two options are explained below:
-r- recursive mode
- This means to go into a directory and delete all of the files inside.
- If it finds more directories, it enters them and deletes their contents as well.
- This is required when deleting directories, otherwise it will return an error.
- This will make the program continue if it runs into an error when trying to delete a file.