Linux change user password from root. Resetting the root password on Linux is the first way.

It is sufficiently protected - not only from penetration from outside, but also from imprudent user actions. One of the tools for such protection is the root passphrase. A complex and reliable access key is easy to forget if you do not use a computer for some time. We suggest using a password reset; Ubuntu contains the tools you need for this.

After installation, of course, you can create another account or multiple user accounts. Either for another user, or for multiple users, or even for different purposes, which should be stored separately. It is highly recommended that you create as many accounts as there are users.

The same person can be both an administrator and a user; it does not change anything: the two accounts are separated by their name, sometimes by their password and their functions. In the root account, the administrator can do everything. . This software will be available only to the user who installed them, as they are installed in the directory of a specific user.

There are two ways to change your password.

There are a couple of ways to restore access to computer resources. In ubuntu root password by default, you can "return" through boot loader, or help livecd. Any distribution is suitable, but it is advisable to use a native one.

Splitting accounts is a guarantee of security. For this reason, it is sometimes recommended to keep records only for surfing. . After the prompt, the cursor blinks or not, but it, by at least, seen as a black or white rectangle or other color.

Full description of tips

Nothing is displayed in the window, not even asterisks. After switching to root mode, the prompt changed in the terminal window. In the last part.

Detailed invitation in single-user mode

Details of the root mode prompt. The first user password will also have the superuser password. Thus, there are no two visible accounts, but only by default.

Method number 1

This option will help a lot when you have access to download options. For those who, without using Ubuntu for a long time, have forgotten the password, you can do this.

At the time of restarting the computer in the boot list, select the desired OS and press "E". On the next screen, in the boot configuration, find the line at the beginning of which is the word “linux”. At its end, replace the combination of the letters “ro” with “rw”. After that, add to the line

On the other hand, there are two modes: superuser mode or user mode, as well as two ways to switch to superuser mode. Here is a file that can only be modified by superuser. The password will not be requested again if this action is within 15 minutes after the first password request. However, in some very rare cases, you must switch to the root console. In root mode, you can destroy entire directories. For 15 minutes, when it remains active, what could happen?

If you create a new account, it will not. There are three commands that you need to enter one after another, checking each of them. Each executed command gives a result that is displayed or not in the terminal. Warning. This is what the terminal provides. You enter the command after the prompt.

The combination that we changed will allow not only reading files, but also writing in random order. When the root password is reset, Ubuntu and the bootloader will return to their original state. Download the command line. To do this, press "Ctrl + X". Enter a new passphrase. To do this, you need the following command:

Sometimes in superuser mode there is a terminal, sometimes at the bottom of the menu or sometimes in the menu or submenu "System Tools". To move to a file, arrow keys, start and end key to move in a line. When installing any software It is important to consider this separation between user and root modes.

This directory is hidden by default, but can be displayed by you if necessary. Then your profile is created and you can browse the web. Since this file is used by many utilities, to display file permissions, etc. To associate a user ID with his name, the file must be accessible to everyone. It still poses a security risk. To change one format to another, enter. Usually the group number will be the same as the user number. Full name user. User’s personal directory.

  • Username, up to 8 characters.
  • The number of group identifiers.
  • Case sensitive, usually only small letters.
All commands requiring administrator privileges can be executed through.

In Ubuntu, the default password has not changed and an error has occurred - this means that the necessary directories are still not writable. Type the following:

[email protected](none): / # mount -n -o remount, rw /

After that, repeat the passwd command. You should observe a message stating that the data has been successfully changed.


To maintain a permanent root connection, you can enter. Then we have a clue with the disease, and we hold the hand like a root. In this system, we always have only one password: user. Check the connection with administrator rights with the new password.

When surfing the Internet, you probably heard about starting in "rescue or recovery mode" or "boot into single-user mode", which allows you to get the root command line. Rescue mode launch method. You get the root command line.

Method Starting with single-user mode. Depending on your distribution, you can choose "Single-user mode." Select "Single User Mode". You will get the root command line. Enter your current password at the invitation. The administrator password is immediately replaced by the one that is passed as an argument to the command.

Restart your PC:

[email protected](none): / # / sbin / reboot -f

All! We were able to change the Ubuntu password. Now you can log in again.

Method number 2

In this case, again, you have to deal with the OS selection options. Find the recovery mode item in the start menu. Resetting the Ubuntu passphrase we will start from here. Perhaps you have one OS? To start GRUB, hold down “Shift” at startup. Or press the Reset button at boot, and the next time GRUB appears during startup.

Password recovery in recovery mode

If you do not want to go through interactive mode, you can specify the old password directly in command line. You can also use this method to change the user password. The following guide explains how to get this data. From the root terminal, you can follow the instructions appropriate to your case in the following paragraphs.

If you do not remember only the password

If you do not remember your username and password

A list of home folders on the system whose names are nothing more than user names will be displayed. You cannot obtain access data in any way. It is important not only to choose a strong and secure password, but also a simple password to remember.

