Runar Ovesen Hjerpbakk

Programmer. Software Architect. Technical Manager.

Linux

Lookup IP from DNS name

As you can read from this blog, operations was never my main interest. But in these days of DevOps, I’m getting exposed to more hosting environments than I’ve ever been before.

Since I was a small child I knew about ping to check if a server was online and see its IP-address. Today I learned about nslookup.

Read More

Simplify your crontab entries with crontab.guru

As you’ve seen from my previous posts, I’ve used cron a lot lately to schedule periodic tasks on my RaspberryPi. cron is driven by crontab, cron table files, configuration files that specifies shell commands to run periodically on a given schedule.

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; 
# │ │ │ │ │              7 is also Sunday on Raspbian)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  command to execute

The timing syntax is understandable enough. In addition to numbers, we can use special operators:

*	any value
,	value list separator
-	range of values
/	step values

An expression to achieve At 22:00 on every day-of-week from Monday through Friday looks like this:

0 22 * * 1-5

My problem is that I get the elements confused. Without reading the explanation, is 22 in the expression above minute or hour? You have to read the spec to find out.

Read More

Shrinking a Raspbian installation to save space

Yet another Pi post!

When I put Raspbian on the SD card used by my Raspberry Pi, I used the Raspbian Stretch with desktop version. That was perhaps a poor choice on my part, as I use the machine as a headless server. However, I’m not that skilled with Desktop Linux, so the mere fact that there were buttons to push during the installation and stuff actually worked, made me feel like a pro.

All those packages that I’ll never use, like LibreOffice, still take up precious space, so I wrote a simple script to remove some of them.

Read More

Automatically update and upgrade Raspbian

Continuing the theme of last night, today I improved the upgrade experience of my Raspberry Pi.

Manual upgrade

As per the documentation, update and upgrade are as easy as running these two commands. First update your system’s package list:

sudo apt -y update

Then upgrade all installed packages to their latest version:

sudo apt -y dist-upgrade

I use -y to answer yes to all prompts by default. Easy enough, but in our modern DevOpsy world, we need to automate this.

Read More

Automatically update OpenSSH on a Raspberry Pi

I just bought myself a gorgeous Raspberry Pi 3 Model B+ to use as a headless server and all-round tinkering machine. It’s small, power efficient and fast enough for my usage:

  • Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
  • 1GB LPDDR2 SDRAM

Enable SSH support

Installation is super easy, just follow the instructions on Raspberry Pi website, with one exception. As of the November 2016 release, the default Raspberry Pi OS, Raspbian, has the SSH server disabled by default.

To enable SSH, you need to either configure it after OS installation has completed as per instructions here, or while preparing your SD card:

For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled, and the file is deleted. The content of the file does not matter: it could contain text, or nothing at all.

Read More