WSL Ubuntu Control
Use this skill to operate a local Ubuntu environment on Windows through WSL.
Prefer the bundled PowerShell scripts over ad hoc quoting when the task involves path translation, file creation, or repeated command execution.
Choose The Workflow
Run a Linux command in Ubuntu: Run scripts/invoke-wsl-command.ps1.
Create or overwrite a text file in Ubuntu with exact content: Run scripts/write-file-in-ubuntu.ps1.
Confirm the skill works on a new machine: Run scripts/smoke-test.ps1.
Working Rules
- Treat
wsl.exeas the control surface. Do not claim to attach to a GUI terminal tab when the work is really being done through WSL commands from Windows. - Prefer
-WindowsWorkingDirectorywhen the task starts from a Windows folder such asC:\Users\name\Documents\Project. The script converts it to/mnt/c/...automatically. - Prefer
-LinuxWorkingDirectorywhen the user already gave a Linux path such as/home/user/project. - After any file write, verify with a second command such as
ls -l,cat,sed -n, ortest -f. - When the user asks for a file with specific text, use the file-writing script instead of building a fragile inline shell redirection command.
PowerShell Usage
Run a command in the current Windows-backed project directory:
& '.\skills\wsl-ubuntu-control\scripts\invoke-wsl-command.ps1' `
-Distro Ubuntu `
-WindowsWorkingDirectory 'C:\Users\name\Documents\Project' `
-Command "ls -la"
Run a command directly in a Linux directory:
& '.\skills\wsl-ubuntu-control\scripts\invoke-wsl-command.ps1' `
-Distro Ubuntu `
-LinuxWorkingDirectory '/home/name' `
-Command "pwd && whoami"
Write a file with exact text:
& '.\skills\wsl-ubuntu-control\scripts\write-file-in-ubuntu.ps1' `
-Distro Ubuntu `
-LinuxPath '/tmp/example.txt' `
-Text "abc`n"
Command Strategy
- Use ordinary shell commands for exploration:
pwd,whoami,ls -la,find,cat,sed -n. - Use the write script for precise text creation because it avoids quoting and encoding mistakes.
- Prefer concise verification output. After success, report the path, key output, and whether the content matched the request.
- If the distro name is not
Ubuntu, discover it first withwsl.exe -l -vand rerun with the correct-Distro.
For path translation examples and common patterns, see references/path-and-command-patterns.md.
Validation
Before reporting success:
- confirm the target distro exists
- confirm the command exited successfully
- confirm the file or directory state actually changed
- confirm the resulting text matches the user request when the task writes content
Deliverable
Report the distro used, the important command result, and the final file path or command output.