やべ、ログインできね。ってことがあったので調べてみました。
Ubuntuのrootユーザーのパスワードを忘れてしまった場合…「リカバリーモード」で対応する
リカバリーモードで起動する
ubuntu起動直後にShiftを押し続けると、GRUB(GRand Unified Bootloader)のメニューが表示される。
ここで「Advanced options for Ubuntu」を選択し、Enterを押す。(→2へ)
※ここでの操作はキーボードの方向キーとEnterで行います。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-4.png?resize=832%2C800&ssl=1)
※VPSの場合…
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image.png?resize=503%2C110&ssl=1)
ブラウザのVPS画面から「VNCコンソール」を選択
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-1.png?resize=832%2C800&ssl=1)
コンソールが表示されたら「Ctrl + Alt + Del」を送信
→再起動されるのでここでShiftを押し続けると最初の画像の画面が表示されます。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-2.png?resize=832%2C800&ssl=1)
稀に通常のログイン画面に遷移して、操作が利かなくなることがありますが、一度SSH接続ブラウザを閉じて、再度 ブラウザのVPS画面から「VNCコンソール」を選択するところから再開すると、最初の画像の画面になっていたりなっていなかったりします。
どうしても操作が利かない場合は「強制再起動」でしょうか。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-5.png?resize=189%2C243&ssl=1)
末尾が「(recovery mode)となっている行を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-6.png?resize=832%2C800&ssl=1)
「「fsck」を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-7.png?resize=832%2C800&ssl=1)
画面がバグっていますが気にせず、「fsck」を選択しEnterを押します。
(私の環境では方向キーで選択した部分は読める程度に表示されるようになりました)
「<Yes>を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-8.png?resize=832%2C800&ssl=1)
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-9.png?resize=832%2C800&ssl=1)
コマンドプロンプトが動き出すので、停止したらEnterを押します。
(私の環境には/etc/default/rcSの設定ファイルがなかったようで怒られてしまいましたが気にせず続行)
「「root」を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-10.png?resize=832%2C800&ssl=1)
「Recovery Menu」の画面に戻るので、「root」を選択し、Enterを押します。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-12.png?resize=832%2C800&ssl=1)
さらにEnterを押します。
すると…
「「root」権限にてコマンドプロンプトが起動!」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-13.png?resize=832%2C800&ssl=1)
rootユーザーでログインしている状態で、コマンドプロンプトが起動されます。
「「root」ユーザーのパスワードを変更」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-14.png?resize=832%2C800&ssl=1)
passwd root
上記コマンドでrootユーザーのパスワードを変更します
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-15.png?resize=832%2C800&ssl=1)
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-16.png?resize=832%2C800&ssl=1)
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-17.png?resize=832%2C800&ssl=1)
パスワードの変更に成功しました。
「「exit」を入力し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-18.png?resize=832%2C800&ssl=1)
exitコマンドでコマンドプロンプトから抜けます。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-19.png?resize=832%2C800&ssl=1)
「「resume」を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-21.png?resize=832%2C800&ssl=1)
「Recovery Menu」の画面に戻るので、「resume」を選択し、Enterを押します。
「「OK」を選択し、Enterを押す」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-22.png?resize=832%2C800&ssl=1)
確認画面が表示されるのでそのままEnterを押します。
「ログイン画面」
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-23.png?resize=832%2C800&ssl=1)
ログイン画面に戻ってくるので、先ほど再設定したパスワードでログインします。
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-24.png?resize=832%2C800&ssl=1)
![](https://i0.wp.com/reiji02.com/wp-content/uploads/2022/03/image-25.png?resize=832%2C800&ssl=1)
ログインに成功しました。
コメント