- Linux in windows
- https://docs.microsoft.com/en-us/windows/wsl/install
- Tutorial : https://docs.microsoft.com/en-us/windows/wsl/setup/environment
- YouTUbe : https://www.youtube.com/watch?v=uWNpXOT-Zbo&list=PLhfrWIlLOoKNMHhB39bh3XBpoLxV3f0V9&index=4
- user: jdwinlinux
- pass: jdwinlinux
jdwinlinux@DESKTOP-AS2FQOH:~/jddocs$ cd /mnt/c/
jdwinlinux@DESKTOP-AS2FQOH:/mnt/c$ ls
ls: cannot access 'DumpStack.log.tmp': Permission denied
ls: cannot access 'hiberfil.sys': Permission denied
ls: cannot access 'pagefile.sys': Permission denied
ls: cannot access 'swapfile.sys': Permission denied
'$Recycle.Bin' DumpStack.log.tmp PerfLogs Users pagefile.sys
'$WinREAgent' Gradle 'Program Files' Windows selenium
AVScanner.ini JD_Google_Drive 'Program Files (x86)' app swapfile.sys
C_Drive Kompose ProgramData gh xampp
D_Drive OD Recovery hiberfil.sys
'Documents and Settings' OneDriveTemp 'System Volume Information' kubectl
jdwinlinux@DESKTOP-AS2FQOH:/mnt/c$ cd D_Drive/
jdwinlinux@DESKTOP-AS2FQOH:/mnt/c/D_Drive$ ls
DXC Job_Switch Kirti Personal jdk-11.0.10_windows-x64_bin.exe react
jdwinlinux@DESKTOP-AS2FQOH:/mnt/c/D_Drive$
- used comman from linux terminal " explorer.exe . Winfows file system : \wsl$\Ubuntu\home\jdwinlinux
!Ubuntu GUI commands: sudo apt update && sudo apt -y upgrade sudo apt-get purge xrdp sudo apt install -y xrdp sudo apt install -y xfce4 sudo apt install -y xfce4-goodies
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini echo xfce4-session > ~/.xsession
sudo nano /etc/xrdp/startwm.sh !comment these lines to: #test -x /etc/X11/Xsession && exec /etc/X11/Xsession #exec /bin/sh /etc/X11/Xsession
!add these lines:
startxfce4
sudo /etc/init.d/xrdp start
!Now in Windows, use Remote Desktop Connection localhost:3390
!Then login using your Ubuntu username and password
Yes, you can access and use the software and tools installed in the Windows file system from within WSL. When you install WSL, it provides a mechanism for integrating the Windows file system with the Linux environment.
By default, the Windows file system is mounted under the /mnt
directory in WSL. This means you can access your Windows drives and files from within WSL. For example, your C:
drive will be available at /mnt/c/
in WSL.
To use software or tools installed in the Windows file system within WSL, you have a couple of options:
-
Use the Windows executable directly: If you have software installed in Windows, such as Git or Maven, you can execute them from the WSL command line by specifying the full path to the executable. For example, you can run
C:\Path\To\Git\git
orC:\Path\To\Maven\mvn
from within WSL. -
Add Windows executable path to WSL's PATH: If you want to use Windows executables without specifying the full path every time, you can add the Windows executable directory to the PATH environment variable in WSL. This way, you can simply run the commands by their names. To do this, you'll need to edit the
~/.bashrc
or~/.bash_profile
file in WSL and add the following line:export PATH=$PATH:/mnt/c/Path/To/Executable
Replace
/mnt/c/Path/To/Executable
with the actual path to the directory containing the executables you want to use. After saving the file, you'll need to restart your WSL session or runsource ~/.bashrc
orsource ~/.bash_profile
for the changes to take effect.
By leveraging these approaches, you can seamlessly use software and tools installed in the Windows file system within your WSL Linux environment.
When I execute 'java --version' in wsl I can see corretto-11 while checking using above command from $PATH , the java path is /mnt/c/Program Files/Java/jdk-17.0.5/bin
, I don't understand this, Why I can see java 11 not java 17
The situation you described suggests that there might be multiple Java versions installed on your system, and the one being executed when you run java --version
in WSL is not the same as the one listed in the /mnt/c/Program Files/Java/jdk-17.0.5/bin
path.
When you run java --version
in WSL, it searches for the executable in the directories listed in the $PATH
variable in the order they are specified. It stops at the first occurrence of java
that it finds.
To determine why you are seeing Java 11 instead of Java 17, you can check the following:
-
Check the order of directories in the
$PATH
variable. Runecho $PATH
in WSL to verify the order of directories. If the directory containing the Java 11 executable appears before the one containing Java 17, then that could be the reason why Java 11 is being picked up. -
Verify if there are any symbolic links or aliases set up for the
java
command. It's possible that there is a symbolic link or an alias pointing to the Java 11 executable, even though the$PATH
variable points to Java 17. You can check this by runningls -l /usr/bin/java
in WSL to see if it is pointing to a different location. -
Ensure that you are running the
java --version
command from within WSL and not from a Windows command prompt or PowerShell. The behavior of thejava
command may differ depending on the environment from which it is executed.
By investigating these aspects, you should be able to determine why Java 11 is being displayed when running java --version
in WSL, despite having Java 17 listed in the $PATH
variable.
you mean if I have docker install in windows I can access docker inside wsl without insalling docker in wsl
Yes, that's correct. If you have Docker Desktop installed on your Windows system, you can access and use Docker from within WSL without needing to install Docker separately inside WSL.
Here's how it works:
-
Install Docker Desktop: Ensure that you have Docker Desktop installed and running on your Windows system. Docker Desktop includes the necessary components to run Docker containers both in Windows and within WSL.
-
Enable WSL Integration: In Docker Desktop settings, you can enable the WSL integration feature. This establishes a connection between Docker running in Windows and the WSL distribution of your choice.
-
Run Docker Commands in WSL: Once the WSL integration is enabled, you can open a WSL terminal and use Docker commands just like you would in a Linux environment. Docker commands executed within WSL will be executed in the Docker engine running in Windows, but the containers themselves will run within the WSL environment.
This integration allows you to seamlessly work with Docker containers from both Windows and WSL, using the same Docker installation. You can build, run, and manage containers from either environment without the need for duplicate installations or configurations.
By leveraging Docker Desktop's integrated support for WSL, you can maintain a unified Docker experience and avoid potential conflicts or inconsistencies that might arise from separately installing Docker within WSL.
- https://www.jetbrains.com/help/idea/how-to-use-wsl-development-environment-in-product.html#debugging_system_settings
- trouble shooting : https://stackoverflow.com/questions/67116880/how-to-correctly-set-up-intellij-with-wsl2
- https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
- https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories
- https://medium.com/javarevisited/using-wsl-2-with-x-server-linux-on-windows-a372263533c3
- As of my knowledge cutoff in September 2021, WSL2 (Windows Subsystem for Linux) does not have built-in support for running graphical user interface (GUI) applications directly on Windows. WSL2 is primarily designed for command-line and server-based applications.
However, there are some workarounds to enable GUI applications in WSL2 by using an X server on Windows. Here's a step-by-step guide on how to set up a graphical environment for WSL2:
-
Install an X server on Windows: To enable GUI applications in WSL2, you need to install an X server on your Windows machine. One popular option is Xming (https://sourceforge.net/projects/xming/). Download and install the Xming X Server on your Windows system.
-
Set the DISPLAY environment variable in WSL2: In your WSL2 terminal, set the
DISPLAY
environment variable to point to your Windows machine's IP address and the display number. Replace<Windows_IP>
with your actual Windows machine's IP address. You can find your IP address by runningipconfig
in a Windows Command Prompt or PowerShell.export DISPLAY=<Windows_IP>:0.0
-
Install GUI packages in WSL2: You will need to install necessary GUI packages in your WSL2 distribution. For example, you can install a lightweight desktop environment like XFCE4 along with other required components:
sudo apt update sudo apt install xfce4 xfce4-goodies x11-apps
-
Run Xming on Windows: Start the Xming X Server on your Windows machine. Make sure it is running and ready to accept connections.
-
Test the GUI application: You can now test if GUI applications work in WSL2. For example, you can run the
xfce4-session
command to start the XFCE desktop environment:xfce4-session
The GUI applications launched from within WSL2 should now be displayed on your Windows desktop through the X server.
Please note that running GUI applications in WSL2 using an X server can have limitations and performance considerations. It is not a native or fully optimized solution, so complex or graphics-intensive applications may not work as expected.
Always remember to check for the latest developments and improvements related to GUI support in WSL2, as Microsoft may introduce new features or changes in future updates. Additionally, you can explore alternative solutions like using Windows Subsystem for Linux GUI (WSLg), which aims to provide a more integrated and native experience for running Linux GUI applications in WSL2.
Yes, there are other X servers for Windows that you can use instead of Xming. One popular alternative to Xming is VcXsrv (also known as VcXsrv Windows X Server). VcXsrv provides similar functionality and allows you to run graphical applications from WSL2 and other Linux distributions on your Windows desktop.
Here's how you can use VcXsrv to enable GUI applications in WSL2:
-
Install VcXsrv: Download VcXsrv from its GitHub repository (https://sourceforge.net/projects/vcxsrv/). Choose the latest release version and download the installer. Run the installer to install VcXsrv on your Windows machine.
-
Set the DISPLAY environment variable in WSL2: In your WSL2 terminal, set the
DISPLAY
environment variable to point to the VcXsrv X server. The default display number for VcXsrv is 0.export DISPLAY=:0
-
Install GUI packages in WSL2 (if not already installed): As mentioned earlier, you may need to install necessary GUI packages in your WSL2 distribution. For example, you can install a lightweight desktop environment like XFCE4 along with other required components:
sudo apt update sudo apt install xfce4 xfce4-goodies x11-apps
-
Run VcXsrv on Windows: Start the VcXsrv X Server on your Windows machine. You should see the VcXsrv icon in your system tray indicating that it's running and ready to accept connections.
-
Test the GUI application: You can now test if GUI applications work in WSL2. For example, you can run the
xfce4-session
command to start the XFCE desktop environment:xfce4-session
The GUI applications launched from within WSL2 should now be displayed on your Windows desktop through VcXsrv.
VcXsrv provides additional configuration options that you can explore to customize the X server behavior according to your preferences. Remember to check the VcXsrv documentation and GitHub repository for more information and updates.
As with any X server solution for WSL2, keep in mind that running GUI applications in this manner might have limitations and performance considerations, especially for graphics-intensive applications. For a more integrated and native experience, you can also explore the Windows Subsystem for Linux GUI (WSLg) feature, which aims to provide better support for Linux GUI applications in WSL2.
- https://youtrack.jetbrains.com/issue/IDEA-267333/Maven-wsl-projects-is-failing-to-resolve-dependencies
sudo apt update
sudo apt upgrade
sudo apt install openjdk-11-jdk
jdwinlinux@PSL-21VL6Q3:~$ java --version
openjdk 11.0.19 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1, mixed mode, sharing)
jdwinlinux@PSL-21VL6Q3:~$
%Maven_Home%\bin
%JAVA_HOME%\bin
- Unzip this tar and move to /opt folder
unzip apache-maven-3.8.8-bin.zip
sudo mv apache-maven-3.8.8 /opt/
vim ~/.profile
# Add below lines as per your path in .profile
export M2_HOME=/opt/apache-maven-3.8.8
export PATH="$PATH:$M2_HOME/bin"
mvn --version
sudo tar -xzf intellij.x.x.x
sudo mv intellij.x.x.x /opt
sudo ln -s /opt/idea-IC-231.9225.16/bin/idea.sh /usr/local/bin/idea
sudo idea
- https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9
- https://nickjanetakis.com/blog/install-docker-in-wsl-2-without-docker-desktop
- If project is closing automatically while oprning then open that project from other intellin from windows.
- second option try open project from idea.sh intellij
Windows Subsystem for Linux (WSL) allows you to run a Linux distribution on your Windows machine. Here are some useful WSL commands to manage and use WSL effectively:
-
Launch WSL:
wsl
This command launches the default WSL distribution.
-
Launch a Specific Distribution:
wsl -d <DistroName>
Replace
<DistroName>
with the name of your installed distribution (e.g., Ubuntu, Debian). -
List All Installed Distributions:
wsl -l -v
This command lists all installed WSL distributions along with their version (WSL 1 or WSL 2).
-
Set Default Distribution:
wsl --set-default <DistroName>
This sets the specified distribution as the default one to be used when
wsl
is run without arguments. -
Set WSL Version:
wsl --set-version <DistroName> <Version>
Replace
<DistroName>
with your distribution's name and<Version>
with1
or2
to set the WSL version. -
Check WSL Version:
wsl -l -v
This command will show the current version (WSL 1 or WSL 2) for each installed distribution.
-
Terminate a Distribution:
wsl --terminate <DistroName>
This command terminates the specified running distribution.
-
Shutdown WSL:
wsl --shutdown
This command stops all running WSL distributions and the WSL 2 lightweight utility virtual machine.
-
Import a Distribution:
wsl --import <DistroName> <InstallLocation> <TarFile>
Imports a tar file as a new WSL distribution.
-
Export a Distribution:
wsl --export <DistroName> <FileName>
Exports the specified distribution to a tar file.
-
Unregister a Distribution:
wsl --unregister <DistroName>
Unregisters the specified distribution, deleting all its data.
Once you are in the WSL environment, you can use typical Linux commands. Here are some commonly used Linux commands:
-
Update Package Lists:
sudo apt update
-
Upgrade Packages:
sudo apt upgrade
-
Install a Package:
sudo apt install <package-name>
-
Change Directory:
cd /path/to/directory
-
List Directory Contents:
ls -la
-
Copy Files:
cp source_file destination_file
-
Move or Rename Files:
mv old_name new_name
-
Remove Files or Directories:
rm -rf /path/to/file_or_directory
-
Display Current Directory:
pwd
-
View File Contents:
cat filename
-
Edit Files with Nano:
nano filename
-
Access Windows Files from WSL:
cd /mnt/c/Users/YourUsername
The
C:
drive and other Windows drives are mounted under/mnt
in WSL. -
Run Windows Commands from WSL:
explorer.exe .
This opens the current directory in Windows File Explorer.
-
Run Linux Commands from Windows Command Prompt or PowerShell:
wsl ls -la
This runs the
ls -la
command in the default WSL distribution.
-
Check IP Address:
ip addr
-
Ping a Server:
ping www.example.com
-
Display Network Configuration:
ifconfig
- Copy Files between Windows and WSL:
cp /mnt/c/Users/YourUsername/file.txt /home/youruser/ cp /home/youruser/file.txt /mnt/c/Users/YourUsername/
By using these commands, you can effectively manage and use WSL on your Windows machine.