05 April 2024

A recent question on firebird-support about using Firebird on Xubuntu, and the problems the asker ran into, lead me to trying it out myself. This post is basically a collection of the steps I took to get Firebird up and running on Xubuntu.

I’m usually a Windows user, and although I have collected some Linux knowledge over the years, I’m far from an expert. In other words, this might not be the optimal to do things.

Preparing the VM

To start, I’m installing Xubuntu as a Hyper-V virtual machine, as it’s included in my Windows 11 Pro installation. If you don’t have Hyper-V, you might be able to use something like Virtual Box.

I downloaded the Xubuntu 23.10 (Mantic Minotaur) desktop ISO image through https://xubuntu.org/download/#non-lts.

In the Hyper-V Manager, I created a new VM using the "Quick Create" option:

  • Select the “Local installation source” option and browse to and select the ISO image.

  • Uncheck the “This machine will run Windows (enables Windows Secure Boot)” option

  • Optionally, click on “More options” and set the name and network for the VM (I used the name “Xubuntu 23.10”)

    Screenshot of the Hyper-V Quick Create screen showing the options entered as described above
  • Click “Create Virtual Machine” to start the VM and start the installation process

  • Wait for Hyper-V to initialize the VM, and then click on “Connect”

  • Hyper-V displays a message that the virtual machine is turned off, click on “start”

  • A Grub (Linux boot loader) window is shown, select the “Try or install Xubuntu” option, or wait for it to start automatically

Installing Xubuntu

Now, the Xubuntu installer allows you to select your language, and either “Try Xubuntu” or “Install Xubuntu”.

  • Select “Install Xubuntu”

  • Choose your keyboard layout, and click “Continue”

  • On the “Updates and other software” screen, leave the defaults as is, and click “Continue”

  • On the “Installation type” screens, choose the appropriate option for your installation. Given we’re installing a VM, which has its own virtual harddrive, the standard option “Erase disk and install Xubuntu” is good, and click “Install now”

  • On the “Write the changes to disks” confirm the change by clicking “Continue”

  • On the “Where are you?” screen select your location (this is for the timezone configuration), and click “Continue”

  • On the “Who are you?” screen enter the requested information, and click “Continue”

The installation will now install Xubuntu in the VM. This can take a while depending on your machine and internet speed.

After a while, the “Installation Complete” popup will show

  • Click “Restart Now”, and wait for Xubuntu to start up.

  • When the VM has restarted, enter the password you set previously to login

Installing Firebird

Now we’re ready to install Firebird.

As I said before, I’m normally a Windows user, so maybe some steps taken are not the optimal way to do things.

We’re going to install Firebird from the terminal.

  • To start a terminal, press Alt+F2 which will popup the “Application Finder”

  • Type “term” and select the “xfce4-terminal”, and click “Launch”

Although the latest Firebird version is Firebird 5.0.0, Xubuntu comes with Firebird 3.0.11, through the Ubuntu and ultimately the Debian projects. It is also possible to install Firebird using the installer from the Firebird site, but for this blog, I’m using the package provided by Xubuntu.

Although the terminal is textual, I will show screenshots of terminal output. That is because I’m writing this blog on Windows, and — at least by default — you can’t share the clipboard between the Hyper-V VM and the host, and I’m too lazy to find out if this can be changed or to use an alternative like exchanging files between the VM and the host.

In some cases I do provide textual output, but there I have transcribed the output (possibly with typos), or — for isql output — retried it on Windows and copied and modified the output to match the output in the VM.

First, I’m going to show how you can find what — if any — Firebird packages are available. This might help you if you’re using a future Xubuntu version, which for example might provide Firebird 4.0 or Firebird 5.0 instead of Firebird 3.0

  • To find packages, you can use apt search. To look for packages with “firebird” in their name or description, enter apt search firebird:

    Output of 'apt search firebird'

    It lists multiple packages, but the ones we’re interested in are the packages starting with “firebird3.0”, and primarily the “firebird3.0-server” package. Some of the other packages, like for example “flamerobin”[1] might also be of interest to you.

  • To install a package, you use apt install, but installation requires super user privileges (comparable to Windows Administrator privilege/UAC), so you need to run it with sudo (which means as much as “do as super user”).

    Run sudo apt install firebird3.0-server, and when prompted enter your password (the user created by the installer is allowed to elevate its privileges to a super user).

  • apt will show which packages it will install in addition to firebird3.0-server. Confirm with Enter or enter Y followed by Enter

  • The installer will prompt for a password for the SYSDBA user (the main administrator account for Firebird).

    For purposes of this blog, I’m using the well-known password “masterkey”, but for a real installation, please use a strong password.

    You can also let the installer generate a random password for you by leaving the password empty. You can find this password in the /etc/firebird/3.0/SYSDBA.password file. For a secure installation, don’t forget to delete this file later.

    Enter a password followed by Enter.

  • Wait for the install to complete

    Output of 'sudo apt install firebird3.0-server

