Home >Operation and Maintenance >Linux Operation and Maintenance >How to determine whether a user exists in Linux
Linux method to determine whether a user exists: 1. Save "read -p "please input a username:" username..." as test.sh; 2. Run "sh test.sh" .
The operating environment of this article: linux5.9.8 system, Dell G3 computer.
How to determine whether a user exists in Linux?
linux Determine whether a user exists:
#!/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
Save the above memory as test.sh, and then run sh test.sh
Recommended learning: "linux video tutorial"
The above is the detailed content of How to determine whether a user exists in Linux. For more information, please follow other related articles on the PHP Chinese website!