Home Command line fun Betty – The Siri-like Commandline Virtual Assistant For Linux
Betty - The Siri-like Commandline Virtual Assistant for Linux

Betty – The Siri-like Commandline Virtual Assistant For Linux

By sk
308 Views

When newbies ask me how to be good at Linux command-line, I usually told them to avoid using GUI mode as much as they can. I suggest them to learn how to do stuffs from Terminal. Ask any Linux expert, and they will always say - "Command line mode is more powerful and easy". I fully concur with this statement. In case, you don't know how to do a specific task from command line, just google your question and start from there. Linux command line is not that difficult as you may think. However, some users are not so interested to use CLI mode no matter how hard you try to persuade them. They always prefer to use GUI mode only. If you're one of them, meet "Betty", a command-line virtual assistant for Linux.

Betty is somewhat similar to Apple's Siri personal assistant or Google Voice Search feature. It is a friendly English-like interface for your command line that translates English-like phrases into Linux commands. You don't need to google your question or don't even need to refer the man pages. Just ask your questions in simple English sentences, and Betty will instantly do what you just said. In this brief tutorial, I will show you how to install and use Betty in Linux.

Betty - The Siri-like Commandline Virtual Assistant For Linux

Install Betty

First, Install the necessary prerequisites.

On Arch Linux and derivatives:

$ sudo pacman -S git curl ruby

On Debian based systems:

$ sudo apt-get install git curl ruby

On RPM based systems:

$ sudo yum install git curl ruby

On SUSE, openSUSE:

$ sudo zypper install git curl ruby

Then, git clone the Betty repository using the following command:

$ git clone https://github.com/pickhardt/betty

I have cloned Betty repository in my $HOME directory.

Add the betty alias in .bashrc file.

To do so, edit .bashrc file:

$ vi ~/.bashrc

Press 'i' to switch to interactive mode and paste the following line at the end:

alias betty="/home/sk/betty/main.rb"

Then, press ESC and type :wq to save and quit the file.

Alternatively, you can use the following one-liner command to add betty alias in .bashrc file.

echo 'alias betty="/home/sk/betty/main.rb"' >> ~/.bashrc

Replace /home/sk/betty/ path with your own. Since I have cloned the betty repository in my HOME directory, I have used the above path.

Finally, update the changes made in your bashrc file using the following command:

$ source ~/.bashrc

Betty Usage

Betty usage is trivial. Allow me show you some practical examples.

Let us say, you want to find your username.

To do so, you would type:

$ whoami

However, you don't need to run the actual command. You don’t have to memorize and remember all Linux commands any more. Just ask the Betty in plain English phrases.

Say for example, to know your username, just type:

$ betty whats my username

Sample output would be:

Betty: Running whoami
sk
betty

betty in action

Cool, isn't? Betty is smart enough to understand your question and It will execute the command "whoami" and display the result.

Here are more examples.

$ betty whats my kernel version
Betty: Running uname -a
Linux ubuntuserver 4.15.0-30-generic #32-Ubuntu SMP Thu Jul 26 17:42:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ betty what time is it
Betty: Running date +"%r (%T)"
06:59:17 PM (18:59:17)
$ betty what month is it
Betty: Running date +%B
August

If there's more than one way Betty could respond, she'll ask you to select the one you want. Have a look at the following example. I have asked her the IP address of my system. She asked me back - Internal or External IP. I wanted her to display my internal IP, so I entered 1 (number one). She ran "ifconfig" command and displayed the IP address.

$ betty whats my ip address
Betty: Okay, I have multiple ways to respond.
Betty: Enter the number of the command you want me to run, or N (no) if you don't want me to run any.
[1] ifconfig
 Gets your internal ip address.
[2] curl -sL http://pannous.net/ip.php
 Gets your external ip address.
1
Betty: Running ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
 inet 127.0.0.1 netmask 255.0.0.0
 inet6 ::1 prefixlen 128 scopeid 0x10<host>
 loop txqueuelen 1000 (Local Loopback)
 RX packets 0 bytes 0 (0.0 B)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 0 bytes 0 (0.0 B)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp9s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 192.168.43.192 netmask 255.255.255.0 broadcast 192.168.43.255
 inet6 fe80::c218:85ff:fe50:474f prefixlen 64 scopeid 0x20<link>
 ether a0:38:73:10:99:5h txqueuelen 1000 (Ethernet)
 RX packets 102938 bytes 101205525 (96.5 MiB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 75264 bytes 12390762 (11.8 MiB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

If Betty can't understand your question, she will display the following message:

Betty: I don't understand. Hopefully someone will make a pull request so that one day I will understand.

For more examples, see Betty GitHub project page.

Don't think Betty will do all complex things, for instance deploying a Web server. Betty can't do such complex tasks on her own. You can use Betty to perform some simple commands only. If you want to add more features, send a pull request and contribute to the project in GitHub (Link is provided at the end of this guide).

Even though Betty is not being actively maintained, it's still fully functional. If you're too lazy to learn Linux commands, Betty might be a perfect companion for you.

Resource: 

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

4 comments

richardstevenhack August 18, 2017 - 4:43 am

A command line Siri? I don’t think so…

Reply
Rob August 30, 2018 - 8:15 am

How can I REMOVE betty? It’s not for me but it’s embedded in the system and I need to clear it out as though it was never there. Nobody seems to have any remove instructions

Reply
sk August 30, 2018 - 12:15 pm

Just remove the betty directory and its entry in your ~/.bashrc file.

Reply
Skullvalanche February 13, 2020 - 3:23 am

Folks who find this interesting may also wanna look at the “navi” project. It’s a slightly different approach, but approximately the same goal of “find me the command I need”.

https://github.com/denisidoro/navi

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More