Ubuntu – Why virtual console(Ctrl+Alt+F1) asked for password after logged into it

virtual-console

I want to run sudo service lightdm restart command on virtual console, so i pressed Ctrl+Alt+F1 after that VC login prompt appears,

Login:
Password:

I logged into the vc with my login credentials.If i run sudo service lightdm restart command on that prompt, it again asked for sudo password.

~$ sudo service lightdm restart
[sudo] password for avinash:

Why there is a two step verfication proces?

Best Answer

The first time you entered your password was to log into your account. The second time it prompted you for your password was because you entered a command starting with 'sudo'.

When you use 'sudo' you are telling the system to run the next command as if you are the root (admin) account. When this occurs it asks for your password again as a security feature in case you decide you don't want to run the command or if it might be an unauthorized person (say you forgot to log out and another person attempted this).