LoginSignup
24
35

More than 5 years have passed since last update.

Bash on Ubuntu on Windowsの設定

Last updated at Posted at 2016-08-08

自分が何を設定したのかのメモ。(20161121、aptの設定を少し追加)

ConEmu向け

日本語入力、あとシェルをさくっと出したい関係で、ConEmu上で動かしたい。
Setting -> StartUp -> Tasks で
{Bash::Bash on Ubuntu on Windows}という項目を追加し、コマンドを以下に設定。

C:\Windows\System32\bash.exe ~ -new_console:t:"Bash"

何も設定しないでbashとだけすると、起動時のディレクトリがWindowsのホームになるので、
Bash on Ubuntu on Windowsのホームにするために、波ダッシュ(~)をつける1
さらに、これをConEmuのデフォルトに設定しておく。

/etc/hosts設定

sudoでホスト名を名前解決できないと怒られるので、/etc/hostsに追記。

sudo echo "127.0.0.1 $NAME" >> /etc/hosts

apt の設定

デフォルトだとアメリカから持ってくるのでアップデート等が非常に遅い。
日本のサーバからパッケージを持ってくるようにする。2

sudo vim /etc/apt/sources.list

で、以下のように変更する。(お好みのサーバをどうぞ。)

deb http://jp.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://jp.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://jp.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse

いろいろビルド

git

sudo apt install git

各種設定

git config --global user.name "Hoge Fuga"
git config --global user.email "hoge@fuga.jp"
git config --global core.editor "vim"

screen

インストールされていたが、/var/run/screenが作れないとPermission deniedが出て終了する。
以下を実行3

sudo /etc/init.d/screen-cleanup start

しかし、実行直後にscreen is terminating・・・ → まだ動かないみたい?:2016年4月1日号 “Running Bash on Ubuntu on Windows”, Windows Subsystem for Linux・UWN#460

gcc

sudo apt install gcc

インストール。

cat << _END_ > hw.c
#include<stdio.h>
int main() {
    printf("Hello, World!\n");
    return 0;
}
_END_
gcc hw.c
./a.out
> Hello, World!

わぁい。

所感

Windows側のファイルを見に行きにくいので、もうちょっと自由になればいいなー。

24
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
35