1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ubuntu以外のディストリビューションで起動時のデフォルトユーザーを設定する。(WSL)

Last updated at Posted at 2021-09-03

導入

備忘録用に記録しておきます。

Ubuntuはインストールした直後にsudoユーザーの作成プロンプトが表示され、それでユーザーを一度作ってしまえばそれがデフォルトユーザーになり、次回以降からubuntu wslを起動すると最初からそのユーザーでセッションが始まるわけですが。

microsoft storeにリリースされていないディストロでwsl環境を作成すると、デフォルトユーザーがrootで始まってしまって非常によろしくない。毎回 su <username> を打つのも精神衛生上よろしくない。

これをどうにかしたい、今回は Gentoo Linux on WSL2 でこの問題を解決していくとする。私はホモでせっかちなのですぐ下に結論を書いておいた。

結論

わたしは Gentoo Linux for WSL2を使用してるので、Gentoo.exeがあるディレクトリまでcdコマンドで移動して以下のコマンドを打つだけで済んだ。コマンドは Powershellで実行すること。
*hogehogeは起動時に指定したいデフォルトユーザー名。

.\Gentoo.exe config --default-user hogehoge

Arch Linuxだったら .\Arch.exe config --default-user hogehoge で、ほかのディストロも exe のところだけ変えれば問題なくできると思う。

結論に至るまで試行錯誤

wsl のコマンドで設定できればいいのに、とは思ったがそれはできないらしい。

wsl -d Gentoo -u hogehoge
上記のコマンドでGentoo WSLを起動し、 hogehoge ユーザーで実行できる。ならば

wsl -s Gentoo -u hogehoge
これでデフォルトのWSLをGentooに設定しながらデフォルトのユーザーを hogehoge にできるのではないかと思ったができなかった。

そしてとある記事を見た。
https://hetarena.com/archives/2856

どうやらUbuntuでは ubuntu config --default-user hogehoge と打つだけでユーザーを変えられるらしい、このubuntuを置き換えればいけそうではないか?
結果うまくいった、といった感じだった。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?