Windows 10 中“Bash on Ubuntu on Windows”的 .bashrc 位置 (Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10)


問題描述

Windows 10 中“Bash on Ubuntu on Windows”的 .bashrc 位置 (Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10)

微軟剛剛在其 Windows 10 週年紀念版中引入了一個 Linux 子系統。安裝非常簡單,但我無法在 Windows 上找到 bash 文件。

它是如何工作的?~ 在 Windows 中指的是什麼?在哪裡可以找到 .bashrc


參考解法

方法 1:

Since the Windows 10 Fall Creators Update, the location changed to:

C:\Users\USERNAME\AppData\Local\Packages\{DIST}\LocalState\rootfs\home\{LINUXUSER}\

Where:

  • {DIST} is equal to CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
  • {LINUXUSER} is the user for which you are looking for the .bashrc file

Just for anyone wondering that came here from Google.

方法 2:

Sorry for the misunderstanding, I check on google and it will be at C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME .

I tried and it works, in the cmd just type cd\ && dir *bashrc* /s it will locate the file, and in my case i see the line C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME but when I want to navigate it with the window browser it doesn't work, but if you copy paste it, it works :‑)

I found it here.


Considering that you need to know where a file is located you can use the find command. The syntax of the command is find {search‑path} {file‑names‑to‑search} {action‑to‑take}by default the action to take is printing the file name. So if you are finding .bashrc file you can use find / ‑name .bashrc the bash will return you /home/yourusername/.bashrc

Also, if you want to access to your home directory you can use cd ~ Hope my answer will be helpful :‑)

方法 3:

just type vi ~/.bashrc

and that should put you into the file where ever it is. You can navigate there simply by doing cd ~ List all files with ls ‑a and you should be able to see it.

方法 4:

~ means that is user home folder, way like /home/%username%/

you can list files like ls ‑al and see .bashrc file.

方法 5:

Other answers doesn't work for me using WSL 2.

The LocalState folder contains a virtual disk so rootfs does not exist,

and AppData\Local folder does not have the Lxss folder.

The solution for me is surprisingly simple:

wsl ‑u root

This will allow you to get into wsl as root.

From here, you have access to the whole linux. Fix the .bashrc or anything you want.

Don't screw up the root user. :)

(by Meet TaraviyancwBinaryDumpJhirschibarJames Munional)

參考文件

  1. Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10 (CC BY‑SA 2.5/3.0/4.0)

#windows-subsystem-for-linux #linux #.bash-profile #bash #Windows






相關問題

Windows 10 中“Bash on Ubuntu on Windows”的 .bashrc 位置 (Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10)

無法在 WSL Ubuntu 18.04 上安裝 R Shiny Server (Cannot install R Shiny Server on WSL Ubuntu 18.04)

從 Windows 10 的 wsl 將捲設置為 docker 容器 (Set volume to docker container from wsl from windows 10)

npm 錯誤!使用 wsl 將 npm 模塊安裝到 Windows 10 時出現錯誤 -13 (npm ERR! errno -13 when Installing npm module to windows 10 with wsl)

如何使用 WSL 訪問 Odoo 12 (How to access Odoo 12 using WSL)

用 recorder.js 錄製語音並將其上傳到 python-flask 服務器,但 WAV 文件已損壞 (Record voice with recorder.js and upload it to python-flask server, but WAV file is broken)

無法將 WSL 節點解釋器添加到 WebStorm (Can't add WSL Node Interpreter to WebStorm)

即使我通過瀏覽器下載了最新的穩定版本,為什麼我的 ubuntu 終端 v10 中的節點版本仍然存在? (Why is my node version in my ubuntu terminal v10 even though I downloaded the latest stable version through browser?)

帶有 python 子進程的 WSL (WSL with python subprocess)

在 Powershell 中重定向 WSL 輸入 (Redirect WSL input in Powershell)

VSCode WSL奇怪的顏色問題 (VSCode WSL Weird Colors Issue)

FAT[0000] 無效配置:未提供配置 (FATA[0000] invalid configuration: no configuration has been provided)







留言討論