Go into recovery mode, so in Ubuntu resetting the root password is easier. You should watch the console with root rights. Translate file system to record mode, similar to the first method. Here you can use another command:


If your home directory is encrypted, you cannot reset forgotten password. Press the down arrow to highlight the line that ends with “recovery mode” and press “Enter”. The computer will start the startup phase to send immediately after the recovery menu. When you have access, you can no longer access your keychain.

Everything inside the newly mounted device, make sure that the correct one is by clicking on the house and then on your username. Change to the root directory of the drive, and then to the directory, etc. find the “shadow” file and do backup: edit the original “shadow” file with a text editor. Do not enter anything for the current password, as the current password is empty. Find the username for which the password has been forgotten. . As explained in recent days, it is recommended that you periodically change the password to ensure maximum security for the system.

For Ubuntu to change the root password, just type:

passwd username

Here "username" is the name of your account.

Run the command to restart the computer:

In conclusion

You have learned through examples how to change a user's password in Ubuntu. This difficult task, at first glance, turned out to be easier than you thought, right? If you have additional questions about Ubuntu software, we recommend that you familiarize yourself with other materials on our website. Join the discussion of current programs and hardware on our site!

For example, it needs to be changed once a month, and we will need to make sure that we correctly match upper and lower case characters, special characters and special characters in punctuation, characters and tildes. “Weak” passwords that are easy to crack are usually just letters or numbers alone, and they are easy to guess because they consist of very common words or obvious numbers.

In the order in which we will be asked, we will insert the previous password, a new one, and then the one that we change. If something goes wrong, or if the password is too simple, the system will warn us that "the new password is too simple." It has the following features.

Operating room linux system Originally designed as a multi-user and secure system. Therefore, here each user has a password. The user credentials and the authentication method are laid at the system level.

Sometimes it becomes necessary to change the password in linux. Firstly, this can happen if you forget the password or just want to change it. Another reason is security. Passwords need to be changed at least several times a year, and if you are a system administrator of a company, it is important to force your users to change passwords from time to time, and Linux also has tools for this. In this article we will look at how to change the password in Linux.

A forgotten password is, of course, an unpleasant thing, but, fortunately, is quite easily resolvable. If you completely forgot your password, there is no way to return it, but there is a relatively simple way to change it. Only one of these lines that seem “redundant” here will help you now. Select the line that says “Recovery Mode”.

This option is used to restore a damaged system, and also allows you to simply change the password. After the download is complete, you will receive an offer to repair the system. As a user, of course, enter the name of the user whose password you want to change. Just enter your new password twice and you're done. Keep in mind that you work in a text environment, and wildcards do not appear when filling out a password, so it may seem that the system does not accept the password. After changing the password, simply return to the previously displayed menu and select the first renewal option.

There are several utilities in Linux that can be used to change the linux password. In this article, we will only consider methods using the terminal, with graphical methods, I think you can easily figure it out, besides they do not give us the flexibility we need.

The list of users in Linux is stored in the file / etc / passwd, you can easily open it and see their passwords are highlighted in a separate file - / etc / shadow. This file can be opened only with superuser rights, and moreover, the passwords here are stored in encrypted form, so find out linux password it doesn’t work out, but changing them manually will be difficult.

Resume normal boot, which launches the classic login window. Since the firewall is disabled in its default configuration, you must first enable it by selecting “Enable Firewall”, as you can see in the picture. Now you can go to the firewall settings. By default, the firewall is configured to ignore all unsolicited incoming connections - this rule is recommended and sufficient for most systems. If you want to establish additional special rules, you can do this using the Add New Rule dialog box.

In most cases, the password is changed using the passwd utility. This is a very powerful utility, it allows you not only to change the password, but also to manage its lifespan. It has the following syntax:

user options

Consider the options to better navigate the use of the utility:

  • -d - delete user password, after that he will not be able to log in
  • -e - make the password obsolete
  • -i - how many days after the password has expired disable the account if the user has not changed the password
  • -l - prohibit the user from logging in
  • -n - minimum number of days between password changes
  • -S - display account information
  • -u - cancels the effect of the -l parameter
  • -x - the maximum number of days until the password can be used.
  • -w - the number of days after which it is necessary to warn the user that the password must be changed.

Perhaps now everything looks very incomprehensible, but with examples it will become easier. We will consider why and in what cases it is necessary to use all these options to change the password in Linux. Let's move on to practice.

Most likely, however, you will not need other custom rules. It may have occurred to you that in order for the firewall to work "well," you will need to start it every time you start the system. This means that you only need to run once, configure everything and not worry about it.

Most users should access the system immediately after clicking on the computer. Although developers are trying to cut back, and starting up the system a little faster than the previous one, there are several ways to get the system a little more. Directly in basic installation you have a simple tool that will allow you to disable some redundant services. You can read about what to disable. Now we will look at individual services that can be disabled. For both of the previous tools, services are called in two ways - an explanatory description and the one-word name used by the system.

How to change user password

You can change your password whenever you want. To do this, you do not need special superuser rights, only know your current password. Just open a terminal and run the password utility without parameters:


