Generate Linux Commands from English Text Using ChatGPT AI

An AI in your Linux terminal to turn your commands in plain English language to actual Linux commands.
Warp Terminal

Even expert Linux users don't remember all the Linux commands and their options. It's not possible for us humans.

But what about the machine? Especially the AI-powered machine?

Imagine if you could 'order' your terminal to 'show all files under 100 MB in size that were modified in last 12 hours'. Sure, you can 'order' it using the Linux commands but what about interacting with in plain English?

Thanks to the advancement of AI, it is actually possible. Here's an example of automatically generating the Linux command to show all the files smaller than 10 KB in the present directory.

Shell Genie AI assistent in Linux terminal

The tool I am using is called Shell Genie. It is a command-line tool that lets you interact with the terminal in plain English.

It can generate commands, run the commands (if you want to), and it can also explain the generated commands to you.

Shell Genie explain commands
AI can explain how the command works

Features of Shell-Genie

  1. Convert plain English to Linux Commands.
  2. Provides an openAI gpt3 backend that requires an API key from openAI and a free-genie backend that is free to use.
  3. Prompt with an option to run the command you asked for.
  4. Explains the generated commands.

Install Shell Genie

Shell-genie is not available in the default repositories of any distro. You can install it using pipx.

In order to install, you need to have Python 3.10+ and Pip installed. You can refer to our article on how to install pip in Ubuntu and other Linux distributions.

Once pip is installed, install pipx with the following command:

python3 -m pip install --user pipx
python3 -m pipx ensurepath
An SVG animation showing pipx Installation steps
Install pipx

Now, restart the terminal and install shell-genie by running:

pipx install shell-genie

This may show an error or the need for a dependency.

A dependency installation to install the shell-geie properly
Dependency Required notification

Run the command that is prompted to install the required dependency. In my case:

sudo apt install python3.10-venv

After this, run the shell-genie install command once more, and it will be installed.

The steps showing the installation of shell-genie
Install `shell-genie`

Once installation is complete, run the following:

shell-genie init

This will ask you to select the backend, either openAI or free-genie. If you have openAI API, you can choose that or stay with the free-genie.

🚧
free-genie backend may not work always, because it is hosted by the developer, and he cautions of possible outages.

It will then ask permission to report feedback. Decide on that with a y/n.

Run shell-genie init commad to set up the shell-genie properly
Run shell-genie init

You are ready to go now.

Working with Shell-genie

🚧
If you are going to experiment, try not to use commands with sudo or remove files. Don't put your machine in the hands of a machine.

As said above, shell-genie provides two modes for working.

  1. Get command from plain English
  2. Get command explanation

Get Linux commands from plain English

You can use shell-genie's ask option to get commands from plain English. For eg.

shell-genie ask "Display only the folders of this directory"

This will display the proper command, and prompt us to run the command or not.

The working of shell-genie, that will print the required command from the provided plain text description. Also propt the user to execute the same or not
Shell-genie working

Get Linux commands with explanation

You can use shell genie to explain some commands that you want to run.

shell-genie ask "display all files smaller than 10kb in here" --explain

The above command will first display the required command and explains it and then prompts the user to execute it or not.

The explain mode in shell-genie, where it will explain the command that was asked in the form of plain english and then prompts the user to execute it or not
Shell-genie in explain mode

Wrapping Up

There are tools like Explain Shell that (try to) explain the Linux commands. But this Shell genie takes it to the next level by generating commands from plain English.

Of course, you cannot rely on artificial intelligence blindly. If you are familiar with the Linux commands a little, you can use Shell Genie to generate commands for your purpose. You won't have to struggle with the man pages or various websites.

It sorts of helps you do things faster in the terminal and also makes you less knowledgeable. Why? Because the more you rely on it, the less you will learn on your own.

That's what I think. Feel free to agree or disagree with me in the comments.

About the author
Sreenath

Sreenath

Linux tinkerer by day, Lord of the Rings fanatic by night. When I'm not busy conquering the command line, you can find me kicking back and watching some football while quoting JRR Tolkien

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.