Understanding Why Terminal Doesn’t Let You Type a Password

Feb 4, 2015 - 33 Comments

Cant type a password into the Terminal? Yes you can, it just doesn't show up

Sometimes you need to enter a password into the terminal, usually for sudo or su commands, which lets users execute a command with super user privileges. This is fairly typical for allowing access to read or modify something that would otherwise not be possible with a standard user account. You’ll commonly see sudo prefixing another command, looking something like “sudo nano /etc/hosts“. Though most of the command line and sudo is generally only appropriate for advanced users, occasionally more casual computer users may need to turn to the Terminal, perhaps to enable a feature, modify a system file, or even for troubleshooting purposes. For novice users who wind up at the command line, a very common question occurs with entering passwords into the Terminal, almost always related to sudo and the apparent inability to type a password into the command line of Mac OS X (or Linux for that matter).

But here’s the thing; Terminal does let you type your password, it just doesn’t look like it. The cursor on screen will not move, and there is no indicator the password is being entered at all. This is intentional and serves as a security mechanism, unlike entering a password into a web form or a standard GUI login screen, which is typically masked as asterisks like ******** or bullets like •••••••••••••, the lack of anything showing is entirely intentional and there is no such indication of entering passwords at the command line. The reason is rather simple, it provides no indication for how long a password is, offering some further obfuscation to password entry.

If this sounds confusing, it’s not at all, here’s how it works in practice. Let’s say you execute a command that requires sudo access, thus bringing up the familiar “Password:” entry.

% sudo cat /etc/secret.conf

When the Password: request comes up, type the password anyway, even though nothing is showing up then hit Return when finished. Again, there is no indication that a password is being entered, and that is intentional.

Terminal won't enter a password visibly, but it is entered

So let’s run through the prior example command again, pretending the admin password on this particular machine is “Monkey123”, you’d type that password as it’s requested, despite not showing up at all, meaning the sequence would be something like:

% sudo cat /etc/secret.conf
Password: Monkey123 (hit Return key)

This will execute the command. And no, Monkey123 (or whatever the admin password is) will not appear on screen, neither will any asterisks or bullets.

Typing a password into Terminal won't show up, this is intentional

To be 100% absolutely clear:

Terminal passwords do not show up when typed as a security measure, type the password when requested anyway and hit return

Typing the password and hitting return will submit the password for authentication, and assuming the password was entered correctly, the command will execute as expected.

Typically a user only has to experience this once or twice to understand that’s how it works, but it remains a great question for users who are just starting to get exposure to the command line. And once you know, you can pass the knowledge along to others, so if someone asks you “why doesn’t the Terminal let me type a password?”, you can now answer and explain it to them.

For those wondering, yes this default behavior can be changed to show asterisks for each character entered as the password in the command line, for sudo, su, or whatever else you’re doing. Nonetheless, making that change is not recommended, and we’re not going to cover it in this particular article… perhaps in the future if there is some interest in doing so.

What do you think of this security measure that hides the password length and entry in Terminal? It has been standard practice for a long time for the unix world, but do you find it useful on the Mac too? Let us know your thoughts in the comments below.


Related articles:

Posted by: Paul Horowitz in Command Line, Tips & Tricks


