Root password debian linux

How do you change the root password on Debian?

I want to change the password I assigned to root on my Debian webserver to something longer and more secure. How do I do that? I haven’t forgotten/lost the current password, I just want to change it.

To find this out for yourself, run apropos password : you’ll get a list of commands that contain “password” in their short description. You can narrow the search a little with apropos -s 1 password : -s 1 restricts to section 1 of the manual, which contains user commands.

3 Answers 3

Or, if you’re running as root already (which you shouldn’t be), just:

The root argument can be omitted, because when you execute passwd it defaults to the current user (which is root, as only root can change the root password).

@Shadur: painfully 🙂 I’d just never done it before, and the Google links I found first were for folks who had forgotten the root password.

@Paul I took liberty in editing your answer. There are a few ways to run things as root, and when passwd is run as root, it defaults to modify the root user.

If you’re going to be doing a lot of command-line administration, you might find it useful to check out the man pages for usermod(8), chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8),

You have to boot in Recovery Mode before using Paul D. Waite’s suggestion:

  1. Right after booting your Debian system choose «boot in Recovery Mode»
  2. Right after booting into «Recovery Mode» right at the command prompt simply type:

“You have to boot in Recovery Mode before using Paul D. Waite’s suggestion” — Really? I don’t remember doing that. Is this a new thing in a new version of Debian?

You must log in to answer this question.

Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Как сбросить пароль в Debian

img

Вы забыли свой пароль пользователя root в Debian? Не волнуйтесь, мы покажем, как сбросить пароль root в Debian. Просто выполните следующие шаги и восстановите доступ и установите новый пароль root.

 Как сбросить пароль в Debian

Сброс пароля

Запустите машину с Debian и нажмите любую клавишу, чтобы остановить процесс загрузки. Выберите “Debian GNU/Linux ” и нажмите клавишу “e” для редактирования параметров ядра в командной строке.

 Debian GNU/Linux

Используйте клавишу «стрелка вниз» для прокрутки вниз. Перейдите к строке, которая начинается со слова linux и с помощью стрелок перейдите к концу строки или нажмите кнопку «end», а затем там (после quiet) добавьте init =/bin/bash .

init =/bin/bash

После добавления записи нажмите Ctrl + x или F10 для загрузки системы.

Debian теперь загрузится в однопользовательском режиме, а корневая файловая система смонтирована в режиме только для чтения (read-only mode). Поэтому используйте команду ниже для монтирования корневой файловой системы в режиме чтения-записи (read-write mode).

Наконец, измените пароль пользователя root с помощью команды passwd . Тут указываем новый пароль и подтверждаем его.

passwd

Перезагрузите систему и используйте новый пароль, который установили для пользователя root в вашей системе.

Источник

How to Reset the Root Password on Debian 9 Stretch

In this article, I will show you how to configure sudo, set root password, disable root login and reset root password. This can be done even if you don’t have sudo enabled and you don’t remember the password. Let’s get started.

Installing and Configuring sudo

If you have set up a root password while installing Debian 9 Stretch on your machine, then there’s a chance sudo won’t be configured. So you won’t be able to run any commands as root user if you’re logged in as an ordinary user.

In this section, I am going to show you how to install and configure sudo to run commands as root user without login in as user root.

First log in as root with the following command:

Now type in your root password and press .

You should be logged in as root user.

Now update the apt package repository cache with the following command:

The apt package repository cache should be updated.

Now install sudo with the following command:

It should be installed. In my case it is already installed.

Now to add your ordinary user, let’s say shovon to the sudoers file, run the following command:

NOTE: Here shovon is an ordinary user account on my Debian 9 Stretch system.

Now exit out of the root user with the following command:

Now the ordinary user shovon can run any command as root using sudo as follows:

Enter the login password of user shovon and press .

The command should run as root as you can see from the screenshot below.

Setting Root Password

If you haven’t set a root password while installing Debian 9 Stretch, then root password by default won’t be set. But sudo should be configured for your ordinary user.

To set a root password then, run the following command:

Now type in the password for your logged in user and press to continue.

Now type in your desired root password and press .

Now retype the root password and press .

The root password should be set. Now you can login as root using your root password.

Changing Root Password

If you want to change the root password, all you have to do is run the following command again:

Now do the same things as you did on the Setting Root Password section of this article.

Disabling Root Login

If you don’t want to allow root login, then you can lock the root account with the following command:

To allow root login again, just set a root password again. For more information, take a look at the Setting Root Password section of this article.

Recovering Lost Root Password

If you happen to forget the root password and you don’t have sudo configured, then don’t give up just yet and think about reinstalling the operating system again. There is a way to reset the root password.

