Linux

LocalSend - Share files between local devices

Sometimes you need to move files between devices, and it’s often been quite a hassle to just being able to get a file from a Windows machine to an iPad or from Linux to a Mac laptop.

My most common case has often been to move files between MacOS and Android - and while Wifi File Explorer Pro has worked, it’s always seemed a little clumsy. It basically create a webserver on the Android device with a simple but quite usable interface.

Transcoding for local streaming

My home network has a local streaming service based on a local Plex server. It has a few videos wwhich came in odd formats, and where for practical purposes it would be nice to have everything in the same format.

This is my way of transcoding everything to the same format before adding it to the Plex server.

This little script will take all files in the the same directory as the script (given the 4 extentions) and encoding all to Xvid format. The Xvid format is my current prefered format balancing size and quality - and allow for Chromecasting. It may change to a H265 format once all the oldest Chromecast devices are updated and all can handle H265.

Welcome to the new server

Hello from a new server

The most recent years this site was run of a Digital Ocean Droplet. A Droplet is their fancy name for a virtual private server (VPS) on shared hardware, but not anymore.

Generally I’ve been quite happy on Digital Ocean and they’ve provided a stable service through years. There was how ever a few things which caused an opportunity to move away.

  • I was running on a 32bit OS, and needed to reinstall the Droplet to move to a current OS.
  • They products and features offered by Digital Ocean seems to be more Corporate than my needs.
  • While the price of 7.5 Euro a month for a server doesn’t seem that expensive, it’s been steady for years without any upgrades to CPU or memory.

Sourcing a few recommendations, welcome to the new server - again a VPS - hosted by Hetzner in Germany.

Hello Tailscale, Goodbye fixed IP at home

I have for many years paid to have a fixed IP number at home. The main reason was to allow me to access servers and have the remote access restricted to the home IP number. This was just one of many layers of the security of the server and the SSH setup, but no more.

I’ve been playing with (Tailscale)[https://tailscale.com/] which essentially provide an overlay network and allows you to have a secure private network across the public internet. Tailscale has a free plan perfectly suitable for my uses and clients for just about any machine, so getting all machines attached to a private network through Tailscale is surprising easy.

What's the IP number?

If you’re jumping around on servers and need to figure out what the IPnumber(s) of the server are, here’s a little bash line which usually works (tough with a few catches):

ifconfig eth0 | grep inet | awk '{ print $2 }'

This command assume the eth0 is the public WAN interface in the server. If there are more network cards this may not be correct - or the only interface for the net.

Show wifi password in clear

Got access to a wifi network, but forgot the password? No a problem. At least not if you have a windows, Mac or Linux machine with access. All these OSes can basically without restrictions show you the wifi password in clear text.

Windows

Once you have access to the wifi network. Open the commandline and enter the following command replacing “SSID” with the actual name of the wifi network you want to retrive the password to.

netsh wlan show profile name=SSID key=clear

Cronjob: Basics and reboot

One of Linux five star things is the cronjobs. They allow you to automatically run stuf (scripts, applications, etc.) at quite specific times.

The crontab is the place controlling when the stuff is run and you can list the crontab using the commaand crontab -l for the current user.

If you want to edit the crontab, just use the command crontab -e and it launches the crontab in the default editor (set EDITOR env variable to change the editor used). The format is basically like this:

Batch converting JPG and PNG to WebP

I’ve been speed optimizing some of my personal sites, and one easy update is changing the images from being JPEGs and PNG images to the smaller WebP format.

All the images I need to convert are usually in collections, where one folder at a time needs conversion and as some contain a lot of images, I needed a way to do it smartly.

This is what I came up with:

For JPEGs

find . -type f -name "*.jpg" | while read file; do cwebp -lossless "$file" -o "${file%.jpg}.webp"; done

For PNGs

find . -type f -name "*.png" | while read file; do cwebp -lossless "$file" -o "${file%.png}.webp"; done

The one-liners find all jpegs (or pngs) in the folder and converts it into a lossless webp version. It leaves the original image as a backup. For further optimizations the “cweb -lossless” could be changes to:

Automatic MacOS shutdown

From time to time my Mac is doing stuff which takes quite awhile. Converting images, converting videofiles between formats or other stuff, which may take a long time (but reasonable predictable).

In those cases I run a little command in the terminal, to automatically shut down the Mac upon completion:

sudo shutdown -h +120

This command sets a timer which shutdown the machine after two hours (the 120 parameters being after 120 minutes).

Linux - No space left on device, yet plenty of free space

My little server ran into an issue, and started reporting the error:

No space left on device

No worries, lest figure out which disk has full and clean up…

Using the df command with the -h (for human-readable output) it should be easy to find the issue:

root@server:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 483M 0 483M 0% /dev
tmpfs 100M 3.1M 97M 4% /run
/dev/vda 20G 9.3G 9.4G 50% /
tmpfs 500M 0 500M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 500M 0 500M 0% /sys/fs/cgroup
cgmfs 100K 0 100K 0% /run/cgmanager/fs
tmpfs 100M 0 100M 0% /run/user/1000

Strange. Notice who the /dev/vda is 50% fillled and all other disk devices seems to be finde too. Well after a little digging, thinking and googling, it turns out device space consists of two things - space (for data) on the device and iNodes (the stuff used to mange the space - where the data go - simplified).