How to restore TWRP recovery after encrypting internal storage on LineageOS 14.1 on Motorola G 2014 (titan)

I installed LineageOS 14.1 on an old Motorola G 2nd Generation (2014) android phone, also known as titan. All went well and it worked like a charm.

I wanted to encrypt the internal storage and accordingly, did so from the Settings -> Security option on the phone. It worked well and said the phone was encrypted.

However, when attempting to install a zip on the phone from Recovery (using Volume Down + Power buttons), I was surprised to find that there was no TWRP recovery available any more.

After taking a backup of the data on the phone, I decided to take a chance and again flash TWRP back to the phone over the current data.

Based on what I encountered, there was no data or system corruption. Use the below information at your own risk.

Put the phone into USB Debugging mode from Developer options.

Open a terminal window. Then entered the following:
Reboot phone into bootloader.
$ sudo ./adb reboot bootloader <enter>

Check that the phone device is connected to the computer.
$ sudo ./fastboot devices <enter>

Use fastboot to flash the twrp recovery image onto the phone.
$ sudo ./fastboot flash recovery twrp.img <enter>

Data was not impacted and TWRP restored.