First reboot your computer. You should see the GRUB menu when your computer boots as shown in the screenshot below. Select Debian GNU/Linux and press e.

You should see the following window. Now go to the end of the line as marked in the screenshot below.

Now remove ‘ro quiet’ part from the end of the line and append ‘init=/bin/bash’ to the end of the line as marked in the screenshot below. Once you’re done, press F10.

You should see the following window.

Now run the following command to remount the root (/) partition as readable and writable:

Now run the following command to remount the /proc filesystem:

Now to reset the root password, run the following command:

Now type in your new root password and press to continue.

Now re-type your new root password and press to continue.

You root password should be changed.

Now press + + and your Debian 9 Stretch machine should reboot.

Now you can login as root with your new root password as you can see in the screenshot below.

This is how you reset your root password on Debian 9 Stretch. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

Источник

Steps to Reset your Root Password in Debian 12 bookworm Linux

Handling multiple Linux systems or once in a while, there might be chances of forgetting the root user password. If so, here is the article to reset the root password on Debian 12 Linux (bookworm) servers or desktops.

Debian is quite popular among server users as compared to Desktop. And we all know how important is for a Server OS to be stable and maintained for the long term. That is the reason why we should give a chance to Debian Linux. It is already powering thousands of hosting and other servers around the globe.

However, what happens when you are not able to log in to your Debian server because you are in a situation where either you have forgotten or misplaced the root user account password? And without having the access to superuser you won’t be able to install most of the applications that required admin privileges.

Apart from that, losing access to the root account will also limit your access to perform system-critical tasks. Even modifying systems files and configuration will be limited. Well, I can understand the pain, and that’s why here in this article we will discuss the process of resetting the root password in Debian 12 Linux. So, that you can get back full control over your server or desktop.

In the resetting root password process, the user cannot recover the old password instead will be replaced or changed by the new one without knowing the old one.

A step-by-step guide to resetting the forgotten root password of Debian 12.

1. Restart Debian 12 to have the Grub menu

To reset the root password, first of all, we restart our Debian 12 system or virtual machine we are using. Soon as the system restarted, it will show you the Grub menu for a few seconds to select the advanced option. Press any arrow key to stop the system from further processing.

2. Modify GRUB to Reset the root password

To open the Grub Menu editing screen, press the ‘e‘ key on your keyboard. This will drop you on an editor, don’t touch or delete anything, just from here move to the next step.

Access Linux Grub Menu

3. Add rw init=/bin/bash to Debian 12’s Grub

You will see a couple of lines that tell the system how to boot itself, so don’t edit anything arbitrarily. Instead, use the arrow keys and move to the end of the line starting with “Linux“. At the end of this line after ro quiet type –

To have an idea you can see the given screenshot. Once you are confirmed that the added line is exactly, what we have shown here in the screenshot. After that boot your system with these added changes by pressing F10.

Edit Grub Menu Debian 12

You might like to know what is “rw init=/bin/bash” is that we have added. It is a Linux boot option that tells the system to run the and drop us in a shell (“/bin/bash”) with read and write permissions (“rw” or read-write) to the file system. Whereas, the “init” in the command is the first process that runs when the operating system is booted, and it is responsible for starting and managing other processes.

4. Check file system permission

After following the previous step you will see yourself in the shell to execute the commands. Let’s first check whether we have read and write access to the Debian 12 file system or not. Because without that we cannot change the root password.

The output must be with rw,realtime. It reflects that we have real-time- read-and-write access to the file system.

Check file system read and write access

5. Reset the Debian 12 Root password

Finally, we will run the commands that will allow us to change the current forgotten root password of our Debian 12 Bookworm server or desktop system.

The command will ask you to type the password you want to set twice.

Debian 12 root password reset sucessfully

Well, if you want to change some other existing user account password apart from the root user then that can be done from here as well.

Simply type “passwd” command with the username. For example, if my non-root user account name is h2s, then to reset its password we will use:

7. Restart the system and login as root

Well, guys, we have successfully changed our current root Debian 12 Linux password without knowing the old one. Let’s now restart the system properly. For that execute the given command on your terminal.

Once the restart is done, you will see yourself on the Login screen of Debian 12 bookworm. Here you can use the root user and the password you have changed for it.

FAQ

We cannot read or find the root password because it is saved in an encrypted format. The only way to recover your root user access is by resetting the password manually.

Those who have a user account with sudo access can switch to the root user without entering its password. For that, you have to use the command: sudo su or sudo su —

If you already have the access to sudo or root user then to change the password of the root you can run – sudo passwd root

Other Articles:

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

Читайте также:  Настройка брандмауэра linux ubuntu
Оцените статью
Adblock
detector