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.
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.
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
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.
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.
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.