When you use the command line a lot, you are inevitably going to collect a few random binary files that you want to keep available to you at all times. These are small scripts and programs that you have either written or downloaded from the internet.
After all, being good at the command line sometimes comes down to having a large bag-of-tricks that you can call on.
There are many very useful tools for Windows, Linux, and Mac that exist as a single binary file that does not need to be installed.
It's nice to have easy access to your CLI tricks no matter what you are doing on your computer. In this article, we'll show you how to make a personal binary directory on your computer, and how to add it to your system path so that you can run your binaries from any directory on your computer.
Examples of Popular Single File Binary Applications
Some of the more popular programs that are available as a single file binary are:
These are great candidates to put in your personal binary directory. They are small, single file binaries that you can download and run from any directory on your computer.
Adding New Binaries to Your Path
When you install an application that has an installer, the installer either puts the binaries in a directory that is already in your path, or it adds the directory that the binaries are in to your path, or it creates a shortcut to the binary in a directory that is already in your path.
When you install an application that does not have an installer, you must add the directory that the binaries are in to your path. This is usually done by editing your system path environment variable. Now let's talk about how you can run binaries that you install on your computer, or that you write yourself.
It is a bad idea to put your personal binary files in these existing system binary directories, for a variety of reasons.
- You may want to keep a copy of your binary files that you've collected as you move from computer to computer.
- Windows might delete your binary files if you put them in c:\windows directories.
- It's a good idea to keep "operating system binaries" and "personal binaries" separate so that you can upgrade the operating system without losing any of your settings or files.
To address all of these issues, we'll teach you how to make a personal binary directory where you put all of your binaries that you have either written or downloaded from the internet. We'll also add this directory to the system path so that you can run your binaries from any directory on your computer.
Your operating system ships with an assortment of basic programs that make your computer useful, but this assortment is far from complete. As you get more and more advanced computer tasks to solve, you end up needing more advanced command line programs to help you tackle those tasks.
Make a Personal Binary Directory
There are really 2 steps that you need to take:
- Make a directory to put your binary files in.
- Add that directory to your system path.
We'll go over the steps for both Windows and Linux.
Make a Personal Binary Directory on Windows
The first step is to make a directory on your computer where you will store all of your personal binaries. This directory can be anywhere on your computer, but it's a good idea to keep it in a place that you will remember.
We suggest making your Windows binary directory at
c:\bin. This location has a lot of benefits, the least of which being it is easy to remember. If you don't want to use
c:\bin\ then follow these steps with the directory that you choose.
Open up a command prompt. It can be either cmd or terminal as these commands work in both. Run the following commands:
mkdir c:\bin setx PATH "C:\bin;%PATH%"
Now exit your command prompt and re-open it. Your
c:\bin\ directory should be in the path. To prove it, run one of the following commands, depending on which shell you are in:
You should see your new
c:\bin directory listed at the beginning of your system path.
Make a Personal Binary Directory on Linux
Linux already has a user binary directory located at /usr/local/bin that is by default in the system path. This is a good place to put your personal collection of binaries, but you can put them somewhere else if you want. If you want to make them somewhere else, then follow these steps with the directory that you choose.
Let's say that you want to keep your personal binary files in your home directory in a bin directory. Run the following commands:
mkdir ~/bin echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
Now exit and restart your terminal. Your
~/bin directory should be in the path. To prove it, run the following command:
You should see your new
~/bin directory listed at the beginning of your system path.
How To Install Single File Programs
Let's assume you have a problem to solve, and you go out to the internet and track down a cool new tool that exactly solves your problem. It's the perfect tool for the exact problem that you have, and you want it on your computer. Perhaps it's something from NirSoft or SysInternals.
You download this cool new tool, which happens to come in a zip file, and you double-click the zip file. There's just a single file in there called 'cooltool.exe'.
It doesn't have an installer. It's just a 'single file'. What do you do with it? How do you install it?
The answer is simple: You put it in your personal binary directory.
Simply extract the cooltool.exe file from the zip file and put it in your personal binary directory. Now you can run it from any directory on your computer.
If you are on Linux or Mac it will probably be called cooltool and not cooltool.exe.
Take Your Binaries With You
The great thing about having a personal binary directory is that you can take it with you when you move from computer to computer. You can put it on a USB drive, or you can put it in your Dropbox or OneDrive folder, or you can put it in your Google Drive folder. You can even put it in your iCloud folder if you are on a Mac.
The point is that you can put your personal binary directory in a place that you can access from any computer that you use. This is a great way to keep your personal binaries with you as you move from computer to computer.