bash: Number of Days Between Today and Some Future Date

printf -v date '%(%Y-%m-%d)T\n' -1                                 
echo $(( ($(date -d $1 +%s) - $(date -d $date +%s)) / 86400 )) days

Above is a bash script to output the number of days between today and some future date. Copy it into a file, e.g.,, into a directory, e.g., ~/bin/scripts. Then, enter the directory you saved it to and type to make it executable:

$ chmod +x

Then, check your .profile to make sure something like this in it:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then                             

Then, run the script.

$ 2021-06-01
70 days

I have to figure out the difference between today and some future date all the time for forecasting, and today was the day I finally bothered to figure out how to do it from the command line. I have to start thinking of ways to make shell scripts to do this little tasks that I go to the web for.

Fun With Fortune in Linux

Fortune provides a random quote or aphorism every time you open a terminal in Linux. I wanted to have a personalized fortune using zuihitsu quotes posted on this site come up whenever I opened a terminal. If you want to do something similar, here’s the procedure.

To check if you have it installed, simply type fortune into the terminal.

$ fortune 

This either returned a fortune or an error message. If you got an error message, then install fortune using the package manager for your system.

$ sudo apt install fortune-mod

Let’s create our own file of fortunes. I want to use my zuihitsu quotes I have posted on this site. This file is a text file that looks like so:

quote 1
quote 2
quote ...

There is a copy of the file available online.

If you have just a file with lines of quotes, this is easy to get into this format using emacs. Simply type: M-%, followed by c-q c-j Enter then c-q c-j % c-q c-j Enter. I like to check the replacements, so just keep hitting y to do the replacement and move on to the next one if it looks good. Save the file to the appropriate directory, which on Debian systems is /usr/share/games/fortunes, but can vary. For explanation purposes, we are going to assume the file was named zuihitsu with no file extension.

Note: If you are using the file above, just save it as a text file in your directory. Then, copy it to the appropriate system directory without a file extension.

Now, create a .dat file for the file you just made.

$ sudo strfile zuihitsu

Set the same permissions on the new files as the others in the directory. This just makes the files readable to groups and others.

$ sudo chmod o+r zuihitsu
$ sudo chmod g+r zuihitsu
$ sudo chmod o+r zuihitsu.dat
$ sudo chmod g+r zuihitsu.dat

Following the rest of the directory. I added a symbolic link.

$ sudo ln -s zuihitsu zuihitsu.u8

You should be able to test it now.

$ fortune zuihitsu

Assuming that worked. The final thing to do is to have your preferred shell call this when it runs. I use bash, so I added the command above to my bash_aliases file. From then on, it will pull a random quote from the zuihitsu file every time you bring up the terminal.


Make a fortune come up automatically every time you login or open a new terminal by adding the following to .bashrc or .bash_aliases:

fortune zuihitsu 

Also, if you use mutt, you can add the following to your .muttrc file to have this fortune file generate a random signature for your emails:

set signature="fortune zuihitsu -s|"

The -s selects shorts quotes and the | pipes it to your email text.

Did you know the original fortune-mod fortune collection is available as a EPUB?

GOG Games on Linux, Featuring Blade Runner

Blade Runner is a point-and-click adventure, a genre that was still very popular on PCs at the time of its release. Games like Beneath a Steel Sky had already used the format to tell Blade Runner-inspired cyberpunk stories. Given the usual state of movie adaptations, a Blade Runner adventure game wouldn’t necessarily have been anything to get excited about.‘Blade Runner’ really does make you feel like a detective

What Westwood did with the license, however, was inspired. The game isn’t a straight retelling of the movie. (Harrison Ford’s Deckard is nowhere to be seen.) You play a detective named Ray McCoy on the tail of replicants linked to vicious animal murders. While the story takes place at the same time as the movie and involves some of the same locations and characters, it plays out in parallel without intersecting too strongly. This was a great decision for a narrative adventure, allowing the game to evoke the movie without feeling predictable.

-Sam Byford, “The resurrected Blade Runner game is a genuine classic.” The Verge. December 18, 2019.

Blade Runner is currently on sale for $8.99 until January 2nd, 2020, at 2 PM UTC. And, if you are into free (as in beer!) games, and who isn’t, you could also download the previously mentioned Beneath a Steel Sky for nothing.

