iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🍎

Accessing the Windows Desktop from WSL

に公開3件

https://zenn.dev/ohno/books/356315a0e6437c/viewer/3fefe4

Please refer to the page above for instructions on installing WSL.

Accessing the Windows Desktop in WSL

You can access the Windows desktop from WSL with the following command. If Ctrl + v does not work for pasting, please try right-clicking.

cd /mnt/c/Users/Username/Desktop/

Since typing long paths every time is tedious, let's create a shortcut (symbolic link) in your home directory. You can create it by running the following command. If Ctrl + v does not work for pasting, please try right-clicking.

cd
ln -s /mnt/c/Users/Username/Desktop/ desktop

From now on, you can access it simply with cd desktop.

.

Exchanging Files

If you want to exchange files between the WSL side and the Windows side, you can do so using File Explorer. Please refer to the following.

https://zenn.dev/ohno/articles/13af6f4e1588a5

Discussion

ahmahm

質問失礼します。WSLでUbuntu環境を作り、問題なく緑色の文字でユーザー名@端末名の状態にはなったのですが、/mnt/c/Users/ユーザー名/のディレクトリが存在せず、シンボリックリンクの作成等にうまく進めず躓いています。

Ubuntuのインストールまで行えていれば、入力したUNIXユーザー名と同名のディレクトリが/mnt/c/Users/下に作られているべきものなのでしょうか?

それとも、「/mnt/c/Users/ユーザー名」で言う「ユーザー名」はUNIXユーザー名ではなくPCのユーザー名を指しているのでしょうか?(PCユーザー名のフォルダなら確かに/mnt/c/Users/下に存在します)

1
大野 周平大野 周平

ご質問頂きありがとうございます。
/mnt/c/Users/ユーザー名/のユーザー名はUNIXユーザー名ではなくPCユーザー名のことです。つまり/mnt/c/Users/ユーザー名/Desktop/がWindows側のデスクトップのパスです。ディレクトリ自体は元から存在しており、WSL・Ubuntsuをインストールした時点でC:/Users/ユーザー名/Desktop/が/mnt/c/Users/ユーザー名/Desktop/として認識できるようになっています。/mnt/cがCドライブを意味するので、同じ要領で他のディレクトリもアクセスできます。

PCユーザー名のフォルダの存在が確認できているとのことですので、そのパスにアクセスして頂ければ、Windows側のデスクトップ上でUbuntsuを操作できます。シンボリックリンクを作っておくと、デスクトップ等に置いてあるC言語のソースコードをコンパイルしたい場合などに便利です。

なお、ブラウザなどでダウンロードしたファイルなどをコピーしたいだけでしたら、こちらの記事に沿って、Windows側のエクスプローラーから操作した方が、ドラッグ&ドロップだけでコピーできるのでおすすめです。ただし、Ubuntsuを起動中にしかUbuntsu のフォルダにはアクセスできないです。

1
ahmahm

御回答ありがとうございます。いろいろと辻褄が合い、無事すすめられそうです。
引き続き参考にさせていただきます!

1