essay | tech | year-summary | about
日期:2018-04-02T00:00:00Z
记录下自己使用时感觉实用的小知识吧!
wsl = Windows Subsystem Linux, 是只有win 10 有的功能。有了wsl,妈妈再也不担心用cygwin的卡顿,用powershell的奇怪语言(?)的困扰和,用MinGW的...(突然找不到可以黑的点)。
这个是很早就出名的一个,win10专为开发者开发的一样东西。
目前推荐的方式是使用microsoft store去下载。
在microsoft store搜索linux,可以找到ubuntu, debian, kari linux等等诸多版本。个人比较推荐debian(原因是我的linux是ubuntu入手,比较习惯于apt家族。顺便一提,新版本提倡使用apt,而不是apt-get)
在博主看来两者有以下的区别:
我个人使用的是这一款:https://github.com/goreliu/wsl-terminal
自带的terminal会有如下问题。
you-get "https://www.youtube.com/watch?v=F2u3BhtMUTE"
(PS:博主版权的视频,并非非法下载,也欢迎大家下载,凭本文持有博主许可,另外需遵循youtube条则)
在debian的原生terminal会出现这样的感觉

因为似乎错了一个字节,然后就开始错位了,没有办法正确出现下图的这种情况。

使用wslconfig。
wslconfig /l
wslconfig /l /a
wslconfig /setdefault
简单明了,应该不用解释了。
切换了之后,会发现比如我使用的那款terminal,会自动切换到默认的wsl。在powershell或者cmd里面,敲打bash或者wsl,也会开启默认的wsl。
https://www.linode.com/docs/guides/linux-mount-smb-share/
sudo apt install cifs-utils psmisc
mount -t cifs
fuser
mkdir /mnt/smb_share
mount -t cifs //[server-ip]/[share-path] /[mount-point]
mount -t cifs
nano ~/.credentials
sudo chmod 600 <Credentials Filename>
sudo mount -t cifs -o credentials=<Credentials Filename> //<IP Address of Server>/<Share on Server> /<Mount Point>
umount -t cifs /<Mount Point>
File: .credentials
username=target_user_name
password=target_user_password
domain=domain
File: /etc/fstab
<file system>: //<IP Address of Server>/<Share on Server>
<mount point>: <Mount Point>
<type>: cifs
<options>: credentials=<Credentials Filename>
systemctl daemon-reload
https://superuser.com/questions/1791373/location-of-wsl-home-directory-in-windows
\\wsl.localhost\Ubuntu\home\{username}
https://learn.microsoft.com/en-us/windows/wsl/disk-space
https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-locate-the-vhdx-file-and-disk-path-for-your-linux-distribution
replacing with the actual distribution name
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '<distribution-name>' }).GetValue("BasePath") + "\ext4.vhdx"
diskpart
Select vdisk file="<pathToVHD>"
detail vdisk
expand vdisk maximum=<sizeInMegaBytes>
compact vdisks
exit
参考资料: