Linux how to change user password

Как изменить пароль пользователя в Linux. Команда Passwd

How to Change User Password in Linux

В этом руководстве мы объясним, как изменить пароль пользователя в Linux. Мы также покажем вам, как заставить пользователей изменить свой пароль при следующем входе в систему.

Инструкции должны работать на любом дистрибутиве Linux, включая Ubuntu, Debian и CentOS.

В Linux вы можете изменить пароль учетной записи пользователя с помощью passwd утилиты.

Зашифрованные пароли пользователей, а также другая информация, связанная с паролями, хранятся в /etc/shadow файле.

Как обычный пользователь, вы можете изменить только свой собственный пароль. Пользователь root и пользователи с привилегиями sudo могут изменять пароли других пользователей и определять, как можно использовать или изменять пароль.

При смене пароля убедитесь, что вы используете надежный и уникальный пароль.

Надежный пароль — это самое важное, что вы можете сделать для защиты своей учетной записи. Часто надежный пароль содержит не менее 16 символов и содержит как минимум одну заглавную букву, одну строчную букву, одну цифру и один специальный символ.

В целях безопасности рекомендуется регулярно обновлять пароль и использовать уникальный пароль для каждой учетной записи.

Изменить свой пароль пользователя

Чтобы изменить пароль своей учетной записи, введите passwd команду без аргументов:

Вам будет предложено ввести текущий пароль. Если пароль правильный, команда попросит вас ввести и подтвердить новый пароль.

Пароли не отображаются на экране при их вводе.

При следующем входе в систему используйте новый пароль.

Изменить пароль другого пользователя

Как мы упоминали во введении, только пользователь root и пользователи, имеющие sudo доступ, могут изменять пароль другой учетной записи.

В следующем примере предполагается, что вы вошли в систему как пользователь с привилегиями sudo.

Чтобы изменить пароль другой учетной записи пользователя, введите passwd команду, а затем имя пользователя. Например, чтобы изменить пароль пользователя с именем baks , выполните следующую команду:

Вам будет предложено ввести и подтвердить новый пароль:

В случае успеха команда напечатает что-то вроде этого:

Принудительно изменить пароль при следующем входе в систему

По умолчанию пароли никогда не истекают. Чтобы заставить пользователя изменить свой пароль при следующем входе в систему, используйте passwd команду с —expire параметром, за которой следует имя пользователя:

Приведенная выше команда немедленно истечет пароль пользователя.

В следующий раз, когда пользователь попытается войти со старым паролем, ему будет показано сообщение, заставляющее его сменить пароль:

Как только пользователь установит новый пароль, соединение будет закрыто.

Вывод

В этом уроке вы узнали, как изменить пароли пользователя и как установить срок действия пароля.

Вы можете найти больше информации о команде passwd, набрав man passwd в своем терминале или посетив страницу руководства Linux passwd .

Источник

How to Change a User’s Password in Linux

  • It includes both upper and lower case letters
  • It includes digits from 0 to 9
  • It has special characters and punctuation marks
  • It is a lot different than your previous passwords
  • It does not include information such as your full name, address, phone number, birth date, or license numbers. This information can easily be used to guess your password.
Читайте также:  Тест для производительности компьютера windows

Always note down your password in a secure location from where it can not be fetched. It would help you in remembering the password in case you forgot it.

In this article, we will tell you how you can manage user passwords in Linux through the command line and GUI. We have run the commands and processes mentioned in this article on a Debian 10 Buster system but you can replicate them on most Linux distros.

Changing Password Through the UI

If you are a Linux user who prefers the graphical user interface to perform most administrative operations, you can use the Settings utility on your system.

There are two ways in which you can access the system Settings.

  • Access the Application Launcher through the Super/Windows key and then enter the keywords ‘settings’ in the search bar as follows:
  • Click the downward arrow in the top panel of the Debian/Ubuntu desktop and then click on the ‘settings’ icon from the following drop-down menu:

In the Settings utility, select the Details tab from the left panel and then select the Users tab on it to open the Users settings view. This is how the Users view looks like:

All the users on your system will be listed here. Click on the user whose details you want to change. You need to first unlock the Users view so that you can make changes to its settings. Please remember that only an authorized user/administrator can unlock the view. Click the Unlock button and enter your credentials as follows:

As you click the Authenticate button, the fields on the Users view will become active and you can make changes to them.

Click on the Password field and the following Change Password view will open. Enter the New Password, and then enter the same password again in the Confirm New Password field. You will now be able to see the Change button active.

Click on the Change button and the password for the selected user will be changed.

Tip: One easy and quick way to access the Users settings is to enter the keyword ‘Users’ in the Application Launcher as follows:

Changing Password Through the Command Line

The Linux command line gives an administrator much more power than the UI, to make user and system settings. In order to launch the default command line application on Linux Debian and Ubuntu, open the Application Launcher and enter the ‘Terminal’ keywords as follows:

As the Terminal opens, you can do the following with user passwords:

  • Change your own password
  • Change password for another user
  • Change the password for sudo

Changing Your Own Password

A non-administrator on Linux can only change their own password. The passwd command is used to change user passwords in Linux. This is how a user can use this command to change their own password:

