In compliance with high industry standards

Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Most Useful Raspberry Pi Commands

Raspberry Usage

Introduction

Raspberry Pi commands allow us to work on a wide range of applications. From building a prototype to developing an existing software, Raspberry Pi can provide the support.

In this blog, you will learn 5 really useful commandline tools to use your Raspberry Pi or Raspberry PLC in a safe environment.

Raspberry Pi PLC

Related links

How to connect Raspberry PLC to Wifi


Read >>

Basics about Raspberry Pi PLC analog outputs


Read >>

How to find yor perfect industrial PLC


Read >>

Raspberry PLC
family products


Read >>

How to program Raspberry PLC interrupt inputs with Python


Read >>

Touchberry Pi
family products


Read >>

Explanation

Let's see the most basic and commonly used Raspberry Pi Commands

Vcgencmd measure_temp


Vcgencmd is a command line utility that can get various pieces of information from the VideoCore GPU on the Raspberry Pi.

Vcgencmd measure_temp

It is important to know the raspberry temperature, because excessive heat can lead you to unwanted situations. In fact, those who overclocked the processor of the Raspberry, must check the temperature frequently, because all the Raspberry pi models perform a degree of thermal management to avoid overheating under heavy load. The SoCs have an internal temperature sensor, which software on the GPU polls to ensure that temperatures do not exceed a predefined limit. 

When the core temperature is between 80ºC and 85ºC, a warning icon showing a red half-filled thermometer will be displayed, and the ARM cores will be progressively throttled back.

So, use measure_temp option, to get the temperature of the SoC (System on Chip) as measured by the on-board temperature sensor, to help you with the temperature control of your device.

Check out the next URL to know more about vcgencmd: 

Htop


Htop is a really powerful command line utility that allows you to interactively monitor your system's vital resources or server processes in real-time.

It is quite similar to the top command. However, since htop is a newer program compared to top, it offers many improvements. 

Htop also supports mouse operations, uses colors in its outputs and gives visual indications about processor, memory and swap usage. 

It also prints full command lines for processes and allows one to scholl both vertically and horizontally for processes and commandlines respectively.

You can install it by doing:

sudo apt update
sudo apt install htop


So, if you run htop in the command line, you will get something like this:

Htop








Finally, if you click on F1, you will get some help about the possibilities and you will see how it works.


Htop

Dmesg

The linux kernel is the core of the operating system that controls access to the system resources, such as CPU, I/O devices, physical memory, and file systems. The kernel writes several messages to the kernel ring buffer during the boot process and when the system is running. 

The kernel ring buffer is a portion of the physical memory that holds the kernel's log messages. It has a fixed size, which means that once the buffer is full, the older logs records are overwritten.

Dmsg is used to examine or control the kernel ring buffer. It is really useful for examining kernel boot messages and debugging hardware related issues. The default action is to display all messages from the kernel ring buffer.

So, just execute it like:

dmesg

Usage

dmesg [options]

If you see that the dmesg command shows too many messages that you are not able to read, then find the words you really want to find using | grep:

dmesg | grep eth0


Dmesg

To know more about this command and its options, just type:

dmesg -h
or
man dmesg


Comma and braces operators

We can do lot with comma and braces operations, to make out life easier, let's see few usages:

  1. Rename and backup operations with comma & braces operators

  2. Pattern matching with comma & braces operator

  3. Rename and backup (prefixing name) operations on long file names

  4. To copy files from a parent directory without typing two times the long path

1.- To backup hello.txt to hello.txt.bak:

cp hello.txt{,.bak,}

2.- To revert the file from hello.txt.bak to hello.txt:

mv hello.txt{.bak,}

3.- To rename the file with prefix "1-":

cp hello.txt 1-!#^

4.- To copy files from a parent directory without typing two times the long path

cp firstDir/secondDir/thirdDir/{hello.txt,bye.txt}

Comma and braces operators


Ctrl + R

Can you image that you could autocomplete your commands with the ones that you typed before? Something like Google Autocomplete. Would be really useful, right? That is possible opening up a terminal windows and just trying the following:

1.

Ctrl + R

Ctrl + R


2. Start typing your command and some suggestion will appear:

Ctrl + R


3. If you want to type the suggested command, then click on the Tab, or the right arrow of your keyboard, and that suggested command will be set on your commandline ready to use. In case you want to see more suggested commands, then try Ctrl + R again until you see the command you want to execute.

Ctrl + R


Finally, some tricky commands

1. Type "rev" to reverse the message to type:

rev

Rev


2. Type "factor <number>" to factor any number:

Factor


3. Finally, just type the following, and see what happens:

apt moo

apt-get --help | grep -i cow
Moo

Looking for your ideal PLC?

Take a look at this product comparison with other industrial controllers Arduino.

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC controller comparison >>

Do you want more information?

Just fill the form!

Tell me more!