How to Install SQLite 3 on Fedora 40 or 39

SQLite is a robust database management system known for its efficiency and versatility. It offers a streamlined, serverless solution for various applications, making it a popular choice for developers. Below are some of the features of SQLite 3 that make it a popular option:

  • Serverless Architecture: SQLite operates without requiring a separate server, reducing complexity and resource usage.
  • Lightweight: With a minimal binary size, SQLite is ideal for applications where memory resources are limited.
  • Cross-Platform: SQLite works across multiple operating systems, making it versatile for cross-platform development.
  • Data Integrity: SQLite is ACID-compliant, ensuring your data remains secure and consistent.
  • Simple Storage: All database data is stored in a single file, simplifying backup and transfer processes.

SQLite’s unique combination of features makes it a compelling option for various applications. Whether you’re working on a mobile app, a web service, or any other software project, SQLite offers reliability and performance. With the introduction out of the way, the guide will provide instructions on installing SQLite 3 on Fedora 40 or 39 Linux.

Method 1: Install SQLite 3 via DNF

Update Fedora Linux Before SQLite 3 Installation

Before installing SQLite, ensuring your Fedora Linux system is up-to-date is essential. Updating the system helps to avoid potential conflicts or issues during the SQLite installation process. To update your Fedora Linux system, open a terminal and execute the following command:

sudo dnf upgrade --refresh

This command ensures that your system’s packages are updated to their latest versions, while the --refresh flag forces a refresh of the repository metadata.

Install SQLite 3 via DNF Command

The recommended method for installing SQLite 3 on Fedora Linux is to use the default appstream provided by Fedora’s repository. The appstream contains the latest stable version of SQLite 3, which has been tested for compatibility with Fedora.

To install SQLite 3, run the following command in your terminal:

sudo dnf install sqlite3

This command instructs the package manager (DNF) to install SQLite 3 from Fedora’s repository. Once the installation is complete, verifying the installed version of SQLite 3 is a good practice to ensure you have the correct version.

To check the version of SQLite 3, execute the following command:

sqlite3 --version

This command displays the installed SQLite 3 version, which should match the latest stable release in Fedora’s repository.

Method 2: Install SQLite 3 via source

Download the Latest SQLite 3 Archive

To obtain the latest or preferred version of SQLite 3, you may compile it from the source. First, visit the SQLite Download page and identify the latest version. Then, use the wget command to download the appropriate archive.


Replace {version} with the actual version number. Always check the SQLite Download page for the most recent version.

For example:


Extract the SQLite Archive

Once the archive is downloaded, extract the files using the following command:

tar xvfz sqlite-autoconf-*.tar.gz

Navigate to the Extracted Directory and Configure Prefix

Change the directory to the extracted folder to begin the compilation process:

cd sqlite-autoconf-{replace with version}

Replace {version} with the actual version number.

Now, configure the compilation with the desired installation prefix:

./configure --prefix=/usr

The output should resemble the following:

configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: executing depfiles commands
config.status: executing libtool commands

Compile SQLite with the make Command

To start the build process, use the make command along with the -j flag to specify the number of cores you want to utilize for faster compilation:

make -j {number_of_cores}

Replace {number_of_cores} with the desired number of cores for your system.

To determine the number of cores on your system, run:


For example, if your machine has two cores, use make -j 2. If you have 12 cores, you could use make -j 6 to dedicate half of your cores to the process.

Install Compiled SQLite 3 Binary

After the build process is complete, install SQLite using the following command:

sudo make install

The installation process will display output indicating the progress. Once installed, verify the installation and the version number:

sqlite3 --version

Following these steps, you have successfully compiled and installed the latest or preferred version of SQLite 3 from the source.

Testing SQLite 3 Installation

After installing SQLite 3, it’s essential to test its functionality to ensure it works as expected. This section provides step-by-step instructions to test SQLite 3 by creating a sample database, adding a table, inserting data, and querying the data.

Create a Sample SQLite 3 Database

First, let’s create a sample database named testdb using the following command:

sqlite3 testdb.db

This command creates a new SQLite database file called testdb.db in your current working directory.

Create a Sample SQLite 3 Table

Now, let’s create a sample table named employees with the following columns: id, name, and position. Enter the SQLite shell by running:

sqlite3 testdb.db

Once inside the SQLite shell, execute the following SQL command to create the employees table:

CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, position TEXT);

Press Enter to execute the command, you should see no output if the table is created successfully.

Insert Sample Data with SQLite 3

Next, insert sample data into the employees table using the following SQL commands:

INSERT INTO employees (name, position) VALUES ('John Doe', 'Manager');
INSERT INTO employees (name, position) VALUES ('Jane Smith', 'Developer');
INSERT INTO employees (name, position) VALUES ('Alice Johnson', 'Designer');

These commands insert three rows into the employees table with different names and positions.

Query the Data with SQLite 3

To confirm that the data has been successfully inserted, run a SELECT query to retrieve the information from the employees table:

SELECT * FROM employees;

You should see the following output, which displays the data stored in the employees table:

1|John Doe|Manager
2|Jane Smith|Developer
3|Alice Johnson|Designer

Exit the SQLite Shell with SQLite 3

Once you have finished testing, exit the SQLite shell by typing:


This command returns you to your regular terminal.

Configure SELinux for SQLite 3

SELinux (Security-Enhanced Linux) is a security module that enforces mandatory access control policies on Linux systems. If SELinux is enabled on your system, you may need to configure it to work with SQLite. This section provides step-by-step instructions on configuring SELinux for SQLite, ensuring proper access control and security.

Check the SELinux Status on Fedora

Before making any changes, verifying whether SELinux is enabled on your system is essential. To check the status of SELinux, run the following command:


If SELinux is disabled, you don’t need to perform any further actions. If it’s enabled, proceed to the next step.

Set the Appropriate SELinux Context for SQLite 3

SQLite stores its data in database files, usually with a .db extension. To allow SQLite to access these files, you must set the appropriate SELinux context for them. The httpd_sys_content_t context is typically used for web server content, so we’ll use that for our SQLite database file.

First, locate your SQLite database file. For this example, we’ll assume it’s located at /var/www/html/testdb.db. Replace the path with the actual location of your SQLite database file.

Next, run the following command to set the SELinux context for the database file:

sudo chcon -t httpd_sys_content_t /var/www/html/testdb.db

This command sets the SELinux context of the testdb.db file to httpd_sys_content_t, allowing SQLite to access the file under the web server context.

Verify the SELinux Context

To confirm that the context has been changed successfully, use the ls command with the -Z option:

ls -lZ /var/www/html/testdb.db

The output should show the updated SELinux context for the database file:

-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testdb.db

The httpd_sys_content_t context in the output indicates that the context has been set correctly.

Test SQLite 3 Access on Fedora

Now that you’ve configured SELinux for SQLite, it’s essential to test whether SQLite can access the database file. If you’re using SQLite with a web application, try accessing the application and performing some database-related tasks, such as creating a new entry, updating existing data, or deleting an entry.

If the application works as expected and can interact with the SQLite database without issues, the SELinux configuration for SQLite is successful.


Throughout this guide, we have covered installing and configuring SQLite 3 on Fedora 40 or 39 Linux. We updated Fedora Linux and installed SQLite 3 from the default repository. Then, we demonstrated how to compile SQLite 3 from the source to get the latest or preferred version. After installation, we tested SQLite 3’s functionality by creating a sample database, adding a table, inserting data, and querying the data. Finally, we provided instructions for configuring SELinux to ensure proper access control and security when using SQLite with Fedora Linux.

Joshua James
Follow me
Latest posts by Joshua James (see all)