You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改WSL Ubuntu的/home/ubuntu文件?Windows下如何定位该目录并编辑?

WSL Ubuntu: Editing Files & Accessing /home/ubuntu from Windows

Hey there! Let's tackle your two WSL questions one by one—these are super common scenarios, so you're definitely not alone here.

1. How to modify files in /home/ubuntu

You've got a couple straightforward options here:

  • Edit directly in WSL bash: Use a terminal-based editor like nano (beginner-friendly) or vim. For example, to edit a file named test.txt, run:
    nano /home/ubuntu/test.txt
    
    Once you're done editing, press Ctrl+O to save, then Ctrl+X to exit. For vim, use i to enter insert mode, Esc to exit edit mode, then :wq to save and quit.
  • Edit from Windows (ties into your second question): You can access the /home/ubuntu directory directly from Windows File Explorer and use Notepad++ to edit files—keep reading for the step-by-step.

2. Finding /home/ubuntu in Windows & editing with Notepad++

Absolutely, this is totally feasible! WSL provides a seamless way to access its file system from Windows. Here's how:

  • Open Windows File Explorer (press Win+E).
  • In the address bar at the top, type \\wsl$\Ubuntu\home\ubuntu and hit Enter.

    Note: If your WSL distribution has a different name (e.g., Ubuntu-22.04), replace Ubuntu with your actual distro name. You can check the name by running wsl -l in a Windows Command Prompt or PowerShell.

  • Once you're in this folder, you'll see all the files and folders you created in WSL's /home/ubuntu directory.
  • Now you can:
    • Drag and drop files directly into Notepad++ to edit them.
    • Open Notepad++, go to File > Open, navigate to the \\wsl$\Ubuntu\home\ubuntu path, select your file, and start editing. Any changes you save in Notepad++ will immediately show up in WSL bash.

Important Note

Never try to modify WSL's underlying virtual disk file (usually tucked away in C:\Users\<YourWindowsUsername>\AppData\Local\Packages\CanonicalGroupLimited...\LocalState\ext4.vhdx) directly. Always use the \\wsl$\ path to access WSL files from Windows—this ensures your file system stays intact and changes sync properly between WSL and Windows.

内容的提问来源于stack exchange,提问作者JBarros35

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:36:44