You can use read command with -s option, which causes input coming from a terminal to not be echoed. This is useful to verify password or something else.
One line is read from the keyboard or from file descriptor FD if the -u option is supplied, and the first word is assigned to the first NAME, the second word to the second NAME, and so on, with leftover words assigned to the last NAME. Only the characters found in $IFS are recognized as word delimiters. If no NAMEs are supplied, the line read is stored in the REPLY variable. If the -r option is given, this signifies `raw' input, and backslash escaping is disabled. The -d option causes read to continue until the first character of DELIM is read, rather than newline. If the -p
option is supplied, the string PROMPT is output without a trailing newline before attempting to read. If -a is supplied, the words read are assigned to sequential indices of ARRAY, starting at zero. If -e is supplied and the shell is interactive, readline is used to obtain the line. If -n is
supplied with a non-zero NCHARS argument, read returns after NCHARS characters have been read. The -s option causes input coming from a terminal to not be echoed.
Following script, demonstrate this concept:
1) Download/view the passwordscript.bash script
2) Save the changes and execute script:
$ chmod +x passwordscript.bash
$ ./passwordscript.bash
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 3 comments… read them below or add one }
Is it possible to put the passwordscript.bash online again?
Hello,
Link is fixed. Sorry for any inconvenience!
http://bash.cyberciti.biz/script/passwordscript.bash.php
Regards,
Vivek
echo “Enter user name”
read a
grep $a /etc/passwd > aa.txt
if [ -s aa.txt ]
then
echo “Authentic User”
who>bb
grep $a bb >cc.txt
if [ -s cc.txt ]
then
echo ” The user is logged in”
echo “Time of login :”
who | cut -d “-” -f3 | cut -d ” ” -f2
fi
else
echo “The user is not logged in”
fi