Linux Basics For IOT Projects

If you’re having trouble following that IOT tutorial or need a quick reference for Linux, we’ve got you covered.

Linux basics for IoT projects

One of the best aspects of the internet of things {IoT} is that the barrier to entry for homespun projects is very low. Complete novices can pick up an Arduino or Raspberry Pi starter kit and learn and build as much as they would like, or spend a little more money and purchase a complete system.

Open source Linux-based operating systems are a very popular choice for small IOT projects. This can be the end of the project line for many, as Linux can be a daunting task for first-timers.

If you’re having trouble following that IOT tutorial or need a quick reference for Linux, we’ve got you covered.

This introduction will explain common commands and Linux principles for your IOT projects.

Make sure to check out our Linux commands infographic if you need a quick reference.

Abstract purple tile pattern

What is Linux?

Linux is an open source platform which runs servers and systems across the world, it is an operating system that sends information between hardware and software. All laptops and desktops come with a built-in operating system, but Linux has features that other operating systems do not have and is a more efficient and wide-ranging option for small projects.

Linux is released in different flavors called distributions; distributions have been configured and built for a specific purpose. Distributions can come loaded with tools and a beautiful graphic display, or be as secure and as minimal as possible.

Even if you have never heard of Linux, you have probably interacted with it in some form, maybe even today. Linux powers much of the internet, including most of the major search providers and many servers that control information traffic.

Why Use Linux For Projects?

Linux is easy to install and there is no need to be intimidated by the prospect of getting started.

It is popular for small projects because it is easy to use, flexible and offers the user the chance to take more control of a project. Linux can use low battery power when a project calls for it, or handle millions of requests an hour with a webserver. The ability to customize the operating system makes Linux the best choice for IOT projects.

Raspberry Pi

For an introduction to home projects, a Raspberry Pi is the ideal device. This gives entry-level tinkerers the chance to do their own programming and operate their computers and systems themselves. There is no need to be an IT expert, there are plenty of educational resources that explain how to operate the Raspberry Pi successfully.

Raspberry Pi has its own specially designed operating system called Raspbian. It can be easily installed on your Raspberry Pi and gives customers the flexibility to manage their own project from the ground up.

Common Linux commands

Linux terminal in Raspberry Pi
Common Linux terminal. Raspbian Default © Raspberry Pi Foundation

Many Linux based projects use the command terminal to input commands and directions. The scripting language used in Linux shell is called Bash. Often times Bash used in tutorials can be confusing, or difficult to follow. You might run into these common Linux commands in IOT projects, below is a description of their use:

CP – CP is used for copying files and directories

Example: CP [filenames] [destination-dir]

MV – This allows you to move files and directories. Can also be used to rename files.

Example: mv [filename] [new_filename]

mv [filename] [destintation-dir]

ECHO – This command is a little more complex. It sends text to the standard output. The standard output can easily be redirected to a file, this can be useful for creating small scripts easily from the command line.

Example: echo “Test String \n test string 2” > teststring.sh

This will create a file named teststring.sh with the following output:

Test String

test string 2

LS – This command will list the files contained in a directory. You can use it with the -A command to show hidden files, or with -LH to show file details.

Example: LS [option]

GREP – This is used within Linux to search for text. It can be used to search a directory or an individual file. GREP has many options, we would suggest you read more about them here

Example: GREP [option] [string] [file or dir]

RM – Use this command to remove or delete certain files or directories.

RMDIR – this command is the one to use when you want to remove an empty directory.

MK/DIR – allows you to make or create a directory. When you want to make a new file or to create a directory to put files in, the MK/DIRE function is the one to use.

SUDO – is a function that allows users to execute programs at an administrator level. It is wise to use this command instead of being logged in under an administrator profile. File permissions and administrator privileges can have serious implications for security, if you need to learn more about SUDO and SU please read this post.

Linux Permissions

One of the main features that appeal to customers of Linux is security. It is regarded as being extremely strong and one of the most secure operating systems that are available for computers.

There are various permissions within Linux, such as read, write or execute. Permissions control a user’s ability to read or, make changes to a file, or add a file into a directory.

Linux IoT Project Setup
Linux is very commonly used for IoT projects, as it is lightweight, open source, and free

There are various groups within the Permission function, including Owner, Group, Other and All Users.

Once you have mastered the Permissions functions, you can ensure all of your permissions are set correctly. You can initialize a file using a three-number sequence such as 640 and 755 via a function called CHMOD. A CHMOD 755 command allows the owner of the file or directory to read, write and execute the file. It doesn’t allow all these functions for other users.

There are also a set of advanced permissions that can be set on your computer using Linux for those who want more secure setup.

Moving On

Linux for IoT projects can be a great fit for those that can harness its power. The best part about Linux is that Linux is so flexible it has an application for almost every use. Learning Linux Bash commands can be daunting at first, but it is as easy as learning a few basic commands and soon you will be flying around the terminal.

Check Out Our Handy Infographic to Help You Get Started

Please like and share:)