我正在使用Windows Subsystem for Linux,并试图找到终端的.bashrc文件。
其他线程通常表示两个位置之一:
C:\Users\USERNAME\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\{LINUXUSER}\
或
C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME
在我的计算机上,Local
文件夹不包含Lxss
子目录,因此消除了第二个选项,而home
文件夹不包含任何内容,因此消除了第一个选项。在哪里可以找到.bashrc?
答案 0 :(得分:-1)
因此,显然WSL在默认情况下不会创建用户。
可以如下设置一个
$ sudo adduser newuser # new user to play with, creates in /home/newuser like your default
$ sudo cp -aR /home/newuser /mnt/c/Users/<you>
$ sudo echo "echo 'running bashrc'" >> /mnt/c/Users/<you>/newuser/.bashrc
$ sudo usermod -d /mnt/c/Users/<you>/newuser newuser
完成此操作后,您可以在该用户的主目录中编辑.bashrc配置文件
ubuntu看到的是/mnt/c/Users/<you>/newuser/.bashrc
,Windows看到的是C:\Users\<you>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\newuser\.bashrc
或者,您可以将.bash_profile
放在C:\Users\<you>
有关更多信息,请参见此线程:https://github.com/Microsoft/WSL/issues/2612
答案 1 :(得分:-1)
@quantumbutterfly's answer is incorrect. The linked thread on github relates to people finding that their .bashrc
was not run after moving their home directory.
WSL does create a default user. You do that as the last part of the setup.
You should be able to start up a WSL session and create a .bashrc
in your home directory (~).
If you want to know where that file exists in Windows, just type the following:
wslpath -aw ~
.
If you are having trouble getting your .bashrc
sourced after moving your home directory, the usermod
referenced in quantum's post is likely all you need.
Other workarounds include:
.bash_profile
in your home directory and include source ~/.bashrc
at the end of it.bash on Ubuntu on Windows
shortcut and add --rcfile ~/.bashrc
to the end of the command. For example: C:\Windows\System32\bash.exe ~ --rcfile ~/.bashrc