This content originally appeared on DEV Community and was authored by Ivaylo Ivanov
Have you ever wondered, how to access the windows file system through WSL? If the answer is yes you are in the right place!
Microsoft WSL has given us an incredible way to access the windows file system, you have just to navigate through an exact path to do it. Without further due, let's dive into the topic.
1. Use the cd command in the Linux terminal.
To access the windows files you have to navigate through /mnt/your_windows_path
cd /mnt/c/Users
**OR**
cd /mnt/d/your_folder/your_folder
Now you have access to every file in the Linux and Windows file systems.
2. Moving files between the two systems
If you want to move files between the two operating systems you can simply use the cp or mv commands.
cp - command for copying files
mv - command for moving files
Use of cp command
cp /mnt/c/file.txt /home/username/Documents
Use of mv command
mv /mnt/c/file.txt /home/username/Documents
3. Editing windows files through Linux terminal.
To edit windows files through the Linux terminal using WSL, you have to use any text editor that can be opened in the terminal. One of the most famous text editors is nano. In our example, I am going to use the nano editor.
Type into the terminal nano and the path to the file.
sudo nano /mnt/c/Users/file.txt
Now you can edit freely files from your terminal.
4. Creating files in windows through WSL.
To create a file in a specific windows directory you have first to navigate to it and then use the touch command to create a file.
touch - a command that creates a file.
!!! The file extension can be anything you want.
cd /mnt/c/Users/Public/Documents/
touch filename.txt
The file is created and can be opened from both systems.
5. Deleting files from the windows file system through WSL.
To delete windows files using WSL, you have to navigate to the directory where the file lives and use the rm command.
rm - a command that deletes files / directories
cd /mnt/c/Users/Public
sudo rm example_file.jpg
Congratulations you learned 5 vital skills about working with the Linux terminal. 🎺🎺🎺
If you have any questions, comment down, I will answer as soon as possible.
This content originally appeared on DEV Community and was authored by Ivaylo Ivanov
Ivaylo Ivanov | Sciencx (2022-01-14T17:38:34+00:00) Access the Windows file system through WSL!. Retrieved from https://www.scien.cx/2022/01/14/access-the-windows-file-system-through-wsl/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.