Skip to content

1. Installing everything from scratch

Scott Campit edited this page Feb 21, 2020 · 2 revisions

Installing Linux on Windows

Linux is a family of open-source operating systems that enables more flexibility in installing/downloading software, managing file systems, and running computational processes (ie Git). This tutorial goes over a step-by-step procedure on how to download Ubuntu 18.04 and run it on a Windows 10 machine.

Installing the Windows 10 Subsystem for Linux (WSL)

Microsoft has a very straightforward guide to installing Linux on Windows. However, I will describe the steps and emphasize certain points in this tutorial to streamline the installation process.

Note that there are several flavors of Linux. Once you have finished restarting your computer, you will need to choose one distribution to install. For this tutorial, we'll download Ubuntu 18.04, which is a relatively beginner-friendly Linux OS to start with.

  1. Search for the PowerShell command prompt. Before clicking on the app, right-click the app and choose to run as an Administrator.

  2. In the window, copy and paste the following command. It will prompt you to restart your computer to finish the installation:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  1. Search for the Command prompt application. Right-click and choose "run as an Administrator", and download the .appx file containing the Ubuntu OS using curl:
curl.exe -L -o ubuntu-1804.appx https://aka.ms/wsl-ubuntu-1804
  1. The file should be downloaded in your current working directory. To finish the installation, you can type the following command into PowerShell:
Add-AppxPackage .\ubuntu-1804.appx
  1. Once you have finished your installation, search for the Ubuntu app and open it. You will be prompted to create a new user account and password.

  2. You should have the bare minimum Linux OS installed! Now we will update the package catalog and upgrade the installed packages after this initial install. To do this, type in the following to your Ubuntu terminal and follow the subsequent prompts:

# Get information for packages that can be upgraded
sudo apt-get update

# Upgrade packages
sudo apt-get upgrade

# Remove useless packages
sudo apt autoclean; sudo apt autoremove

Now that you have updated your Ubuntu OS, you're ready to start using bash commands in your Windows machine. If you're not familiar with Linux commands, there is a tutorial that goes over basic Linux commands for navigating through your computer's filesystem.

Considerations for macOS

The macOS and Linux kernels are very similar, and so some Linux commands will work on the macOS Terminal. However, before using Git, I would recommend installing Homebrew, a package manager that is similar to the Debian apt package manager. The only step you need to download Homebrew is the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

To learn more about homebrew, you can read the documentation and play around with other brews.

Installing Git for the Linux Terminal

  1. You can copy-and-paste the following command into the Ubuntu terminal to install Git via the command line:
# Get information for packages that can be upgraded
sudo apt-get update

# Upgrade packages
sudo apt-get upgrade

# Remove useless packages
sudo apt autoclean; sudo apt autoremove

# Finally, install git
sudo apt-get install git-all

This should install all the essential packages for using Git.

  1. Now that we have Git running on our system, we can customize some of our settings that will allow us to use Git with GitHub. First, we will set the user name and email address. Input the relevant information for your user name and email address (emphasized with "<>" symbols):
git config --global user.name "<Your Name>"
git config --global user.email "<youremail@email.com>"

Next, we will set the text editor that will be used when writing messages in Git. The easiest and most intuitive one to get started with is nano, but you can feel free to use other popular ones such as vim or emacs if you're comfortable with those editors. I will be writing this tutorial using nano as the editor.

  1. To set the text editor as nano (or any other text editor), type in the following:
git config --global core.editor nano
  1. This was a brief intro to some of the parameters you can input for your Git setup. To see other configuration files that you can change, including text colors, type in:
git config --list
  1. There will be some commands that you use fairly frequently, but will not know all the parameters for. To find out more about a specific git command, you can type in the -h or --help arguments following any command. For example:
git add --help

will return

usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

Congrats! We've gone over how to install Linux to our machine, and how to install Git as well as simple Git usage. Next, we'll go over how to start using Git and GitHub together for tracking specific projects or repositories.

My personal suggestions for additional software:

  • Atom is a free open-source and hackable IDE that has a very active developer community, and contains several packages that can help your Git experience. The only downside to Atom is that it is slower compared to other IDEs.
  • StackEdit is an open-source, Google Chrome application that allows you to write Markdown files in a single platform and can integrate with GitHub, Google Drive, and other applications.

Additional reading