How to manually install Command Line Interfaces on Windows

Aug 24 2021

Introduction #

This guide will explain how to setup a CLI on Windows 10. The intended reader is someone who is interested in automation or programming, but doesn’t know where to start. You should be familiar with navigating your filesystem, such as knowing how to open the Downloads folder, being able to see file extentions, and creating new directories.

If you’re a writer/editor and wondering why the heck you should learn about CLIs, check out Vale, a programmable style guide.

Why manual installation?
This method works for every program in existence, as long as the producer offers binaries. PowerShell 7, Node.js, Python, Monero, etc. Popular projects, such as Python, have “wizards,” installers, or distributions (such as Anaconda for Data Science) to complete these steps for you.

To use programs that aren’t connected to a package managment ecosystem, they have to be installed manually. Maybe you don’t want to bother with auto-updates, or you’re installing on an external harddrive.

Also, if you have restrictions on a work computer, you can install simple utilities without prompting for Administrator Privileges. These CLIs typically don’t need advanced permissions.

Installing a program manually is as simple as unzipping a file, hence it’s sometimes called “zip” install. Connecting it to the terminal is trickier.

Check system type (32- or 64-bit) #

If your computer has been made within the last 10 years, it probably has a 64-bit processor. If you want to check, here’s an article on how to determine the version of your operating system.

Download compiled binaries #

For the purposes of this guide, we are installing jq, a lightweight tool for manipulating JSON.

  1. Head to the jq “Releases” page on GitHub
  2. Download the right file for your system. For Windows 64-bit: jq-win64.exe
  3. Create a new folder to store the program. For example: C:\utilities\jq
  4. Rename the executable to jq.exe
  5. Place it into your new folder

Name conventions

“32-bit” binaries may sometimes be labeled “x86”

“amd64” is the same as “x64” and “x86-64”. Anything with “64” in the name is for 64-bit.

Add the program to your Systems Environment Variables path #

Register the program as a command on the terminal.

  1. Click on Start Menu and type path (automatically pulls up Windows Search)
  2. If you own the computer, choose “Edit the system environment variables”
  • If you don’t have admin privileges, choose “Edit environment variables for your account” and skip to Step 4

After typing in Path, the editing options show up
3. Click on [Environment Variables]
4. Under User variables for xxx, double-click on Path

User defined paths window
5. Click [Browse]
6. Find your directory where the program is stored, such as C:\utilities\jq

Adding C:

The OS C: drive is typically under “This PC”

  1. Click [OK] on every window to save.

Check that the program runs #

  1. Start Menu > Type cmd
  2. Open “Command Prompt”
  3. Type in jq --version
  4. You should get a jq-1.6 response:
    The console response

Because our program is called jq.exe, it can be evoked with a jq command. Likewise, a program named app.exe is called app (no extension) in the terminal.

If you want to download multiple jqs, name them as you want and place them within the same folder. For example, if you download version 1.5 and 1.6 for testing purposes, rename the newer one to jq-1.6.exe, and you can evoke jq-1.6 --version.

After all steps are completed, you’ve installed a CLI manually and finished the tutorial!

Appendix #

Defining binaries and terminal #

Binary #

A binary refers to a file that’s ready to run on a machine (compiled to a machine-readable format) which in most cases, is a program that runs on specific architecture. Binaries for mobile devices are different from binaries for computers because they use different hardware, and the binaries for Mac OS are different from the binaries for Windows because the operating systems are coded differently.

This is opposed to “building from source,” where you can download the human-readable source code, but to actually use the program, it needs to be compiled.

On Windows, programs typically have a .exe or .bin extension. As always, only download from trusted sources. User discretion is the best antivirus.

Terminal #

It’s the black screen that you see in movies, when a hacker character conducts programming magic. In Windows, there are 2 different terminals: Command Prompt and PowerShell.

Before Graphical User Interfaces (GUIs), there was only text. When instructing the computer to copy files and run system tasks, machines don’t need a desktop. Desktops are a human affordance. Automation of grunt tasks is written into scripts, because text is easier to copy and transfer.

Every operating system comes with preinstalled scripts and programs. Here’s a list of Windows commands.

Due to the complexity of computers, the terminal has many other names, such as “console,” “shell,” and simply “command line”. Stack Overflow thread on the origins of the terminal.

Intro to CLI Syntax #

As the field of computing evolved, programmers adopted the conventions for POSIX-compliant syntax. This type of program is referred to as a Command Line Interface (CLI).

The format to evoke a CLI is as follows:

app command argument --flags
  • app specifies the program
  • command calls a particular function, although this is optional based on the programmer’s whim, and not all apps have commands. jq doesn’t use commands in its syntax, but git does.
  • Flags are prefixed with two -- hyphens to indicate the full name of a flag, which is typically a type of toggle, but again it depends on the program.
  • One - hyphen flags are aliases (1-letter shortcuts) because flag names get long and tedious to type out.
    • Aliases can be combined in one hyphen. For example, a programmer states that to print out the module version, there are aliases to go with it. These lines are equivalent evocations (they are case sensitive):
app --Version --verbose
app -Vv

However, these are only conventions, so always read the documentation.

Interpreting documentation #

When reading the manuals of other programs, documentation for syntax usually is written out as:

app arg1 arg2 … argN [–optional-flag]

Optional arguments and parameters are denoted inside square brackets []. Usually, there are examples to show the proper evocation and use cases.

Example Linux commands

Closing #

If you are interested in exploring CLIs further on Windows OS, I highly recommend installing PowerShell 7+ or activating the Linux Subsystem so that you can use Unix syntax. The Command Prompt and old versions of PowerShell use Windows-specific conventions, where the lack of cross-platform compatibility is annoying. Or, if you don’t want to download stuff, try remote computing with GitPod.