Saturday, 31 August 2024

Install & Uninstall Ubuntu on Windows with WSL2

To install Ubuntu on Windows 10 using WSL2 (Windows Subsystem for Linux version 2), follow these steps:

Step-by-Step Guide to Install Ubuntu on Windows 10 with WSL2

  1. Enable WSL and Virtual Machine Platform:

    • Open PowerShell as Administrator. You can do this by right-clicking on the Start button and selecting “Windows PowerShell (Admin)”.

    • Run the following commands to enable WSL and the Virtual Machine Platform:

      powershell
      dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  2. Set WSL2 as the Default Version:

    • To set WSL2 as the default version, run:

      powershell
      wsl --set-default-version 2
  3. Restart Your Computer:

    • Restart your computer to apply the changes.
  4. Install Ubuntu from Microsoft Store:

    • Open the Microsoft Store app.
    • Search for “Ubuntu” and select your preferred version (e.g., Ubuntu 20.04 LTS).
    • Click on the “Get” button to download and install Ubuntu.
  5. Initialize Ubuntu:

    • After installation, open the Ubuntu app from the Start menu.
    • A console window will open, and Ubuntu will initialize. This may take a few moments.
    • You’ll be prompted to create a new UNIX username and password. This username and password are for your Ubuntu environment.
  6. Check WSL Version:

    • To ensure that your Ubuntu installation is using WSL2, run the following command in PowerShell:

      powershell
      wsl --list --verbose
    • You should see Ubuntu listed with version 2 next to it. If it shows version 1, you can change it to WSL2 by running:

      powershell
      wsl --set-version Ubuntu-20.04 2

    (Replace Ubuntu-20.04 with the exact name of your Ubuntu installation if it's different.)

  7. Start Using Ubuntu on WSL2:

    • You can now start using Ubuntu by launching it from the Start menu or by typing wsl in PowerShell or Command Prompt.

Additional Tips

  • Update and Upgrade Ubuntu: Run sudo apt update && sudo apt upgrade in your Ubuntu terminal to keep your packages up to date.
  • Access Windows Files: You can access your Windows files from Ubuntu via the /mnt/c directory (for the C: drive).

That's it! You now have Ubuntu running on Windows 10 using WSL2, allowing you to use Linux commands and software directly within Windows.

 

* folder data: C:\Users\{user_name}\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_..

Thank you

Learn English

1. Vocabularies

- conscioutly

- deliberately



Thursday, 1 August 2024

Free up space docker

Docker resources to free up space. Here are some steps to do that:

  1. Remove Unused Volumes:

    docker volume prune
  2. Remove Unused Networks:

    docker network prune
  3. Remove Stopped Containers:

    docker container prune
  4. Remove Unused Images:

    docker image prune
  5. Remove All Unused Resources:

    docker system prune
  6. Remove All Unused Resources Including Volumes:

    docker system prune -a --volumes
  7. Check Docker Disk Usage:

    docker system df
  8. Identify and Remove Specific Unused Images: List images:

    docker images

    Remove specific image:

    docker rmi <image_id>
  9. Remove Unused Containers: List containers:

    docker ps -a

    Remove specific container:

    docker rm <container_id>
  10. Clean Docker Build Cache:

    docker builder prune

Thank you

Golang Advanced Interview Q&A