Gibin Francis
2 min readMar 16, 2022

IoT Edge Dev Quick Book

Please find my quick book for IoT Edge development

IoT Edge

List IoT Edge modules

iotedge list

Check IoT Edge configs and deployment issues

iotedge check

Show logs from IoT Edge module

iotedge logs modulename

IoT Edge Version

iotedge version

Restart one module in IoT Edge

iotedge restart modulename

Stop IoT Edge

sudo systemctl stop iotedge

Start IotEdge

sudo systemctl start iotedge

Restart IotEdge

sudo systemctl restart iotedge

Date Time

Know the date and time on the edge device and we can verfiy that the UTC time stamp is synced

timedatectl

Update timeserver

sudo apt install ntpdate
sudo timedatectl set-ntp off
ntpdate pool.ntp.org
sudo apt install ntp
sudo nano /etc/ntp.conf

then you can see content like below, please add your ip or domain of timeserver. Add on top for getting high priority

server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst

then follow below steps

sudo systemctl restart ntp
ntpq -p

Get date details

date

Logs

Get module logs from the tail 500(- - tail 500 ) and keep getting the logs from there onwards ( -f )

iotedge logs --tail 500 -f

Get logs files with last 50 lines

tail -n 50 /folder/logfilename.log

Get the logs files to zip

tar zcvf /tmp/logs.tar.gz /folder/*.log

Listing all log files

//get into the admin
sudo su
ls -lrt /var/lib/docker/containers/*/*-json.log -h

Truncating all json log files

truncate -s 0 /var/lib/docker/containers/*/*-json.log

Remove specific file

rm -r filename-json.log

Folder

All permission to specific folder

sudo chmod a+rwx /foldername

Create User

sudo useradd <username>

Add user to specific group

sudo usermod -a -G <groupname> <username>

change owner of a folder

sudo chown -R <username>:<groupname>/foldername

Memory

Get disk space information

df -h

Get memory details

free

Get active docker status

sudo docker stats

Ge running process and Process Id

ps -aux

Docker

List running docker images

sudo docker ps 

List all docker images

sudo docker images -a

Prune all images

docker image prune -a

Execute commands on docker

docker exec -it <container> /bin/bash
docker exec -it <container> bash

Environment variables — Ubuntu

Get your ubuntu/linux version

lsb_release -a

List all environment variables

env

Print specific environment variable — Adding ‘$’ before the key will print the environment variable value

$envVarName

set environment variable

export envVarName='value'

remove environment variable

unset envVarName

conditionally check environment variable

[ -z "$envVarName" ] && echo "Empty: Yes" || echo "Empty: No"

conditionally check environment variable and update if empty

[ -z "$envVarName" ] && export envVarName='value'

conditionally check environment variable and update with existing other env variable if empty

[ -z "$envVarName" ] && export envVarName=$otherEnvVarName

Gibin Francis
Gibin Francis

Written by Gibin Francis

Technical guy interested in MIcrosoft Technologies, IoT, Azure, Docker, UI framework, and more

No responses yet