- How To Linux Set or Change User Password
- Linux Set User Password
- Linux change password for other user account
- Linux Change Group Password
- Changing user passwords on Linux
- Forcing Linux user to change password at their next login
- Locking and Unlocking user password of the named account
- A note about setting up a secure Linux password
- Conclusion
- Как изменить пароль пользователя в Linux. Команда Passwd
- How to Change User Password in Linux
- В этом руководстве мы объясним, как изменить пароль пользователя в Linux. Мы также покажем вам, как заставить пользователей изменить свой пароль при следующем входе в систему.
- Изменить свой пароль пользователя
- Изменить пароль другого пользователя
- Принудительно изменить пароль при следующем входе в систему
- Вывод
- How to Change a Password in Linux
- How to Change a Password in Linux?
- How to Change a Password in Linux for Another User?
- Passwords and Linux
- How to Create a Strong Password
- Conclusion
- How to Change Your User Password In Linux
- Linux set password instructions
- How to Change Your Linux Password
- Linux: Reset User Password
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:
- Lower case alphabetics
- Upper case alphabetics
- Digits 0 thru 9
- 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.
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:
- First sign on or “su” or “sudo” to the “root” account on Linux, run: sudo -i
- Then type, passwd tom to change a password for tom user
- 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
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:
- Words which appears in a dictionary
- Your first and last name
- Pet names
- Kids or spouses names
- License number
- Date of birth (DoB)
- 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
Источник
Как изменить пароль пользователя в 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 Password in Linux
Passwords are the first line of defense when securing any system, including Linux. Passwordless SSH is a reliable alternative, but at the end of the day, a strong password is one of the best options. Having a strong password makes your system much more reliable. In this tutorial, you’ll learn how to change a password on any Linux distribution, including Ubuntu, Debian, and CentOs.
We will also teach you how to change it for other users on your VPS. That is ideal if you are trying to learn the skill set of a sysadmin.
How to Change a Password in Linux?
To change the password you only need to know one command. First, access your VPS through SSH. Having trouble? Check out our PuTTY tutorial. Then, to change the password in Linux you need to open the terminal and type the following command:
After executing the command, you will be asked to enter the new password twice. In this case, when we’re not specifying a user, we’ll be changing the root password. The output should look like this:
If you change your password successfully, the command line will output something like this:
This means your new password is set and your old password is long gone.
How to Change a Password in Linux for Another User?
It is also possible to change the current password of another user in the same system. To do this, you will need to use the passwd command once again.
First, log in as the root user, type passwd followed by the user’s name whose password you want to change. The command would look like this in the command line:
In this case, if you want to change the password of the user named edward. The command line would look like this:
Next, we will be prompted by the same request to enter the new password twice.
And just like that, you have updated a different user old password, to a new password, by using the passwd command.
Passwords and Linux
Linux is considered one of the safest systems in the world because of the way processes are handled. However, every operating system depends on the security of their passwords, at some point. Linux manages these passwords in a very similar way to other systems. However, it is necessary to know two important directories in password management.
The first of these files is /etc/passwd where we can find all users’ on the system. In addition, it shows which group of the system the passwords belong to. It is possible that you will see many users, but only a few will be able to log in as they are system users.
If you want to see the content of /etc/passwd, you can do it with the following command:
The second Linux file that is strongly related to passwords is /etc/shadow. In the shadow file, you will be able to see the encrypted passwords of users and if they have an SSH key and other related information.
How to Create a Strong Password
Finally, it is recommended that we establish strong passwords so that no one can hack them. It is suggested that you choose a password that is unique, long, and avoids using personal information.
To create or change to a unique password, use a different password for each of your important accounts, such as online banking and email accounts. Try not to reuse your past passwords.
To create or change a longer and more memorable password, try your favorite line from a song, book, or movie. You can also take longer lines and just use the first letter of each word.
Remember not to use personal information in your password as well. Avoid nicknames, initials, pet names or old street addresses.
If you suspect that one of your passwords has been compromised, change it as soon as possible. It is also advised to do this frequently.
Conclusion
Changing a password in Linux is important for the security of your project. The process is very simple, and we recommend doing it frequently for maximum security. Stay safe out there!
Edward is an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward’s goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.
Источник
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).
Источник