But, there’s a catch. GOG doesn’t provide much help getting these games installed on a Linux system. I didn’t see any instructions, but let me save you some time. I documented what I did to get it to work, and now, you have the very instructions that should be on the GOG website, but are somehow, inexplicably, not there. We’re going to use Blade Runner as our example, but while I was looking into how to get this thing running, it was apparent that these problems happen on the Linux platform with many of GOG’s games.

Installing & Getting the Games to Work

Before starting, let’s make life easy for ourselves and get an outdated audio library that is needed in order for the game to launch.

$ dpkg -i libsndio6.1_1.1.0-3_amd64.deb

You’re also going to need Simple DirectMedia Layer 2, which you can install the standard way, through the repository:

$ sudo apt-get install libsdl2-net-2.0-0

Now, with those preliminaries out of the way, let’s get to the task at hand, shall we? Download the Blade Runner file from the GOG website. Open a terminal:

$ cd Downloads
$ chmod +x 
$ ./ 

After installation, it should be in your Show Applications, which is in the bottom right corner for people using the standard Gnome window manager, and then, select the game you’ve just installed, if it isn’t Blade Runner.

Or, maybe you’ve learned to love the terminal, you could launch the game from the command line by opening a terminal:

$ cd GOG\ Games/Blade\ Runner/
$ ./

The game should launch from this point. If not, contact GOG and …Good Luck!

Webster’s Revised Unabridged Dictionary (1913) on StarDict on Ubuntu/Debian

So, after reading “You’re probably using the wrong dictionary,” I thought I would give installing Webster’s Revised Unabridged Dictionary (1913) on a Debian-flavor of Linux a try and write it up the process and some observations of its use.

Installation on a Debian-flavor of Linux is straight-forward:

$ sudo apt-get install stardict
$ cd Downloads
$ wget
$ unzip
$ cd dictionary
$ tar -xvjf stardict-dictd-web1913-2.4.2.tar.bz2
$ cd stardict-dictd-web1913-2.4.2/
$ sudo mv *.* /usr/share/stardict/dic/
$ stardict

This launches the main application. There is also a mini-window that can be moved to where you like and then you can use it with other applications by highlighting text. Here’s a screenshot of this article:

When you highlight a word, it will automatically be searched for and displayed in the mini-window.

Entries include pronunciation, etymological origin, related words, definition and an example of usage, often from literature. I can imagine this being a very useful tool. It might be worth checking if my writing from this date changes in an appreciable way and whether it is an improvement or not.

Setting DNS Manually on Ubuntu Linux

Introduction: Domain name servers (DNS) provide the numerical addresses for sites on the Internet. When you type into your browser, your computer queries a DNS name server to get a numerical address. This numerical address is then used to contact the site.  Normally, configuring DNS is handled behind the scenes by Dynamic Host Configuration Protocol (DCHP) automatically.

For some situations, you’ll want to set a different DNS server than the one set by DCHP. Maybe your Internet Service Provider (ISP) uses their own DNS server that is slower than Google’s DNS server. Maybe you use a Virtual Private Network (VPN) and want to stop DNS leaks to your ISP.

In Linux and other UNIX-like operating systems in the past,  you would change configuration files, such as /etc/resolv.conf or /etc/dchp/dhclient.conf, to set DNS manually. 

The problem: Changing resolv.conf and dhclient.conf configuration files does not work in Ubuntu.

The solution: Starting with 17.10, Ubuntu uses netplan to set DNS. On my test machine, netplan’s configuration file looks like this:

version: 2
   renderer: NetworkManager

It is possible to manually do the job of DCHP in netplan, but it’s complicated. If your objective is to just change the DNS servers, there is an easier way to do it. Use Network Manager.

There are files in the directory /etc/NetworkManager/system-connections that define how DCHP should work for each network connection. To the files listed in that directory, add the following with DNS server IP addresses under [ipv4]:


The DNS servers in this example are from FreeDNS and DNS Watch.

After adding the DNS IP addresses, separated by a semi-colon, then from the command line, do: sudo service network-manager restart

Once completed, you should be on your DNS server of choice. It’s a little inconvenient to have to add these lines to each network-connection file, and there might be a better way. But, this will work.