Bash script to check if a specific user is present in etc passwd

preview_player
Показать описание
In this video we will learn how to write Bash script to check if a specific user is present in /etc/passwd. Please subscribe to support Asim Code!
Рекомендации по теме
Комментарии
Автор

Please subscribe to support Asim Code!

AsimCode
Автор

Thank you. I had tried two or three other ways to do this that I saw online, but none of them were working. This worked perfectly.

Renkinjutsushi
Автор

its not working if you change 'root ' to 'oot ', it saying 'oot' is found because 'oot' present in 'root'

me_debankan
Автор

id -u "${USER_NAME}"
if [[ "${?}" != 0 ]]
then
echo " Username ${USER_NAME} does not exist " >&2
exit 1
fi
it should be useful i think
btw, how the condition is working in your video?, is it checking for root in the begining of /etc/passwd or something?

me_debankan