[英]How to change username via Shell Script
I'm doing a script to change the name of a user just using variables so the user doesn't see the actual command.我正在编写一个脚本来仅使用变量来更改用户的名称,这样用户就看不到实际的命令。 I have done other things like change the folder of the user but for some reason tryng the same method with this isn't working, I hope you understand my mistakes and give me a hand.
我已经做了其他事情,比如更改用户的文件夹,但由于某种原因,尝试相同的方法不起作用,我希望你能理解我的错误并帮助我。
echo "Give me the old username"
read name
echo "Give me the new username"
read new
echo "$new" | usermod -l --stdin "$name"
For some reason stdin isn't working:C I'm getting the next output "usermod: invalid user name '--stdin'".出于某种原因,stdin 无法正常工作:C 我得到了下一个 output“usermod:无效的用户名 '--stdin'”。
Note: I have used stdin to get the new names before and it worked perfectly just this way so I don't know what's wrong.注意:我以前使用标准输入来获取新名称,并且它以这种方式完美运行,所以我不知道出了什么问题。
I don't know any usermod
that knows --stdin
... try this:我不知道任何知道
--stdin
的usermod
...试试这个:
echo "Give me the old username"
read name
echo "Give me the new username"
read new
usermod -l "$new" "$name"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.