Then you need to enter a new password and you're done, now your password has been changed. It is encrypted using irreversible encryption and stored in the / etc / shadow file. But note that you cannot use any password here. The Linux system ensures that users select fairly complex passwords. If the password is very short or contains only numbers, you cannot set it.

Since the descriptive name is long and, in addition, different for both tools, we will use the single-word name here. Turning them off can result in very serious system damage. Most services are very well described, and there is no problem evaluating their function, so they can decide what they need for “common sense.” But always, if you have only doubt, let everything be as it is.

On some servers, a firewall is required, while others are not needed. In addition, if the computer does not have an external address, then this does not make sense, for example, when you turn on your own firewall to check its functionality using some freely available web tools from the Internet, in which case the provider’s firewall will be tested, not my own.

General requirements for the password are as follows: must contain from 6 to 8 characters, with one or more of them must belong to at least two of the following sets:

  • Lower case letters
  • Uppercase letters
  • Numbers from zero to nine
  • Punctuation and _

Now consider how to change the Linux password for another user.

How to change the password of another user

Everything is clear with your password, but if you want to change the password for another user, then everything is not so simple. To do this, you need superuser privileges. And everything else is the same:

Here user is the user who needs to change the Linux password. The password requirements are the same; you cannot set a password that is too simple.

You can remove the Linux password for the user, then he will not be able to log in:

sudo passwd -d user

How to change a group password

You probably saw the file / etc / gshadow on your system. This file is equivalent to / etc / shadow, only contain passwords for groups. You cannot log in on behalf of a group, but knowing its password, you can access the functions it provides in a separate command shell using the newgrp command.

To set a password for the group, a utility is used that is very similar to passwd - gpasswd. Naturally, we need superuser rights. For instance:

sudo gpasswd disk


Now let's try to get group permissions:


After entering the password, we temporarily end up in this group and can work with those files to which this group is allowed access. To remove the linux password from the group, use the -r option:

sudo gpasswd -r disk

How to force the user to change the password

Server security is one of the most important things. Often the cause of security problems is users themselves who do not change passwords often or make them too simple. If you are an administrator, you have the opportunity to get users to change their password from time to time, and also automatically send them warnings that it’s time to change the password linux user.

All this allows the passwd utility. First, let's look at how to view password information in passwd. To do this, use the -S option:


  • The first field is the username
  • The second field shows one of the values: P - password is set, L - the user is blocked, NP - no password.
  • 07/21/2016 - date of the last password change.
  • 0 - minimum time before password change
  • 99999 - maximum password duration
  • 7 - for how many days you need to warn about the expiration of the password
  • -1 - after how many days the password needs to be deactivated.

For example, thirty days after the change, the user's password will become obsolete:

sudo passwd -x 30 test


Three days before the password becomes obsolete, we warn the user that the password must be changed:

sudo passwd -w 3 test

If he does not do this within five days, the account must be disabled:

sudo passwd -i 3 test

The password can be changed no more than once every 10 days:

sudo passwd -n 10 test

We look now at what happened:

sudo passwd -S test


All is correct.

How to change root password

Changing the Linux password for root is very simple, just like for any other user. Only need to have superuser privileges. This is how it will look:


Everything is working. Also in this way you can set the root password in Ubuntu.

How to manually change the password

The Linux operating system would not be Linux if we were not able to configure the password manually without any utilities. As I said before, passwords are stored in the / etc / shadow file. And they are stored there in encrypted form. It is not possible to decrypt the password.

When the system saves the password, it performs encryption according to a certain algorithm and saves the encrypted result, and when the user needs to log into the system, it simply takes its password, again encrypts and verifies that it is stored in / etc / shadow. If it matches, the user is authorized.

Even in this way, changing the linux user password is not so difficult. And so, first we need to get the encrypted password. This can be done in several ways, for example using openssl:

openssl passwd -1 -salt xyz yourpass

Replace xyz for any random combination of characters, the more the better. yourpassThis is your new password.

Copy the result to the clipboard, then open the / etc / shadow file and find the user there. I want to change linux password for test:

sudo vi / etc / shadow


The syntax for this file is:

username:password: ::::

The next field indicates the last password change in the form of the number of days that have passed since January 1, 1970. The rest of the fields do not interest us, and you can figure it out just by comparing the data.

Now replace the password with the one received above and saved to the clipboard. Save the file and you can try to log in with a new password:


Everything is working. As I said, there are several more encryption algorithms with which you can get a password, here they are:

makepasswd --clearfrom \u003d - --crypt-md5<<< YourPass
$ mkpasswd -m sha-512 -S salt -s<<< YourPass
$ perl -e "print crypt (" YourPass "," salt ")," \\ n ""
$ openssl passwd -crypt -salt XRYourPass

In all of these examples, salt is a random string to increase encryption strength, and YourPass is your password. What to do with the received data you already know.

findings

In this article, you learned how to change the linux password. I considered all possible ways and not even very standard ones. If you still have questions, write comments!