Linux Learning Environment

Introduction

You need a place to practice commands—a VM, WSL2 on Windows, or a small cloud VPS. This chapter compares those options, shows how to open a terminal and SSH into a remote machine, and introduces sudo and optional Ubuntu mirror tuning so installs match later chapters.

Prerequisites

  • What is Linux
  • Internet access to download images or create a cloud instance

Pick an Environment

OptionBest forNotes
WSL2 + UbuntuWindows developersFast setup; good for Java/Node on Windows + Linux CLI
Local VMIsolated full LinuxVirtualBox / VMware + Ubuntu Server ISO
Cloud VPSReal server practiceAlibaba, Tencent, AWS, DigitalOcean, etc.
Physical / dual bootDedicated Linux boxOptional; same commands apply

All paths below should give you a bash prompt and sudo.

  1. Enable WSL in PowerShell (Administrator):
powershell
wsl --install

Reboot if prompted. Default is often Ubuntu.

  1. Launch Ubuntu from Start menu, create a UNIX username and password.

  2. Verify inside WSL:

bash
# Confirm Linux environment
uname -a
lsb_release -a

Install JDK or Node inside WSL when following Java Linux or Node Linux chapters—or on Windows host, depending on your workflow.

Tip

WSL vs Remote Server

WSL is excellent for learning commands locally. Production deploys still happen on remote Linux VPS—practice SSH below even if you use WSL daily.

Local Virtual Machine

  1. Download Ubuntu Server LTS ISO from ubuntu.com/download/server.
  2. Create a VM in VirtualBox or VMware (2 GB RAM minimum, 20 GB disk).
  3. Install Ubuntu Server; enable OpenSSH server when the installer offers it.
  4. Note the VM IP (bridged networking) or use port forwarding for SSH.

Verify after install:

bash
uname -a
whoami

Cloud VPS (First Remote Server)

Typical flow on any provider:

  1. Create an instance: Ubuntu 22.04/24.04 LTS, 1 vCPU, 1–2 GB RAM for learning.
  2. Add your SSH public key at creation (recommended) or use root password once.
  3. Note the public IP and security group rules: allow TCP 22 (SSH) from your IP.

Connect from your laptop:

bash
# Replace with your user and public IP
ssh ubuntu@203.0.113.10

Provider images often use user ubuntu, ec2-user, or root—read the provider docs.

Local Terminal vs SSH

ContextHow you connect
WSL / VM console / desktop terminalAlready on the machine
Remote VPSssh user@host over the network

SSH encrypts your session. For production, prefer keys, not passwords.

SSH Key Authentication

On your client machine (laptop):

bash
# Create a key pair (Ed25519 recommended)
ssh-keygen -t ed25519 -C "you@example.com"

Press Enter for default path ~/.ssh/id_ed25519. Optionally set a passphrase.

Copy the public key to the server (Linux with ssh-copy-id):

bash
# Install your public key on the server
ssh-copy-id ubuntu@203.0.113.10

Manual method: append ~/.ssh/id_ed25519.pub content to server ~/.ssh/authorized_keys (one line per key).

bash
# On server: correct permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Test login—it should not ask for a password if keys are configured.

Understanding sudo

sudo runs one command as root (administrator):

bash
# Update package index (needs root on Ubuntu)
sudo apt update

Your normal user should not log in as root for daily work. sudo grants temporary elevation and is audited.

bash
# See which groups you belong to
groups
 
# Often your user is in the 'sudo' group on Ubuntu

Warning

Never paste random curl | bash install scripts without reading them. Use sudo only when you understand the command.

Optional: Ubuntu Mirror (Faster Downloads in China)

Backup then edit sources (Ubuntu):

bash
# Example only — use your distro’s recommended mirror list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

Many tutorials replace archive.ubuntu.com with a regional mirror (Tsinghua, Aliyun, etc.). Follow your university or cloud provider mirror documentation. Then:

bash
sudo apt update

Wrong mirrors cause apt update failures—keep the .bak file to restore.

Verify the System

Run this checklist on any new environment:

bash
# Kernel and architecture
uname -a
 
# Distribution (Ubuntu/Debian)
lsb_release -a 2>/dev/null || cat /etc/os-release
 
# Disk space
df -h /
 
# Memory
free -h

Save the VPS IP and SSH user in a password manager or ~/.ssh/config:

text
Host my-learn
    HostName 203.0.113.10
    User ubuntu
    IdentityFile ~/.ssh/id_ed25519

Then connect with:

bash
ssh my-learn

Mini Exercise: First Remote Session

  1. Create cloud or VM Ubuntu instance.
  2. SSH in with keys.
  3. Run whoami, hostname, pwd.
  4. Run sudo apt update (no upgrade required yet).

FAQ

WSL hostname vs Windows path?

Windows files appear under /mnt/c/ in WSL. Keep Linux projects under ~/projects for fewer permission surprises.

Connection refused on SSH?

Check VPS firewall/security group, sshd service (sudo systemctl status ssh), and correct IP/port 22.

Forgot sudo password?

On WSL/VM you control the install—reset via recovery. On cloud VPS, use provider console “reset password” or key-only access.

Root login allowed?

Some images disable root SSH. Use sudo from a normal user—good practice.

What comes next?

Filesystem and basic commands.