0

I'm new to programming and trying to download Swift on Ubuntu on Windows 10 Insider Preview.

I'm now running bash on Ubuntu, I'm trying to get to the Downloads directory. I tried cd ~/Downloads and I get the no such directory message. I can't seem to navigate anywhere.

If it helps, When I type pwd it says /root. When I type echo $PATH it shows: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/gcc/x86_64-linux-gnu/4.8

Any help is appreciated, its probably a simple solution, thanks a lot!

5
  • I haven't been able to get the update to have bash on Windows but have you tried ls to see the files and tried to navigate that way ... maybe you are in the root directory and there is no Downloads folder there .. maybe its under /home/username .... but I can't be sure because like I say .. I have no way of checking and have never had the chance to play with the new bash in Windows
    – John Orion
    May 1, 2016 at 18:14
  • trying the update again ... if it doesn't fail this time I may have better information for you in a little while :D
    – John Orion
    May 1, 2016 at 18:17
  • Ok .. I got bash installed on Windows ... now can you explain how you are "trying to download Swift on Ubuntu" ... what steps are you taking to download the file ... this will help me understand where the issue lies
    – John Orion
    May 1, 2016 at 19:26
  • What's the output of echo "$HOME"? Bash substitutes any occurrence of ~ at the beginning of what seems to be a path name with the value of the environment variable of HOME. May 1, 2016 at 20:18
  • Echo $HOME gives /root
    – Joel
    May 1, 2016 at 20:33

1 Answer 1

1

The solution is that you are logged into the Bash shell as root. The beginning of the cursor line should say your username @ your computer name not root @ your computer name and the end of the cursor should have a $ not a #. The root account doesn't have a Downloads directory which is why you are getting the error.

If this is the case you can type exit and press enter this should bring you back to where it will have your username@yourcomputername and the $ at the end. If all else fails you can close Bash and open it again and it should start you in your user's 'home' directory.

Once set this way, typing cd ~/Downloads (in Ubuntu/Linux it is case sensitive) will bring you into your Downloads directory. The Bash shell mirrors the Windows drive structure. The downloads folder is the same folder as Windows default download folder ... C:/Users/yourusername/Downloads

The original poster was having problems with the bash shell always using root. I have tried everything to get the initial screen back where you enter the Unix user name and password but wasn't able to find a way without breaking the shell.

The way I was able to get back to that initial setting was to create a new Windows account. Log into that account and then reboot

note I had to log in and let it set up the account then I had to reboot because some of the files needed for the bash didn't seem to be in place and it seemed to hang when I tried but the reboot solved that.

Then I launched a cmd prompt and type bash to get the following screen. enter image description here

At this point I screwed up again... I picked the name Don for the UNIX name and put in a password .. everything worked well until I tried cd ~/Desktop and it threw an error.

The error said

bash: cd: /home/don/Desktop: No such file or directory

If you notice in the image the user directory for this account I created is donat not don .. so the ~/Desktop is using the "username" to find the directory

Because of this I would have had to use donat as the Unix name for everything to work properly.

So if you have to create a new account to set this up properly .. Make sure you make note of what directory that new account is using and make that your UNIX login name matches the directory name.

As I said, if I look at explorer and look at the path C:\Users\ the "Home" folder is donat for this account.

Under further messing around I found that it seems that Windows and the Bash running in Windows doesn't like the ~/directory shortcuts. You will have to use full paths such as /mnt/c/Users/username/Downloads to access your download folder you can't just use ~/Downloads.

23
  • Thanks John this is all good to know. I'm still having problems though, it may have been with the initial download of bash. I'm only able to run bash through the windows cmd prompt. So I open the cmd prompt and type bash I'm using the root@myPC. And then when I exit I'm back to the regular windows cmd prompt (no bash).
    – Joel
    May 1, 2016 at 20:18
  • If you right click on the start menu and choose Run then type Bash and press enter do you get the root bash or user bash?
    – John Orion
    May 1, 2016 at 20:21
  • According to the guide I'm using I should be able to open a "Bash on Ubuntu" command window, but when I search for Bash on my computer I only get a "bash" cmd window.
    – Joel
    May 1, 2016 at 20:22
  • I get the root bash. And if I exit from that it closes the window.
    – Joel
    May 1, 2016 at 20:25
  • ok you have different issues ... I just opened a cmd prompt and typed bash and pressed enter .. i got the 'user' bash ... I opened a cmd prompt in admin mode and typed bash and got 'user' bash ... I don't and can't automatically get into root bash without typing sudo su are you logged in as the administrator account and not an "administrators" account .. in other words are you in the default administrator account that is normally disabled in Windows?
    – John Orion
    May 1, 2016 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .