3

linux~添加组_添加用户_为用户加密码

 2 years ago
source link: https://www.cnblogs.com/lori/p/15881789.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

echo传递命令参数

总结一个linux小技巧,主要是设置用户密码,通过echo输出密码到命令passwd,并使用输入参数--stdin将用户名传入,命令如下:

# 添加mysql组
groupadd mysql
# 添加用户test到mysql组
useradd test -g mysql
# 为test用户设置密码123456
echo "123456" | passwd --stdin test

cat命令追加文件内容(cat >>)

$ cat >> /etc/hosts << EOF
192.168.1.156 node1
192.168.1.167 node2
192.168.1.168 node3
EOF

cat命令覆盖文件内容(catr >)

$ cat > /etc/hosts << EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.156 node1
192.168.1.167 node2
192.168.1.168 node3
EOF

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK