top of page
Shell Script User Login with Password
We can create a bash script to authenticate users with login and password. Here we will demonstrate this using the read command to accept the user input and the if-else command to authenticate.
vi user_login.sh
# !/bin/bash
#Type your login details
read -p 'Username: ' user
read -sp 'Password: ' pass
if (( $user == "admin" && $pass == "admin123" ))
then
echo -e "\nWelcome! You are Sucessfull login\n"
else
echo -e "\nUnsuccessful login\n"
fi
Here is the sample of the output of the above script.
![shell script user login with password](https://static.wixstatic.com/media/15aea5_ef2de5fbfff14676809f2b9b249bc629~mv2.png/v1/fill/w_66,h_16,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/15aea5_ef2de5fbfff14676809f2b9b249bc629~mv2.png)
More ways to use the user login with password
You can create more than 1 user and check for their login
You can display the user name in the welcome message "Welcome " + username
Related Posts
![](https://static.wixstatic.com/media/baac51_121a663408ad477dacbfbd49d274712e~mv2.jpg/v1/fill/w_147,h_98,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/baac51_121a663408ad477dacbfbd49d274712e~mv2.jpg)
Heading 2
Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.
bottom of page