0
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 1 year has passed since last update.

WSLでのUbuntu環境

Posted at
1 / 2

授業でWSLをインストールして使っていく上で起こりがちな問題点と解決法を備忘的に書き連ねます

wslをインストールする際に入力するパスワードは sudoするときには使えるが、suするときには使えない。rootになるためには Powershell を開いて wsl -u rootするとノーパスワードでrootになれる。
しばしばsudoするためのパスワードを忘れる場合があり、上記の様にしてPowershell上でrootになって、passwd usernameとすれば再設定することができる。(ubuntuを開き直せば設定したパスワードでsudoできるはず)

また、ubuntuを開くとrootになっている、という状態になることがあり、解決法としては一般ユーザとしてのusernameをfooとすると、adduser fooとしてユーザーを作成し、同時に2回sudoのパスワードを聞かれるので設定する。ついで sudo gpasswd -a foo sudo としてfooにsudo権限を与え、パワーシェルを開いて ubuntu config --default-user fooとしてデフォルトのユーザー名を指定すれば、次にubuntuを開く際にfooで入ることができる。

sudo apt updateとしてアップデートが進まない場合(茶色い文字の%の数字が0から全く増えない場合)にはネームサーバーの設定が適切ではない場合が多い。/etc/resolv.confを編集してGoogleのネームサーバーを指定すると解決することが多いのでエディタで編集するか、sudo cp /etc/resolv.conf /etc/resolv.conf.orgとして現状のファイルのバックアップを取ってから、sudo echo 'nameserver 8.8.8.8' > /etc/resolv.confとすれば、sudo apt updateができるようになる。sudo echo 'nameserver 8.8.8.8' > /etc/resolv.confで、Permission deniedなど許可がないとのメッセージが出る場合は、sudo chmod o+w /etc/resolv.confとしてから、もう一度試す。

0
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
0
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?