Linux Set or Change User Password

原文转载至:http://www.cyberciti.biz/faq/linux-set-change-password-how-to/

How do I set or change Linux system password for any user account?

Both Linux and UNIX use the passwd command to change user password. The passwd is used to update a user’s authentication token (password) stored in shadow file.

The passwd changes passwords for user and group accounts. A normal user may only change the password for his/her own account, the super user (or root) may change the password for any account. The administrator of a group may change the password for the group. passwd also changes account information, such as the full name of the user, user's login shell, or password expiry date and interval.

Task: Set or Change User Password

Type passwd command as follows to change your own password:
$ passwd
Output:

Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

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 6 to 8 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

Task: Change Password For Other User Account

You must login as root user, type the following command to change password for user vivek:
# passwd vivek
Output:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Where,

  • vivek - is username or account name.

以下命令中 -g 在centos 5.5 i386中无法使用

Task: 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值