[转帖]echo “新密码”|passwd --stdin 用户名

echo,新密码,passwd,stdin,用户名 · 浏览次数 : 0

小编点评

**命令说明:** 该命令使用 `stdin`选项从标准输入中读取新密码,并将其设置为指定用户的密码。 **示例:** ``` echo “新密码”|passwd --stdin rusky ``` **步骤:** 1. **创建密码变更文件:** `touch rusky.passwd` 2. **设置用户密码:** - `echo “新密码”|passwd --stdin rusky` 设置 `rusky` 用户的密码为 `新密码`。 - `echo "qwert"qwert"` 设置 `rusky` 用户的密码为 `qwertqwert`。 3. **验证密码更改:** - `passwd --stdin rusky` 验证 `rusky` 用户的密码是否正确。 **注意:** - 使用 `stdin` 选项时,密码将从标准输入中读取,因此需要确保标准输入正常打开。 - 此方法虽然简单易用,但它可能不安全,因为通过 `history` 命令可以查到用户的密码。 - 建议使用更安全的密码设置方法,例如 `ssh-keygen` 或 `fishpass` 等工具。

正文

https://www.cnblogs.com/rusking/p/6912809.html

 

--stdin  

This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.  

这个选项用于从标准输入管道读入新的密码。 

使用 echo 方式来重置Linux 系统用户密码:

echo “新密码”|passwd --stdin 用户名

1
2
3
4
5
6
7
8
9
10
[root@rhel7 ~]# passwd --stdin rusky   为rusky用户设置密码。
Changing password for user rusky.
zxcvbnm
passwd: all authentication tokens updated successfully.
[root@rhel7 ~]# echo "qwert"
qwert
[root@rhel7 ~]# echo "qwert" | passwd --stdin rusky  把echo返回的字符qwert设置为用户rusky的密码
Changing password for user rusky.
passwd: all authentication tokens updated successfully.
[root@rhel7 ~]#

这种方式虽然简单,但是通过history命令可以查到用户的密码,所以不安全。

*******VICTORY LOVES PREPARATION*******

与[转帖]echo “新密码”|passwd --stdin 用户名相似的内容:

[转帖]echo “新密码”|passwd --stdin 用户名

https://www.cnblogs.com/rusking/p/6912809.html --stdin This option is used to indicate that passwd should read the new password from standard input, w

[转帖]echo 输出不换行-e \c

http://www.my889.com/i/1952 在shell中,echo输出会自动换行。有时候在循环中不希望echo输出换行。代码实现如下: 1 echo -e " \c" # -e 表示开启转义, \c表示不换行 脚本: 1 2 3 4 5 6 7 8 9 #!/bin/bash i=1

[转帖]Linux基础命令---echo打印内容到标准输出

https://www.cnblogs.com/wj78080458/p/11027763.html echo echo指令可以输出内容到标准输出,以空白分割字符串,并且后面增加换行。 此命令的适用范围:RedHat、RHEL、Ubuntu、CentOS、Fedora。 1、语法 echo [-ne

[转帖]连shell的基本输出都不会,还写什么脚本?echo和printf命令总结

https://zhuanlan.zhihu.com/p/438957797 在 Linux 系统中使用 echo 命令和 printf 命令都可以实现信息的输出功能,下面我们分别看这两个命令的应用案例。 echo 1.使用 echo 命令创建一个脚本文件菜单功能描述:echo 命令主要用来显示字符

[转帖]Shell~echo -e 颜色输出

https://www.cnblogs.com/ElegantSmile/p/11144879.html echo -e 可以控制字体颜色和背景颜色输出 从一个例子开始: # echo -e "\e[1;33;41m test content \e[0m" 输出效果: 1. \e 转义起始符,定义一

[转帖]超详细的I/O多路复用概念、常用I/O模型、系统调用等介绍

概述 当我们要编写一个echo服务器程序的时候,需要对用户从标准输入键入的交互命令做出响应。在这种情况下,服务器必须响应两个相互独立的I/O事件:1)网络客户端发起网络连接请求,2)用户在键盘上键入命令行。我们先等待哪个事件呢?没有哪个选择是理想的。如果在acceptor中等待一个连接请求,我们就不

[转帖]【Windows】将bat文件注册为windows服务

1、编写服务的bat文件 @echo off C: cd C:\TeldAPP\Monitor\windows_exporter C:\TeldAPP\Monitor\windows_exporter\windows_exporter-0.16.0-386.exe --config.file=C:\

[转帖]用bat更改hosts文件批处理

原文地址: https://www.jb51.net/article/51902.htm copy@echo off echo "请注意你的杀毒软件提示,一定要允许" @echo ######################################## @xcopy C:\Windows\s

[转帖]Linux shell 按行循环读入文件常用代码如下:

Linux shell 按行循环读入文件常用代码如下: #/bin/bash printf "*************************************\n" echo " cat file whiel read line" cat test.txt |while read line

[转帖]分享一个Navicat16最新版永久试用的办法

https://zhuanlan.zhihu.com/p/614621302 新建bat,就叫 navicat无限试用.bat @echo off echo Delete HKEY_CURRENT_USER\Software\PremiumSoft\NavicatPremium\Registrati