Tag Archive for: Bash

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)

Are you a Web Developer running out of space in your hard disk?

Have you ever tried to remove those node modules that you never use anymore? You could get surprise about the tremendous amount of space you can recover.

Now, you can do it easily with npkill, a minimalist and elegant package that will recursively look for you node_modules and will show you the space they take. You can then select which ones you want to erase to free up space.

Do not install it, just use npx in any path you want.

npx npkill