linux怎么判断用户是否存在

linux判断用户是否存在的方法:1、将“read -p “please input a username:” username…”保存为test.sh;2、运行“sh test.sh”即可。

linux怎么判断用户是否存在

本文操作环境:linux5.9.8系统,Dell G3电脑。

linux怎么判断用户是否存在?

linux 判断一个用户是否存在:

#!/bin/bash  read -p "please input a username:" username  if id -u $username >/dev/null 2>&1; then         echo "user exists" else         echo "user does not exist" fi

把上面内存保存为 test.sh , 然后 sh test.sh 运行

linux怎么判断用户是否存在

推荐学习:《linux视频教程

以上就是

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享