Skip to main content

AI for Linux

Chapter #3: How to Boost Your Linux Terminal Workflow with Fabric AI

This guide will show you how to install and use Fabric AI on Linux to streamline tasks for system administrators and developers.

Having a tool integrated directly into your terminal that assists with day-to-day tasks can be a game-changer. AI-powered tools are increasingly helping developers and system administrators streamline their workflows.

You’ve likely already used tools like ChatGPT or DeepSeek, which have gained popularity for their impressive performance and affordability.

While these tools are powerful, they’re primarily designed as web-based chatbots. To use them, you need to open a browser, ask your question, and then copy the output back into your terminal or the other way around. This back-and-forth can be time-consuming and disrupt your workflow.

Tools like Fabric solve this problem by integrating AI assistance directly into your terminal. With Fabric, you can get contextual help, generate commands, and automate repetitive tasks - all without leaving the command line. It also offers additional functionality beyond standard chatbot capabilities.

In this guide, we’ll cover what Fabric is, how to install it on a Linux system, and walk through practical examples and use cases that demonstrate how it can enhance productivity for system administrators and developers alike.

What is Fabric AI?

Fabric can be defined as a powerful framework that offers a wide range of functionalities. It’s not limited to a single feature - instead, it provides a complete suite of services and tools. These functionalities are known as “Patterns.” A Pattern is essentially a function that performs a specific task, and you can invoke the one that best fits your needs.

Built on top of Go, Fabric delivers high performance and simplicity. According to its official GitHub repository, the tool's primary objective is to enhance human productivity by leveraging AI through a unified interface capable of handling multiple tasks.

Under the hood, Fabric utilizes Large Language Models (LLMs) such as OpenAI and others to power its capabilities. It functions entirely within the command-line interface, making it a natural fit for Linux users who prefer terminal-based workflows. Interaction is streamlined through built-in Patterns designed to simplify a variety of tasks.

Some of Fabric’s key capabilities include:

  • Assisting with code generation and improvement
  • Summarizing lengthy content
  • Creating content such as blog posts and social media updates
  • Automating YouTube tasks, such as extracting metadata and summaries

All of this can be done directly from the terminal, without switching between tools or contexts.

Install Golang in Linux

As mentioned earlier, Fabric is built using Golang, so having Go installed on your system is a prerequisite. Before proceeding with the Fabric installation, make sure Go is available on your machine. If it's not already installed, you'll need to install it first.

You can verify if Go is installed by running:

go version

If you get a "command not found" error or Go is not the required version, follow the steps below to install the latest version of Golang on your Linux system.

If you are on Debian or a Debian-based distribution, you can easily install Go with the command:

sudo apt install -y golang

If you are on Fedora/Red Hat, install Go using the command:

sudo dnf install -y golang

These commands will install the version of Go available in your distribution’s default repository. However, this may not be the latest official release.

For example, at the time of writing, the latest Go version is 1.24, but your distribution might provide an older version.

To verify the installed version, use:

go version

You’ll see output similar to:

go version go1.20.5 linux/amd64

Install Fabric in Linux

After installing Golang, installing Fabric is simple with one command, which will install Fabric directly from the repository. It may take some time as it needs to download all its dependencies.

go install github.com/danielmiessler/fabric@latest
Install Fabric in Linux

Add the Go environment variables to your .bashrc to ensure it functions correctly using this command:

# Golang environment variables
export GOROOT=/usr/local/go
export GOPATH=$HOME/go

# Update PATH to include GOPATH and GOROOT binaries
export PATH=$GOPATH/bin:$GOROOT/bin:$HOME/.local/bin:$PATH

To check if Fabric is installed and working correctly, just enter the command fabric and hit Enter, you should see this screen:

Test Your Fabric Installation

Once the download and installation are complete, the next step is to configure the tool. As mentioned earlier, it requires a Large Language Model (LLM) to function. You can choose the LLM provider that best suits your needs. In this guide, we'll use OpenAI as an example.

First, you’ll need to obtain an OpenAI API key. If you don’t already have an OpenAI account, create one using this link and then navigate to the API keys page.

Click on “Create secret key” to generate your API key.

Create an OpenAI Key

Hit"Create secret Key", copy it, and save it, we will need it later to set up the tool.

Set Up Fabric in Linux

After generating the OpenAI key, we are ready to set up the tool to use OpenAI as the behind-the-scenes platform. You can also choose another provider if you prefer; Fabric gives you the option to select which one to use.

To start the setup, run the following command:

fabric --setup

This will start the instructions to configure the tool. The first thing it will ask is to choose the LLMs you want.

Choose LLM for Fabric

Since we’re using OpenAI as the LLM provider, select option 1 and press Enter. You’ll then be prompted to enter the API key you generated earlier.

