問題描述
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 toCanonicalGroupLimited.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 Taraviya、ncw、BinaryDump、Jhirschibar、James M、unional)