Ubuntu – Unable to enter new commands in terminal — stuck with “>”

bashcommand line

No matter what I do I'm stuck with >. How can I enter a new command?

$ chmod -R 600 `/ .ssh
> 
> chmod
> id_rsa.pub
> 
> sudo chmod 600 ~/ssh/id_rsa

screenshot

I was trying to sync the master and slave by following a youtube video when I encountered the "permission denied" issue. While trying to resolve it I got stuck with >. Now I can't enter any new command.

Please guide me. I'm a Linux/AWS newbie.

Best Answer

  • You have used the older command substitution syntax `` AKA backticks, with only the first one in the initial PS1. That is, you put one backtick in the primary prompt and have not closed it with another, hence the shell (bash) is continuing to take input on the secondary prompt PS2 (by default >).

    In regular cases, just using another backtick to close the substitution would do, but as you have used too many ambiguous commands successively, press Ctrl + C to close the PS2 and get the primary prompt PS1 again.

    while we're at it, for any kind of command substitution operation, start using the more robust $() instead of the buggy and deprecated ``.

    Example:

    $ echo `whoami
    > `
    foobar
    

    Also, are you seriously trying to do chmod -R 660 /?

    Please don't do this, and also don't run any command you don't understand or trust fully.

  • Related Question