Installing the Linux Bash Shell in Windows Matthew Watson Current as of 9/26/2017

So being a windows user in any computer science class ever is a bit of a pain. Everyone hates us and nobody understands. Boo hoo. But I don’t think we should have what essentially amounts to bonus homework just to figure out how to get basic things working. So, here’s what I hope will be a handy resource in getting the bash shell to run properly in your windows computer. I’m also going to include instructions on accessing your computer’s main files from within bash, something that I found a lot more difficult than it should be, further complicated by the fact that I found no useful resources online for this.

Installing the Bash

PLEASE NOTE: This will work only if you have with the anniversary update installed. If something doesn’t appear for you, or looks dramatically different or anything like that, update your computer if you have Windows 10. If you don’t have Windows 10 than none of this will work. Sorry!

The resource I used primarily to figure this part out was this: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

If you don’t want to bother with it, or can’t get there or whatever, here’s my summary of the instructions. (The site is better though, it has pretty pictures)

1. Navigate to your settings ( (or start) -> Type settings then press enter) 2. Click Update and Security (Should be on the bottom right) 3. On the bar on the left side, click on “For developers” 4. Activate developer mode. You’ll probably have to click through some approval boxes, go ahead and do that, then wait for a download to finish. 5. Open up your (Windows key (or start) -> Type control panel then press enter) 6. Click on programs, then under Programs and Features click on “Turn Windows Features on or off” 7. Scroll down the list until you see a folder labelled “Windows subsystem for linux (Beta)”. Click the check box. Some stuff will happen (downloads and the like), and then you’ll be prompted to reboot the computer. Go ahead and do that. 8. Once your computer reboots, open up bash. (Windows key (or start) -> Type bash then press enter) Note that this will be how you open up bash going forward. 9. Follow the instructions that appear in the terminal that opens. There will be a download, and then you’ll have to create a user account for linux. Pick things you can remember, and keep in mind that when you enter your password nothing will appear, not even **** characters. This is normal, it’s reading your inputs, just press enter when you’re done. 10. Congratulations, you’ve installed bash on your windows computer!

Accessing your files

I found this incredibly non-intuitive, and couldn’t find a good resource for using the bash on windows anywhere. So here’s my little guide.

Note: I’m going to write linux commands in this format: < some command>. Don’t type the <> brackets, just the text inside. Note 2: Linux, unlike windows and its’ terminal, is CASE SENSITIVE. If a command doesn’t work and you’ve checked that you’re in the right place with a quick < ls>, you’re probably not capitalizing letters you should be, or vice versa. Final Note: If you don’t want to bother with my explanations for stuff you can skip to the end of this document to find a reference of all the commands you need to enter to get to the desktop.

First off, if you’ve just installed bash after opening it for the first time, go ahead and close it. I have no idea where it puts you in the at the point right after installation, so just reset the whole thing to prevent confusion and or frustration.

The first time you open bash on a reboot of your computer (or right after installing), you may get some text that suggests you need to log in, or don’t have administrator privileges, or something like that, without any obvious instructions on how to do so.

Enter this command: < sudo su> Once you enter this command, the terminal will prompt you for the bash password you set up when you first opened it. Enter it in and your prompt should change to something resembling yourusername@SOMETHING: $ Once you see that you’ll be good to go. If you’re curious by the way, sudo is a command in linux that lets you use the permissions of another user, typically the administrator. < sudo su> i s basically you just trying to act as the su, or supervisor (administrator) of the computer. Once you’ve entered in your password, linux knows you are the su now and therefore you no longer need to add sudo to your commands after you’ve done this.

Now, the file you’re located at is a strange hidden file deep in your windows file system. Notice if you type < ls> you will see nothing. So there’s nowhere to navigate to from here either. This link is supposedly how to get to this file in . This didn’t work for me for whatever reason for the record: https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-you r-windows-system-drive-in-bash/

Whether you can find the file or not, it’s still not where you’re going to want to do your CS homework. You’d much rather be messing with a file in your documents or desktop or something. Here’s how to get there.

Enter in: < cd ..> The < cd ..> command is the back up command. In file explorer there is an up arrow that backs you up one file from wherever you are. (Example: If you are in a folder in your desktop the up arrow will put you back on the desktop). The < cd ..> command does the same exact thing.

You’re still within the world of weird hidden linux stuff. < ls> here will show you a folder with your bash username. Still not what we want.

Enter in: < cd ..> at this point will show you a bunch of crap. Don’t mess with any of it. No I don’t know what any of it is. It’s probably stuff that will ruin your computer forever if you even look at it! Don’t say I didn’t warn you.

Enter in: < cd mnt> By the way, all the backing up we did earlier is actually unnecessary. Haha, gotcha! In all seriousness, from the start you can enter this command: < cd /mnt> to get right to this point. I did the backing up just to demonstrate where it is we’re getting to within our computers, since it’s rather unintuitive to change directories to a directory you can’t see with < ls>.

here will show you a list of drives on your computer. Chances are the C drive is where you want to go, even if you have other drives on your computer. If for whatever reason you can’t find the files you’re expecting after you access the C drive, go ahead and back out (< cd ..>) and try a different one.

Enter in: < cd c> Now you’ll be able to see some files you might recognize with < ls>. Almost there!

Enter in: < cd Users> The next command will be based on whatever you’ve named yourself on your computer. For me it’s Matthew, use < ls> to check if you’re not sure.

Enter in: < cd *> * = whatever your username on your computer is. Finally we are within our file system! From here you can get into all sorts of places that will actually contain the files we want to mess with. Use < ls> of course to see exactly where you can get to at any time. Some useful examples:

Don’t forget the < cd ..> command if you want to back out of somewhere, like go into different folders on your desktop if you’ve put different homeworks in different folders for example.

Just an FYI, you can more efficiently move around within linux by combining commands. For example, from where you start when you open bash, I can enter this command to get right to the desktop: < cd /mnt/c/Users/Matthew/Desktop>

And there you have it. Hopefully this will make things easier for you going forward, and if it doesn’t feel free to ask me about it/yell at me because this document sucks.

Quick Reference for Accessing your Files

If you need to login: < sudo su>, then enter your password (alternate, f rom before the commands) * = Whatever your user file is on your computer. Use < ls> to check if not sure Single command from start: * = Whatever your user file is on your computer