» Comments RSS Feed

  1. addison diez says:

    I enter my password and it still says “Sorry try again.” Is this some Master Password issue I really don’t want to deal with or something else cause I can’t find anything in the article about it being wrong even after entering the password correctly.
    or im just blind. if im just being blind, please copy the section of the article that’ll help me

  2. sudhira says:

    im typing my password yet its showing sorry try again. how to solve this

  3. Muhammad Afzal says:

    This solution worked for me, thank you. I faced this problem while committing my codes on github. I didn’t commit many codes due to this problem and now finally i am doing my work easily.

  4. Josie says:

    I am really confused, mine comes up with a padlock next to the password: and tells me its wrong everytime, why is there a padlock

  5. habti says:

    this article helped me so much .
    those who don’t know what to do ,treat as what article says.it is too useful.
    thanks to the writer of the article.

  6. Robert says:

    I came across this helpful article via a Google search. It’s funny how elegantly simple the explanation/reason was behind my apparent issue. Thank you for writing this informative post.

  7. M.A. says:

    So, what do I do when Terminal won’t let me enter anything after the Password line. Won’t accept manual entry or cut-paste. the line says Password: followed by a key icon. Then when I press Enter/Return, just get Sorry, try again followed by the same Password: [key icon]

    • Tldr says:

      This article tells you exactly what to do if you think that Terminal won’t let you type anything in the password line, I suggest reading the article to find your answer, it explains it completely


      • Bryan says:

        The inability of people to read is breathtaking.

        • Hoberlin says:

          It’s interesting, some people are just smart enough to seek an answer for why Terminal is seemingly not letting them type a password but then the same people somehow skip the entire article that explains it does let you type the password it just doesn’t show it, and they go directly to the comments and say that it’s not letting them type the password – which it is, and that and the why, all of which is explained in the entire article if they bothered to read it!

    • AB says:

      I am having the same issue I am typing the password and yes I realise that terminal doesn’t show as if I am typing the password problem is terminal is not even allowing me to input my password. I don’t feel whoever commented on your comment with the link to the article below actually ready your problem which is the same as mine…

  8. Lyle says:

    Best thing I read today…
    Been trying to figure this out for hours now.

  9. I did what you suggested but the computer told me my password could not be found and it printed my refused password

  10. Korrilius says:

    See my problem is that when I press enter, the Teminal just exits all together, anyway I can fix this?

  11. anthony says:

    my terminal wont let me install a photoshop plugin, it keeps giving me error reports Failed to get extension handle by extension name, status = -406!
    Failed to install, status = -403!

  12. rick says:

    I attempted to set new root password but I failed.When I set new root password in comand line word won’t show up.Keyboard was certainly worked.I can not understand this cause.

  13. Edoardo says:

    I’m trying to delete stuff from my mac with the sudo command but when i reach the point where i need to enter the password in the terminal instead of the usual grey rectangle there is a key inside that won’t let me type anything even if i type the password (btw i know that nothing should appear) and then press enter it would say ‘sorry try again’
    Have you got any idea what my problem is????

  14. DanD says:

    Unfortunately for me my password does not seem to work under OSX 10.11. I know I am typing it right but it still says “su: Sorry”.

    • Sophie Lazar says:

      SO, if this helps anybody… First i had the admin password on my 10.8.5 mac set for the admin, so I would enter it, (wihtout seeing it as explained above) and it would still say sorry no..
      Then I changed it to no passoword and tried that. I went back to the system preferences/user/groups/ and under the column for the list of users and admin, where there is a + and a – symbol, next to that is a little settings wheel. I had done a fresh install of my OS, and there was no MASTER PASSWORD set, even though there was an admin password set. I set the master password, and VOILA! bingo, sudo password joy>>. it took a second to think about it, and then ran my command. booya

      • MaureenTheTemp says:

        I could kiss you, Sophie!! That was my problem, went in and set a password and bingo everything worked. It’s six years later, but you are still helping the world! (Or at least newbie Linux users)

  15. KarolaM says:

    Thank you for your posting, good explanation; it worked for me even though I am not a techie. Appreciate your time spent on detailed narrative.

  16. Avenged110 says:

    This is so annoying. That and the fact that I can’t enter a blank password. I get so sick of having to go make a password just to enter a command.

    What I don’t understand is if its hidden/can’t enter a blank password “in the name of security,” who cares, I’m sitting in front of the computer. Who/what are they keeping it secure from? The guy looking over my shoulder?

    • Not Torvalds says:

      Yes actually, it may sound weird but this actually is designed to prevent password snooping from ‘the guy looking over’ your shoulder. The invisible password thing has been part of BSD and Unix since the 70’s, a very long relic. Nowadays, if you have a secure and reasonably long password, it may not be as important, but imagine an unscrupulous individual discovering someone had a 1 to 6 digit password? That would be easy to set that as a parameter and guess and/or run a dictionary file against the digit match, thus, this security measure exists. This is from AT&T and Unix, it’s in all Linux distros too, it’s not just Mac OS X or Apple.

    • Raven says:

      Why on Earth would you want a blank password? Don’t be lazy.

      • bernard cleyet says:

        “Why on Earth would you want a blank password? Don’t be lazy.”

        Because I’m very tired of having to look up a password for every little thing. The only important (for me) password is my bank’s. I’ve stopped using face book and other (likedin, etc.), because of passwords. So I use enter (CRLF) whenever permitted.

        Unfortunately, I thought my question [How does one find the password for sudo?] was being answered. Not incidentally, all the ones I’ve tried result in “try again”.


        • Gin says:

          The sudo password is the same as the admin / root password

          Try using an easy mnemonic to remember passwords. Even something like “IHatePasswords321” would be better than nothing.

  17. Gomrl says:

    The other question is why you cannot sudo in Terminal as a standard user but need to be logged in as an admin user.

    • rpk says:

      Users with permissions to ‘sudo’ are stored in /etc/sudoers – which will generally contain a line allowing ‘admin’ users to run sudo.

      The permissions on /etc/sudoers is root read-only, so you’ll need to be in an ‘admin’ group to view it – but then only if you have permissions to run ‘sudo’.


      cat /etc/sudoers

      and you’ll get:

      cat: /etc/sudoers: Permission denied

      Now if you’re in the ‘admin’ group, type:

      sudo cat /etc/sudoers

      ps. don’t be daft and try to edit /etc/sudoers with something like ‘nano’.

      You need to use ‘visudo’ – which locks the file against multiple simultaneous edits and opens up the file in the ‘vi’ or ‘vim’ editor.

      You can totally screw your system up if bugger up this file, which is highly likely if you’re unfamiliar with using ‘vi’ or the correct syntax the file requires.

    • Daniel Ebeck says:

      There is a way around this, as long as you know the credentials for an admin user. Just use the “login” command from the standard account to switch to an admin user in the Terminal. Then you can use sudo as much as you like. Use “exit” to get back to your standard user.

  18. TD says:

    Other programmers deal with the issue of number of characters by inserting a random number of asterisks for each key pressed. Then at least you know its accepting keyboard input.

Leave a Reply


Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site