Tag Archive for: Bash

Convert JPG Images to Optimized WebP

mogrify -format webp -quality 80 -strip -resize "1024x>" *.jpg

This command creates optimized WebP versions of your JPG images while intelligently handling image sizes, only larger images are resized, and smaller ones are left unchanged. The original JPG files remain untouched, with new WebP versions created alongside them.

Use oathtool command line for 2 step verification (2FA)

You don’t need to use GAMMA Authenticators or closed private apps that generates 2 step verification (2FA) codes on your phone. Keep it simple and under your control, use oathtool command:

oathtool -b --totp 'private_key'

This will give you an output with the code you need whenever you want, ex:

521319

Read IO-Link sensor info

First of all, you need to check your IO-Link master and sensor to know how to proceed, but in most cases between different manufacturers is quite similar thanks to IO-Link standard.

Let’s check an IM5184 sensor connected to port 2 in a AL1350 master at 192.168.0.20

curl

curl -d '{"code":"request","cid":1,"adr":"/iolinkmaster/port[2]/iolinkdevice/iolreadacyclic","data":{"index":1002,"subindex":1}}' http://192.168.0.20

httpie

http POST 192.168.0.20 code=request cid:=1 adr=iolinkmaster/port[2]/iolinkdevice/iolreadacyclic data:='{"index":1002, "subindex":1}'

This would give us an hexadecimal value ready to use.

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json
Transfer-Encoding: chunked

{
    "cid": 1,
    "code": 200,
    "data": {
        "value": "00022FE5"
    }
}

Detect your IO-Link masters

If your IO-Link masters are connected to your network, you can use arp-scan command-line tool to discover and fingerprint ARP (Address Resolution Protocol) hosts.

sudo arp-scan -l

How to compress a folder with a password using the terminal?

If you can’t (or don’t want to) right click over the folder itself you can do as follows.

zip -er name_you_want.zip folder
  • e = encryption (use password)
  • r = recursive (everything inside that folder)