As you enter the passwd command, the system prompts you to enter your current password. As you do so, this password is checked against the stored password. If it matches, you are proceeded to the next step i.e, to enter the new password. After you enter the new password, the system then asks again to type the new password for confirmation. After the two entries match, your password will be successfully changed.

Changing Password for Another User

On Linux, only an administrator/superuser can change the password for another user. This is the command a superuser will be using:

Читайте также:  Windows не видит половину жесткого диска

As a user enters this command, they will be asked the password for sudo to ensure that they are indeed a super user. A super user is not required to enter the old password for a user as they might be using the command to reset a forgotten password. Anyways, the super user is also required to enter and re-enter the new password, after which, it is updated successfully.

Changing the Password for sudo

It is a good security practice to change a super user’s password on Linux from time to time. Here are two ways through which you can change a sudo password:

Method 1:

The first way is to log in as root through the following command:

When you are logged in as root after entering a valid password, use the passwd command to change the password for root.

You can then exit the root prompt through the exit command as follows:

Method 2:

The second method is to use the following command as sudo:

Enter the password for sudo and then you can change the password of root, like you do for any other user.

This was all you needed to know about changing user passwords in Linux, both through the UI and the command line. You can now maintain a much secure user account on your system.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Источник

How to Change Your User Password In Linux

Linux set password instructions

With the Linux operating system, it’s easy to change your user password. The easiest way to change your password is from a shell prompt. The steps below show you how to change your Linux user password and reset your Linux password.

How to Change Your Linux Password

How you change your password from the command line is accomplished with the passwd command. Don’t let the idea of the command line scare you away, as it’s incredibly simple. Here’s how to use this command:

Open a terminal window.

Issue the command passwd.

When prompted, type your current user password.

Type the new password.

Verify the password by typing it a second time.

Close the terminal window.

The password change takes effect immediately.

Linux: Reset User Password

To change someone else’s password, use the sudo command.

Open a terminal window.

Issue the command sudo passwd USERNAME (where USERNAME is the name of the user whose password you want to change).

Источник

How To Linux Set or Change User Password

Linux Set User Password

Type following passwd command to change your own password:
$ passwd
Sample Outputs:

The user is first prompted for his/her old password if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed. A new password is tested for complexity. As a general guideline, passwords should consist of 10 to 20 characters including one or more from each of following sets:

  1. Lower case alphabetics
  2. Upper case alphabetics
  3. Digits 0 thru 9
  4. Punctuation marks/spacial characters

Linux change password for other user account

You need to login as the root user, type the following command to change password for user vivek:
# passwd vivek
OR
$ sudo passwd vivek
Sample putput:

  • vivek – is username or account name.

Passwords do not display to the screen when you enter them. For example:

Linux changing user password using passwd

Linux Change Group Password

When the -g option is used, the password for the named group is changed. In this example, change password for group sales:
# passwd -g sales
The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

Читайте также:  Что за приложение windows rar

Changing user passwords on Linux

As a Linux system administrator (sysadmin) you can change password for any users on your server. To change a password on behalf of a user:

  1. First sign on or “su” or “sudo” to the “root” account on Linux, run: sudo -i
  2. Then type, passwd tom to change a password for tom user
  3. The system will prompt you to enter a password twice

To change or set a new root (superuser) password type:
$ sudo passwd

Forcing Linux user to change password at their next login

By default, Linux passwords never expire for users. However, we can force users to change their password the next time they log in via GUI or CLI methods. The syntax is straightforward:
$ sudo passwd -e
$ sudo passwd —expire
Let us immediately expire an account’s password:
$ sudo passwd -e marlena
The system will confirm it:

When user try to login via ssh command, they will see the following on screen:

Locking and Unlocking user password of the named account

Note that the following local command does not disable the account. The user may still be able to login using another authentication token, such as an SSH key. To disable the account, administrators should use either usermod —expiredate 1 or sudo passwd —expire command. Also, users with a locked password are not allowed to change their password to get around the security policy set by sysadmin.

We can lock the password as follows:
$ sudo passwd -l
This option disables a password by changing it to a value which matches no possible encrypted value (it adds a ! at the beginning of the password in the /etc/shadow file. Want to unlock the password, try:
$ sudo passwd -u
The above command option re-enables a password by changing the password back to its previous value. In other words, to the value before using the -l option.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

A note about setting up a secure Linux password

Compromises in password security typically result from careless password selection. Avoid common password such as:

  1. Words which appears in a dictionary
  2. Your first and last name
  3. Pet names
  4. Kids or spouses names
  5. License number
  6. Date of birth (DoB)
  7. Home or office address

I strongly recommend that you generate a unique password for all user accounts using your chosen password manager.

Conclusion

The passwd command line utility is used to update or change user’s password. The encrypted password is stored in /etc/shadow file and account information is in /etc/passwd file. To see all user account try grep command or cat command as follows:
$ cat /etc/passwd
$ grep ‘^userNameHere’ /etc/passwd
$ grep ‘^tom’ /etc/passwd
The guidance given in this quick tutorial should work with any Linux distribution, including Alpine, Arch, Ubuntu, Debian, RHEL, Fedora, Oracle CentOS, SUSE/OpenSUSE and other popular Linux distros.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Оцените статью