linux判断用户是否存在的方法:1、将“read -p please input a username: username...”保存为test.sh;2、运行“sh test.sh”即可。 本文操作环境:linux5.9.8系统,Dell G3电脑。 linux怎么判断用户是否存
linux判断用户是否存在的方法:1、将“read -p "please input a username:" username...”保存为test.sh;2、运行“sh test.sh”即可。

本文操作环境: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怎么判断用户是否存在的详细内容,更多请关注自由互联其它相关文章!
