gr33nbanana
gr33nbanana

Reputation: 103

How to access my D:\ drive from the Ubuntu command line on Windows 10

When I open the Ubuntu windows store app and the bash command line (if I am not wrong?) comes up it's working directory is /home/username . I want to run a script which on my Windows is located in D:\University... . Can I do this and if so how?

I have only tried cd D:\ but I get " -bash: cd: D:: No such file or directory". I don't have any experience so far with Linux so I don't know if Ubuntu on Windows can only run in its own location or it can access all the files on my PC.

Upvotes: 10

Views: 23569

Answers (3)

Dubey Ravi vinod
Dubey Ravi vinod

Reputation: 338

its simple, You can use the below command:

cd /mnt/<drive-name>

Upvotes: 0

Harsha
Harsha

Reputation: 79

You can access your Windows files from the Ubuntu WSL 2 terminal by navigating to the corresponding mount points. Windows drives are typically mounted under the /mnt directory in WSL. For example, your D: drive would be accessible at /mnt/d.

Here's how you can navigate to and run a script located in D:\University from your WSL 2 terminal:

  1. Open your WSL 2 terminal (Ubuntu).

  2. Navigate to the D: drive:

    cd /mnt/d

  3. Navigate to your script location:

    cd /mnt/d/University

  4. Run your script: Assuming your script is named script.sh and is executable, you can run it as follows:

    ./script.sh

If the script is not executable, you may need to run it with bash:

bash script.sh

Upvotes: 0

Mahdi Tohidloo
Mahdi Tohidloo

Reputation: 3408

you can use mnt to access your drives.

root@user-pc: cd /mnt/d/your_destination_directory;

Upvotes: 19

Related Questions