LoginSignup
1
0

More than 1 year has passed since last update.

WSLへの権限追加 (Permission denied (os error 13))

Last updated at Posted at 2022-02-12

1. 経緯

WSL で Rust を使うため、cargo をインストールしようとしたら以下のエラーが表示された。

error: could not create bin directory: '/home/usr/.cargo/bin': Permission denied (os error 13)

2. 対応

ls -l  で確認してみた。

drwxr-xr-x 10 root root 4096 Aug  5  2021 others
drwxr-xr-x  2 root root 4096 Feb 13 00:06 user

mkdir も Parmission denied、 sudo を付けても同様だった。そこで権限の追加を色々調べて試していたら、以下のコマンドで解決した。

/home$ sudo chmod o+x <username>

ポイントは、例えば上のように home ディレクトリにいる場合、権限を付与したいディレクトリ名を相対パスで記述する。

chmod (change mode)は権限を追加・解除の変更コマンド、o は他の(other)ユーザー、x は実行(execute)を表す。x の箇所を r や w にしてその他の権限を追加できる。 反対に+のところを-にすれば権限の解除が可能。

結果:

drwxr-xr-x 2 root      root      4096 Oct  3 16:51 Program
d------rwx 6 user_name user_name 4096 Feb 13 00:46 usr
1
0
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
1
0