Enter Your OpenAI API Key

Next, you will be prompted to enter the base URL. You can leave the default value unchanged and press Enter to continue.

Enter Base URL

Next, run the same command again and select option 12 to download the patterns. When prompted for the repository, simply press Enter to accept the default value.

Download Fabric Patterns

Next, the tool will prompt you to specify a default folder name. You can leave the default value unchanged and press Enter to proceed.

Add Default Folder Name

The tool will begin downloading the necessary patterns to your local configuration. Once completed, it will prompt you to configure the AI vendor.

From the list of available options, select option 11 and press Enter.

Downloading Necessary Fabric Patterns

Next, you’ll be prompted to select the OpenAI model version you wish to use. The available options depend on your subscription plan. For this guide, we'll proceed with the free-tier model, gpt-3.5-turbo.

Select OpenAI Model Version

Next, it will ask for the context; leave it as it is and hit Enter.

Add Model Context

Now we have configured all the required plugins, and we can start using the tool.

How to Use Fabric in Linux

After installing and setting up Fabric, you can start using it directly from the terminal. Just pipe your command, code, or file content into fabric with a specific pattern like explain, summarize, or fix to get AI-powered responses instantly without leaving your terminal.

Code Explanation

As mentioned earlier, Fabric can assist with a variety of tasks, one of the most useful being code explanation and debugging.

If you're working with a script and encounter issues such as syntax errors, logic bugs, or simply need help understanding what the code does, Fabric can analyze the file and provide clarity or corrections.

Let’s walk through with an example by creating a file named mybash.sh with the following content:

#!/bin/bash

BACKUP_DIR="/backup"       
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
BACKUP_FILE="$BACKUP_DIR/home_backup_$TIMESTAMP.tar.gz"
SOURCE_DIR="/home/$USER"    

mkdir -p "$BACKUP_DIR"

tar -czvf "$BACKUP_FILE" "$SOURCE_DIR"

echo "Backup completed: $BACKUP_FILE"

Suppose you're unsure about the functionality of this script or want a clearer explanation. You can pass the script to Fabric using the following command:

cat mybash.sh | fabric --pattern summarize

This command reads the contents of mybash.sh and pipes it to Fabric, which then applies the summarize pattern to provide a concise explanation of the script’s purpose.

Use DeepSeek with Fabric

Just like OpenAI, Fabric also supports DeepSeek as an LLM backend. To use it, you’ll first need to create an account on the DeepSeek official website and navigate to the API section.

Create a new secret key with the name you want.

Create a New Secret Key

Copy the API key and save it. The same way as before, go to fabric --setup and choose number 10 to set up DeepSeek with Fabric.

Set Up DeepSeek with Fabric

Next, you’ll be prompted to enter the API key you obtained from the OpenAI website. Paste the key when prompted.

When asked for the context, simply leave it blank.

Finally, configure the vendor option by selecting option 11.

Configure AI Vendor

Then choose DeepSeek-chat, which is option 1.

Choose DeepSeek Chat

Now you're good to go using DeepSeek as an API with Fabric.

💡
Both OpenAI and DeepSeek require an active billing setup to use their API keys. While OpenAI offers a free tier, usage beyond the allotted limit will result in an error indicating that the quota has been exceeded and payment is required to continue.

More Usage Examples of Fabric in Linux

Now that Fabric is set up, let’s look at how it can actually help you get things done faster. Below are some practical scenarios where Fabric can boost your productivity directly from the terminal.

1. Summarize Log Files

Have a huge log file but no time to read it all? Use Fabric to extract key points:

cat /var/log/syslog | fabric --pattern summarize

Fabric will analyze and return a short summary of the logs, especially useful when debugging or reviewing error dumps.

2. Explain Complex Shell Commands

If you're unsure about the purpose of a lengthy or complex shell command, Fabric can help by providing a clear explanation.

echo "find / -type f -name '*.log' -exec gzip {} \;" | fabric --pattern explain

This command searches the entire filesystem for files with a .log extension and compresses them using gzip.

3. Create Bash Scripts from a Prompt

If you need to automate routine tasks such as backups, user management, or cron jobs, Fabric can help you generate Bash scripts effortlessly.

Simply describe the task in plain English, and Fabric will create a fully functional script with inline comments for clarity.

echo "Write a bash script to monitor disk usage and email an alert if usage exceeds 80%" | fabric --pattern bash

Fabric will return a ready-to-use script, complete with explanatory comments, making it easy to understand and customize.

Conclusion

Fabric is a powerful terminal-based tool that brings the capabilities of AI directly to your command line, significantly enhancing productivity and streamlining your workflow.

In this article, we demonstrated how to integrate Fabric with either an OpenAI API key or DeepSeek. You can choose the model that best fits your needs and begin leveraging AI directly from your terminal.