LoginSignup
162
151

More than 5 years have passed since last update.

【WSL】ホームディレクトリ変更手順

Last updated at Posted at 2018-04-27

「Windows Subsystem for Linux(WSL)」では、Ubuntu環境が特殊なディレクトリに隠蔽されており、アクセスがしにくかったため、ホームディレクトリを通常使っているWindowsフォルダに変更した際の手順メモ。

WSLのホームディレクトリ用のフォルダをWindows上に作成

私の場合はCドライブ配下に「linux_home」というフォルダを作成した。

Windows上のフォルダがWSL上から見えるか確認

WSL上から、Windows上のCドライブは/mnt/c/でアクセス可能なため、lsコマンドでディレクトリのリストを表示し、「linux_home」が見えるか確認する。

$ ls -la /mnt/c

ホームディレクトリのパスを変更

etc/passwdファイルのホームディレクトリの設定箇所を/mnt/c/linux_homeに変更する。

$ sudo vim /etc/passwd

(↓ユーザ名の行を探し/home/xxxを「/mnt/c/linux_home」に変更)
{ubuntu上のユーザ名}:x:1000:1000:,,,:/mnt/c/linux_home:/bin/bash

WSLをexitして再起動後、変更が反映されているか確認

起動後のディレクトリが/mnt/c/linux_homeになっているかpwdコマンドで確認する。

$ pwd
/mnt/c/linux_home
162
151
2

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
162
151