Linux
If you want to give the host direct access in WSL, you need to enable user_allow_other.
Uncomment user_allow_other
#id -g aimwang
公司的編譯伺服器使用 Ubuntu 16.04, 為了減低編譯環境造成的影響, 所以在本機編譯環境也採用相同的版本.
Windows Store 沒有提供 Ubuntu 16.04, 所以要手動安裝
1. 下載 Ubuntu 16.04 的 appx. (連結)
2. 執行 Windows PowerShell, 切換到下載目錄.
3. 在 PowerShell 裡面執行 Add-AppxPackage .\Ubuntu_1604.2019.523.0_x64.appx
完成後就可以看到 Ubuntu 16.04 的應用程式. 第一次執行要設定使用者.
auto eth0iface eth0 inet staticaddress 172.19.240.2netmask 255.255.240.0gateway 172.19.240.1dns-nameservers 172.19.240.1
[host 端的 vEthernet 沒有固定 IP 無意義]
執行, 或加入開機 task
wsl -d Ubuntu-16.04 -u root ifconfig eth0 172.19.240.2 netmask 255.255.240.0
wsl -d Ubuntu-16.04 -u root rout add default gw 172.19.240.1
在沒有桌面環境的情況下, 只能用 command line 模式設定網路介面.
Ubuntu 是透過 netplan 來設定.
#sudo nano /etc/netplan/01-network-manager-all.yaml
以下內容設定 enp8s0
ip: 192.168.1.140/24
gw: 192.168.1.1
dns: 8.8.8.8 1.1.1.1
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: networkd
ethernets:
enp8s0:
addresses: [192.168.1.140/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
使用sshfs比samba安全方便. 但是 Geany 存取 sshfs-win 掛載進來的檔案, 在存檔時會抱怨 Permission denied.
解決的方式是撤銷 use_gio_unsafe_file_saving. 操作如下:
1. 拉下【編輯(E)】選單, 點擊【偏好設定(S)】
2. 切換到【各種類型】, 取消勾選 files.use_gio_unsafe_file_saving. 然後套用並確定.
local debug = 0
function dbg_print(...)
if 1 == debug then
local dbg = io.open("/dev/console", "w")
if dbg then
dbg:write(os.date("[%H:%M:%S]: "))
for _, o in ipairs({...}) do
dbg:write(tostring(o)..' ')
end
dbg:write("\n")
dbg:close()
end
end
end