Tag: windows subsystem for linux

如何获取源文件的真实路径

我在~/.bashrc添加了这一行 . /mnt/c/Users/enzo/drive/projects/dotfiles/init.sh 并且在init.sh内部我试图获取init.sh的路径,但我无法做到。 到目前为止我试过这个: CURDIR=`/bin/pwd` BASEDIR=$(dirname $0) ABSPATH=$(readlink -f $0) ABSDIR=$(dirname $ABSPATH) REAL=$(realpath $0) echo “CURDIR is $CURDIR” echo “BASEDIR is $BASEDIR” echo “ABSPATH is $ABSPATH” echo “ABSDIR is $ABSDIR” echo “REAL is $REAL” 输出: CURDIR is /mnt/c/Users/enzo BASEDIR is /bin ABSPATH is /bin/bash ABSDIR is /bin REAL is /bin/bash 我在windows子系统下用于linux。

如果shell脚本中的/ Else在Ubuntu for Windows中引发错误

这是一个简单的shell脚本示例: #!/usr/bin/env bash if [ 1 == 1 ]; then echo “Something” fi 当我跑这个 sh ./test.sh 我明白了: ./test.sh: 4: ./test.sh: Syntax error: “fi” unexpected (expecting “then”) 它似乎没有认出我在那里的’那么’。 任何线索为什么? 这是部分重要的Ubuntu for Windows。 一般运行shell脚本不是问题,它似乎与if / else斗争。

位于Windows子系统Linux中的〜/ .bash_profile在哪里?

当试图从Windows子系统Linux中的Ubuntu Xenial(16.04)访问~/.bash_profile ,我收到以下错误: -bash: /home//.bash_profile: No such file or directory 它位于何处,如何编辑? 谢谢!

Ubuntu通过(Windows Linux子系统)和Docker

我已经开始使用Windows 10的Linux子系统,并且使用Ubuntu 14.04取得了巨大的成功。 到目前为止,使用Docker没有运气 – 这是平台的限制还是Docker + WLS组合将来可行? 我有很多脚本需要Linux和docker存在。

如何在Windows的Windows子系统上禁用IPv6?

我尝试通过添加/etc/sysctl.conf来禁用IPv6: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 然后运行sudo sysctl -p来重新加载/etc/sysctl.conf设置 – 但是这引发了错误: sysctl: cannot stat /proc/sys/net/ipv6/conf/all/disable_ipv6: No such file or directory 我试图通过将grub配置/etc/default/grub.d/50-cloudimg-settings.cfg更改为:来禁用它: GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 console=tty1 console=ttyS0″ 然后运行sudo update-grub但没有安装update-grub: sudo: update-grub: command not found 所以我不确定是否有可能更新grub,但事实上有一个特定的配置在那里让我有所作为。 WSL版本: Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial

在WSL上运行gnome-keyring(适用于Linux的Windows子系统)

我一直在尝试使用Keyring(Gnome Keyring)使用本文中的步骤存储HTTPS GIT凭据: http://blog.iqandreas.com/git/storing-https-authentication-in-ubuntu-and-arch-linux/ 我采取了以下步骤: sudp apt-get install make sudo apt-get install-gnome-keyring-dev sudo make –directory=/usr/share/doc/git/contrib/credential/gnome-keyring git config –global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring 现在,当我使用任何远程git命令时,我收到错误: ** (process:19273): CRITICAL **: Error communicating with gnome-keyring-daemon 是不是可以在WSL上运行守护进程,或者我错过了一些简单的东西? 对不起,如果这是一个不同类型的问题,我是Ubuntu的新手。 另一方面,为标签’ubuntu-on-windows’创建一个同义词’WSL’会是个好主意吗? 我认为这可能成为ubuntu-on-windows最合乎逻辑的首字母缩写: https : //blogs.msdn.microsoft.com/wsl/ 更新: 我试过@LordMord说的话: 在〜/ .bashrc的末尾添加 ssh-add -l &>/dev/null if [ “$?” == 2 ]; then test -r ~/.gnome-keyring && \ […]

Windows子系统Linux(WSL)的更好的终端体验?

Windows子系统Linux(WSL)的终端相当小。 我没有在Windows上使用终端 – 我通常使用Ubuntu或OSX – 但我很惊讶默认终端是如此裸露。 有可能: 将Windows终端程序连接到WSL或 从WSL启动Ubuntu终端程序作为X窗口?

权限使用Windows复制/粘贴将文件复制到Windows上的Ubuntu时出错

我目前正在微软商店的Windows上使用Ubuntu。 为了尝试我的一些Python脚本,我将它们复制并粘贴到我可以使用Ubuntu会话访问的文档文件夹中: C:\Users\[MyUsername]\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\[MyUsername] 但是当我查看脚本时,它返回”PermissionError: [Errno 13] Permission denied: ‘[folderName]” 。 有没有办法将文件和文件夹从Windows会话复制/粘贴到Ubuntu文件夹,而无需在所有文件上运行chmod? 谢谢你的时间

如何在WSL中运行服务

在搜索了这个站点和各种Q之后,很明显服务和systemd不适用于WSL。 每次启动我的电脑时我都需要在WSL中运行一个程序所以我读了这个页面关于如何使用crontab: 如何在Windows上运行Ubuntu服务(启动时)? | 超级用户,但我感到困惑,因为格式与crontab中的格式不符。 但这是我的cron: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PATH=cd /usr/local/src/:cd xmr-stak-cpu:cd bin/ @reboot . sudo ./xmr-stak-cpu 我也这样做了: 启动时运行bash / cron循环 Create a file called linux.bat in shell:startup Paste: C:\Windows\System32\bash.exe -c ‘while [ true ]; do sudo /usr/sbin/cron -f; done’ 这是行不通的。 如何在WSL中运行服务? 肯定有一种方法不需要我成为Linux博士? 或者有没有办法使用Windows 因为在Windows中我尝试了以下内容:使用https://github.com/Microsoft/WSL/issues/612 Run: When the computer starts, Action: Start a program, Program: c:\Windows\system32\bash.exe, Arguments: […]

在ubuntu命令行中,在Win10 WSL中的文件管理器中打开一个文件夹?

在Ubuntu我经常这样做 nautilus . 在GUI中打开当前文件夹。 我如何在Win10 WSL中执行此操作? 你甚至可以从WSL命令行启动窗口应用程序吗?