In this blog, we will learn how to create or move files and folders to Linux root system from Windows. Familiarity with Windows Subsystem for Linux (WLS) is required. Please read my earlier blog post – Windows Subsystem For Linux – Run Linux on Windows (It’s FAST).
This is part 3 of our 4 part series. You can find the full series here:
- Part 1 – Linux Vs Windows (Why Linux For Programming & Web Dev)
- Part 2 – Windows Subsystem For Linux – Run Linux on Windows (It’s FAST)
- Part 3 – A Beginner’s Guide to Use Windows Subsystem For Linux
- Part 4 – How to Install and Use Visual Studio Code Editor with WSL
In my previous article where I introduced an overview of Windows Subsystem for Linux (WSL), we learnt the newer version of WSL architecture (WSL 2) is faster than the previous (WSL 1). We also learned there are a couple of key changes in the new architecture. The key changes are:
- Your files need to be moved or present in the Linux file system instead of Windows system.
- For now, an IP address is needed to access network applications.
Let’s cover this one by one.
Access Linux Files of the WSL
We need to find the home directory in Linux subsystem. This way we can see all the files inside WSL
1. Launch Ubuntu 18.04 command line terminal (we can also referred to this as WSL terminal). Do read my previous blog to get you started with the WSL ecosystem.
2. Run this command:
3. Don’t skip the space after exe and dot at the end of the command.
4. A folder will be automatically open up once the command executes. This is the home directory. The network path to that directory will be like this:
5. You can see all the files, such as .bash files and .wsl config file, created inside this folder automatically.
6. These are the system files. To understand, consider these files and folder similar to C-Drive files/folder in Windows.
Create a project directory inside of Linux Root System
Now, we will create a folder and a file into Linux system. Both of them won’t be in the Windows system.
1. We are already in the home directory of Linux. We can create a folder here. Let’s create a new folder “ajeet”. This is similar to creating a new folder in a Windows machine. Right click using computer mouse, select New > Folder. Rename it to “ajeet”.
2. Alternatively, we can create a new folder by running a command in the WSL terminal. Run ls in the terminal to see folders. You will see “ajeet” folder we just created. Run mkdir ajeet_new to create a new project directory called “ajeet_new”. This folder “ajeet” and “ajeet_new” can also be seen using Linux command ls. If you don’t see the newly created folder in the Window view, just refresh the folder using mouse. You can also run ls in the terminal to view all the folders.
3. You can now move files and folders into this networked folder, and work independently with Linux distro.
4. We can also install Python in this folder and learn coding.
Access network applications
For now in WSL architecture, we need to use an IP to access network apps since Linux is inside a virtual machine. This IP can be see if you run a local server. In the newly created networked folder, you can install nvm, node.js and npm, and run a local server for an app. Learn how to install nvm, node.js, and npm. Once the app is created, you can use an IP like this 192.168.28.2:3000 to access your app.
This section is beyond the scope of this blog post as it will need an advance knowledge of command-line tools and concepts. For beginners, the previous section is enough to start learning web development and programming.