How to make executable available everywhere in Linux (using ~/.bashrc)

Photo by Tianyi Ma on Unsplash

Well, this is my programming log for future me who is very likely to forget what I have done today.

As a Linux newbie, I decided to get myself familiar with terminal. Not only does it look cool as a programmer, I believed it will improve productivity.

The first thing I have done is to find a text editor. I looked up options for nice and colorful editors available in terminal. I eventually found a light-weighted and color-supporting editor called “micro”. I decided to use it. It is an opensource(free) and well-documented. Those who are interested, check that out here https://micro-editor.github.io/

Anyway I installed micro at my home directory “/home/tofusoup429/mic ”.

The problem is that I had to type a long command-line, “/home/tofusoup429/mic/micro” to start the editor. This is extremely not cool and inconvenient. I wanted to start the editor by simply typing “micro” anywhere in my Linux shell.

command micro not found~

I found a solution. I had to edit a hidden file named “.bashrc” in the home directory “home/tofusoup429” or “~”. It is hidden by default. So you can only see it by “ls -a”.

According to https://www.routerhosting.com/kb/what-is-linux-bashrc-and-how-to-use-it-full-guide/, “bashrc” is explained as follows.

“. bashrc is a shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt. … In order to load your preferences, bash runs the contents of the bashrc file at each launch.”

Not visible with ls
visible with ls -a

Open the “.bashrc” file and add path where the executable of the editor is located. The line I had to add was …

export PATH=“<PATH TO EXECUTABLE>:$PATH”

In my case the <PATH TO EXECUTABLE> is /home/tofusoup429/mic. Note that <PATH TO EXECUTABLE> should not include the executable itself.

Adding a line to .bashrc

It is basically me giving an order to linux that whenever I put a command, look up the path “/home/tofusoup429/mic”.

Then, you need to refresh “.bashrc”. You can either restart the terminal or simply source the bashrc file. I would rather source the file with command ~

source /home/tofusoup429/.bashrc

Now it refreshes the .bashrc file and should reflect the newly added path.

It works. As soon as I put “micro” command, it opens the editor.

Thank you for reading my programming log. I hope this will save some time of other Linux newbies.

--

--

--

A Certified Public Accountant / Hobbyist-programmer-but-dead-serious-specializing JavaScript, ReactJS, NextJS and AWS.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Canal — error while reading from client socket java.io.IOException:

Octaplex Network X Satoshi Club AMA recap (Part 2)

How to run a secure chat behind Tor off of your Android phone

Python And Flask Framework Of Python Course For Beginners | FREE

Check Tempur Pedic cloud reviews that aresupreme https://t.co/KFeupyAwEB

Developer Tools for UI Debugging

Installing and Configuring VMware vRealize Automation 7.6 Step by Step | VMware VIRTUALIZATION

Top 25 Distributed Databases

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steve Kim

Steve Kim

A Certified Public Accountant / Hobbyist-programmer-but-dead-serious-specializing JavaScript, ReactJS, NextJS and AWS.

More from Medium

How to Create a Bootable USB Drive in Linux Using Etcher

What is the purpose of using a VPN?

A VPN, or virtual private network, extends a private network across a safer public network.

Installing pfSense on ESXi

Successfully installed VM, ready to install pfSense

what happens when you type ls -l *.c and hit Enter in a shell?