🖥️ Setting Up Terminal for Windows


Many of our starter packs (and many tech tutorials in general!) assume that you have Terminal and you know how to use it.  While this is automatically installed on your computer if you have macOS, it’s a bit more complicated if your operating system is Windows.  If you need to use Terminal but have the Windows operating system, this starter pack is for you!  We’ll walk you through how to install the Ubuntu Subsystem for Windows, set up your home directory, and some basic Unix commands.  

At any point during the hackathon, if you have technical questions, hit up our help queue.  If you have questions or feedback specific to this starter pack, tell us (DM Murad on Slack!).  Thanks for coming, and good luck!  

Murad, Cal Hacks Director

👩🏼‍🏫 Let’s Install the Ubuntu subsystem for Windows

  1. On your Windows Search Bar, search up Ubuntu
  1. You should see a link that takes you to the Microsoft store.  After clicking on it, install the Ubuntu app that you find!  It should look like this:

  1. After it’s downloaded, search Ubuntu up on your computer.  Once you open it, it will take some time to set up.  Once it’s set up, it will ask you for a password and a username.  Note: Be sure that your password is simple - if you forget it, it will be really hard to retrieve!

🌍 Setting up your home path and getting to your C Drive

  1. To get to your C drive path, run cd /mnt/c this is where your C drive is located, after that you can go to your users directory and the user you are currently logged into
  1. In Ubuntu ~ represents the home directory of your terminal, it’s pretty useless for it to be in a path that can’t be accessed through windows explorer so let’s change that!
  1. run nano /etc/passwd look for a phrase that has the username that you set in the first step, it should look something like username:x:1000:1000:,,,:/home/username:/bin/bash 
  1. Remove the phrase “/home/username” where username is the username you set during setup.
  1. Replace this with the path that your Windows User is at, this should be at /mnt/c/Users/username where username is the name of the Windows user you are logged in as.
  1. Close your terminal, run source /etc/passwd
  1. Then run cd ~, you should be in your user directory!!!

💭 Some Basic Unix Commands

  1. cd takes you to a directory, ie, if you are in Documents and want to get to a folder called github, you would type cd github 
  1. ls prints all the file and directory names in the current directory you are in so if you are in a folder called downloads and want to see all the files there just type ls! Alternatively, you can type ls /downloads/ if that’s the path to downloads.
  1. nano opens a file in nano and allows you to edit it ie. if you want to edit a file called main.py that’s in your current ubuntu directory type nano main.py and you can edit the file within the terminal!
  1. To remove a file (delete it) you can use rm filename
  1. If you ever get an access denied error, retype the command you tried to run with sudo this gives you admin privileges after you type in your password 
  1. If you need to make a directory (folder) use mkdir nameOfFolder
  1. To move a file into a new directory use mv fileYouWantToMove newDirectory/fileName or you can just change a filesName by doing mv originalFileName newFileName
  1. To make a file run touch fileName Make sure you include file extensions

📚 Further Resources