Reputation: 103
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
Reputation: 338
its simple, You can use the below command:
cd /mnt/<drive-name>
Upvotes: 0
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:
Open your WSL 2 terminal (Ubuntu).
Navigate to the D: drive:
cd /mnt/d
Navigate to your script location:
cd /mnt/d/University
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
Reputation: 3408
you can use mnt
to access your drives.
root@user-pc: cd /mnt/d/your_destination_directory
;
Upvotes: 19