Using Firebird Server

The Xubuntu “firebird3.0-server” package also installs the “firebird3.0-utils” package, which includes isql-fb, a commandline query tool for Firebird. In a “default” Firebird installation, this tool is actually called isql (short for Interactive SQL), but because other database systems and for example UnixODBC also use a tool called isql, this Debian/Ubuntu/Xubuntu package renamed it to isql-fb.

For more information on isql/isql-fb, you can read the Firebird’s isql Interactive SQL Utility manual.

After installation, the Firebird server will have been started automatically, and is ready for immediate use.

File and directory layout

The layout of files for the Xubuntu Firebird installation differs from “default” Firebird installations.

The location of some important files:

Configuration files like firebird.conf, databases.conf, etc

/etc/firebird/3.0/

Security database

/var/lib/firebird/3.0/system/security3.fdb

Log file

/var/log/firebird/firebird3.0.log

The default expectation of the Xubuntu package is that you put (server-based) database files in /var/lib/firebird/3.0/data. If you want to put it somewhere else, make sure the directory is owned by the user firebird, and — optionally, but recommended — the group firebird.

Unfortunately, specifying a relative path when creating a database puts it in /tmp, so make to sure to specify an absolute path, or define an alias in /etc/firebird/3.0/databases.conf before creating the database.

  • A simple example of creating a database through the localhost Firebird server:

    mark@xubuntu2310-vm:~$ isql-fb -user sysdba -f stdin
    Enter password:
    Use CONNECT or CREATE DATABASE to specify a database
    SQL> create database 'localhost:/var/lib/firebird/3.0/data/testdatabase.fdb' default character set UTF8;
    SQL>
Stopping and starting Firebird server

You can stop and start the Firebird server in two ways:

  1. Stop: /etc/init.d/firebird3.0 stop
    Start: /etc/init.d/firebird3.0 start

    This will call systemctl of the next option.

  2. Stop: systemctl stop firebird3.0.service
    Start: systemctl start firebird3.0.service

Both options will prompt you for your password through a popup, or you can run the command with sudo to get the prompt in the terminal.

Using Firebird Embedded

Firebird also comes with an embedded mode, which allows you to access databases without going through Firebird server. However, using Firebird Embedded does require some care, because by default it will share things like lock files and temporary directories with the normal Firebird installation (and this is recommended!).

Given the privileges required to access those directories, for normal Firebird Embedded usage, this means that you need to add yourself to the firebird group.

  • Run sudo usermod -a -G firebird <your-username>

  • Next run newgrp firebird to make the additional group privileges available to your user account

    The command newgrp firebird only has effect in your current terminal. As long as you don’t log out and log back in, you will need to run newgrp firebird in each new terminal you open!

    If you expect to start a lot of different terminals, you may want to log out and log back in before continuing, as it removes the need for using newgrp.

  • Example connecting using Firebird Embedded to the database created previously:

    mark@xubuntu2310-vm:~$ isql-fb -user sysdba /var/lib/firebird/3.0/data/testdatabase.fdb
    Database: /var/lib/firebird3.0/data/testdatabase.fdb, User: SYSDBA
    SQL>

    The difference with connecting through the server is that we don’t specify a hostname, and we only need to specify a username, and no password. The fact that you have filesystem access to the database is considered sufficient authorization to access the database. The username is used to determine which privileges and roles you have available within the database.

Creating a database in your home directory

When using Firebird Embedded, you can also create databases in your home directory. These databases will only be accessible by your user account (unless you compromise security by giving the firebird user and/or group access to your home directory, which you should not do).

mark@xubuntu2310-vm:~$ isql-fb
Use CONNECT or CREATE DATABASE to specify a database
SQL> create database '/home/mark/personal-database.fdb';
SQL>

You do need to specify the absolute path (or you can use ~ to resolve your home directory). If you don’t specify a username when starting isql-fb or in the CREATE DATABASE statement, it will use your Linux username as the database username:

SQL> select current_user from RDB$DATABASE;

USER
===============================
MARK

SQL>

The End

This concludes the quick tutorial on installing Firebird on Xubuntu. If you want to know more about Firebird, consult the documentation on the Firebird website.

For questions, you can reach out to the community on firebird-support.


1. FlameRobin is a GUI query tool for Firebird