How can I CTRL^C out of a password prompt?












7















Say I started a su command, and I want to cancel it. Control+C doesn't work for su like it does for sudo... I have to finish the prompt (either by getting the password wrong enough times or by getting it right).



Is there something that I can type to kill a password prompt?










share|improve this question

























  • Possible duplicate of How can I undo a 'sudo' command before entering the password?

    – DisplayName
    May 6 '16 at 16:07











  • @DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

    – Questionmark
    May 6 '16 at 16:10













  • the answer is control-D.

    – DisplayName
    May 6 '16 at 16:21











  • @DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

    – Questionmark
    May 6 '16 at 16:38











  • It is a duplicate. The answer for the post I linked also says control-D.

    – DisplayName
    May 6 '16 at 20:18
















7















Say I started a su command, and I want to cancel it. Control+C doesn't work for su like it does for sudo... I have to finish the prompt (either by getting the password wrong enough times or by getting it right).



Is there something that I can type to kill a password prompt?










share|improve this question

























  • Possible duplicate of How can I undo a 'sudo' command before entering the password?

    – DisplayName
    May 6 '16 at 16:07











  • @DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

    – Questionmark
    May 6 '16 at 16:10













  • the answer is control-D.

    – DisplayName
    May 6 '16 at 16:21











  • @DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

    – Questionmark
    May 6 '16 at 16:38











  • It is a duplicate. The answer for the post I linked also says control-D.

    – DisplayName
    May 6 '16 at 20:18














7












7








7








Say I started a su command, and I want to cancel it. Control+C doesn't work for su like it does for sudo... I have to finish the prompt (either by getting the password wrong enough times or by getting it right).



Is there something that I can type to kill a password prompt?










share|improve this question
















Say I started a su command, and I want to cancel it. Control+C doesn't work for su like it does for sudo... I have to finish the prompt (either by getting the password wrong enough times or by getting it right).



Is there something that I can type to kill a password prompt?







bash shell command-line kill authentication






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 6 '16 at 16:11







Questionmark

















asked Mar 2 '16 at 1:05









QuestionmarkQuestionmark

1,23041741




1,23041741













  • Possible duplicate of How can I undo a 'sudo' command before entering the password?

    – DisplayName
    May 6 '16 at 16:07











  • @DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

    – Questionmark
    May 6 '16 at 16:10













  • the answer is control-D.

    – DisplayName
    May 6 '16 at 16:21











  • @DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

    – Questionmark
    May 6 '16 at 16:38











  • It is a duplicate. The answer for the post I linked also says control-D.

    – DisplayName
    May 6 '16 at 20:18



















  • Possible duplicate of How can I undo a 'sudo' command before entering the password?

    – DisplayName
    May 6 '16 at 16:07











  • @DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

    – Questionmark
    May 6 '16 at 16:10













  • the answer is control-D.

    – DisplayName
    May 6 '16 at 16:21











  • @DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

    – Questionmark
    May 6 '16 at 16:38











  • It is a duplicate. The answer for the post I linked also says control-D.

    – DisplayName
    May 6 '16 at 20:18

















Possible duplicate of How can I undo a 'sudo' command before entering the password?

– DisplayName
May 6 '16 at 16:07





Possible duplicate of How can I undo a 'sudo' command before entering the password?

– DisplayName
May 6 '16 at 16:07













@DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

– Questionmark
May 6 '16 at 16:10







@DisplayName You can't control-c out of a su like you can a sudo... this is a different scenario.

– Questionmark
May 6 '16 at 16:10















the answer is control-D.

– DisplayName
May 6 '16 at 16:21





the answer is control-D.

– DisplayName
May 6 '16 at 16:21













@DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

– Questionmark
May 6 '16 at 16:38





@DisplayName Yes, see Gilles answer. My point is that this should not be marked as a duplicate...

– Questionmark
May 6 '16 at 16:38













It is a duplicate. The answer for the post I linked also says control-D.

– DisplayName
May 6 '16 at 20:18





It is a duplicate. The answer for the post I linked also says control-D.

– DisplayName
May 6 '16 at 20:18










3 Answers
3






active

oldest

votes


















5














su is running with elevated privileges, and you are not seeing it respond to ^C (which sends a signal with your privileges). You could su to another shell and kill it from the other shell. Also (depending on the system), it might respond to SIGHUP (a hangup signal) if you closed the terminal session where the awkward su is in progress.



There's more than one way that su can ignore your ^C, e.g.,




  • establishing signal handlers or

  • running under a different controlling terminal.


A quick read of Debian's su seems that it uses the latter. Your system of course may be different.



Further reading:




  • /bin/su no longer listens to SIGINT!

  • how to terminate some process which is run with sudo with kill






share|improve this answer


























  • If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

    – techraf
    Mar 2 '16 at 1:41








  • 1





    Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

    – Thomas Dickey
    Mar 2 '16 at 1:42





















7














You can CTRL-D su's prompt.

This shortcut signals an end-of-file on the console, quitting the prompt; the console will display Authentication error, which is expectable.






share|improve this answer





















  • 3





    Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

    – Thomas Dickey
    Mar 2 '16 at 2:26





















2














I've found the best way to kill su during entering of an incorrect password is Control+U followed by Control+D. This should avoid annoying delays. You can also just clear the input with Control+U and re-try typing the password in.



Control+U is a command that clears the current line of text, and also works in a shell (and probably other places too). It's also nice that it seems to work with su to clear the currently-entered password.



Using Control+C doesn't seem to work, it appears that for some reason su just ignores it. It is untrue that the user who started the process can no longer kill it because of setuid -- su dies perfectly fine if you kill it with SIGTERM or SIGQUIT from another terminal (as a user that started it). SIGINT doesn't work, so su probably just ignores it.



Control+D with an empty password input seems to be the only way to instantly kill a running su - if any text is entered, then hitting Control+D will induce a 3-second delay (unless you've actually typed in the correct password, in which case... it'll start a root shell).






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f266931%2fhow-can-i-ctrlc-out-of-a-password-prompt%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    su is running with elevated privileges, and you are not seeing it respond to ^C (which sends a signal with your privileges). You could su to another shell and kill it from the other shell. Also (depending on the system), it might respond to SIGHUP (a hangup signal) if you closed the terminal session where the awkward su is in progress.



    There's more than one way that su can ignore your ^C, e.g.,




    • establishing signal handlers or

    • running under a different controlling terminal.


    A quick read of Debian's su seems that it uses the latter. Your system of course may be different.



    Further reading:




    • /bin/su no longer listens to SIGINT!

    • how to terminate some process which is run with sudo with kill






    share|improve this answer


























    • If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

      – techraf
      Mar 2 '16 at 1:41








    • 1





      Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

      – Thomas Dickey
      Mar 2 '16 at 1:42


















    5














    su is running with elevated privileges, and you are not seeing it respond to ^C (which sends a signal with your privileges). You could su to another shell and kill it from the other shell. Also (depending on the system), it might respond to SIGHUP (a hangup signal) if you closed the terminal session where the awkward su is in progress.



    There's more than one way that su can ignore your ^C, e.g.,




    • establishing signal handlers or

    • running under a different controlling terminal.


    A quick read of Debian's su seems that it uses the latter. Your system of course may be different.



    Further reading:




    • /bin/su no longer listens to SIGINT!

    • how to terminate some process which is run with sudo with kill






    share|improve this answer


























    • If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

      – techraf
      Mar 2 '16 at 1:41








    • 1





      Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

      – Thomas Dickey
      Mar 2 '16 at 1:42
















    5












    5








    5







    su is running with elevated privileges, and you are not seeing it respond to ^C (which sends a signal with your privileges). You could su to another shell and kill it from the other shell. Also (depending on the system), it might respond to SIGHUP (a hangup signal) if you closed the terminal session where the awkward su is in progress.



    There's more than one way that su can ignore your ^C, e.g.,




    • establishing signal handlers or

    • running under a different controlling terminal.


    A quick read of Debian's su seems that it uses the latter. Your system of course may be different.



    Further reading:




    • /bin/su no longer listens to SIGINT!

    • how to terminate some process which is run with sudo with kill






    share|improve this answer















    su is running with elevated privileges, and you are not seeing it respond to ^C (which sends a signal with your privileges). You could su to another shell and kill it from the other shell. Also (depending on the system), it might respond to SIGHUP (a hangup signal) if you closed the terminal session where the awkward su is in progress.



    There's more than one way that su can ignore your ^C, e.g.,




    • establishing signal handlers or

    • running under a different controlling terminal.


    A quick read of Debian's su seems that it uses the latter. Your system of course may be different.



    Further reading:




    • /bin/su no longer listens to SIGINT!

    • how to terminate some process which is run with sudo with kill







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 8 at 14:45









    Stephen Kitt

    167k24376454




    167k24376454










    answered Mar 2 '16 at 1:20









    Thomas DickeyThomas Dickey

    52.4k595166




    52.4k595166













    • If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

      – techraf
      Mar 2 '16 at 1:41








    • 1





      Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

      – Thomas Dickey
      Mar 2 '16 at 1:42





















    • If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

      – techraf
      Mar 2 '16 at 1:41








    • 1





      Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

      – Thomas Dickey
      Mar 2 '16 at 1:42



















    If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

    – techraf
    Mar 2 '16 at 1:41







    If I execute su as a regular user and it is waiting for a password input from user, is it "running with elevated privileges" at this moment?

    – techraf
    Mar 2 '16 at 1:41






    1




    1





    Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

    – Thomas Dickey
    Mar 2 '16 at 1:42







    Yes: you can see for yourself by doing a ps -ef from another terminal. That happens automatically because su is setuid'd to root.

    – Thomas Dickey
    Mar 2 '16 at 1:42















    7














    You can CTRL-D su's prompt.

    This shortcut signals an end-of-file on the console, quitting the prompt; the console will display Authentication error, which is expectable.






    share|improve this answer





















    • 3





      Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

      – Thomas Dickey
      Mar 2 '16 at 2:26


















    7














    You can CTRL-D su's prompt.

    This shortcut signals an end-of-file on the console, quitting the prompt; the console will display Authentication error, which is expectable.






    share|improve this answer





















    • 3





      Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

      – Thomas Dickey
      Mar 2 '16 at 2:26
















    7












    7








    7







    You can CTRL-D su's prompt.

    This shortcut signals an end-of-file on the console, quitting the prompt; the console will display Authentication error, which is expectable.






    share|improve this answer















    You can CTRL-D su's prompt.

    This shortcut signals an end-of-file on the console, quitting the prompt; the console will display Authentication error, which is expectable.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 2 '16 at 22:45









    Gilles

    531k12810651592




    531k12810651592










    answered Mar 2 '16 at 2:22









    joH1joH1

    565419




    565419








    • 3





      Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

      – Thomas Dickey
      Mar 2 '16 at 2:26
















    • 3





      Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

      – Thomas Dickey
      Mar 2 '16 at 2:26










    3




    3





    Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

    – Thomas Dickey
    Mar 2 '16 at 2:26







    Control-D would be an EOF (QUIT is a different thing, and is usually caught). But yes, EOF could work.

    – Thomas Dickey
    Mar 2 '16 at 2:26













    2














    I've found the best way to kill su during entering of an incorrect password is Control+U followed by Control+D. This should avoid annoying delays. You can also just clear the input with Control+U and re-try typing the password in.



    Control+U is a command that clears the current line of text, and also works in a shell (and probably other places too). It's also nice that it seems to work with su to clear the currently-entered password.



    Using Control+C doesn't seem to work, it appears that for some reason su just ignores it. It is untrue that the user who started the process can no longer kill it because of setuid -- su dies perfectly fine if you kill it with SIGTERM or SIGQUIT from another terminal (as a user that started it). SIGINT doesn't work, so su probably just ignores it.



    Control+D with an empty password input seems to be the only way to instantly kill a running su - if any text is entered, then hitting Control+D will induce a 3-second delay (unless you've actually typed in the correct password, in which case... it'll start a root shell).






    share|improve this answer




























      2














      I've found the best way to kill su during entering of an incorrect password is Control+U followed by Control+D. This should avoid annoying delays. You can also just clear the input with Control+U and re-try typing the password in.



      Control+U is a command that clears the current line of text, and also works in a shell (and probably other places too). It's also nice that it seems to work with su to clear the currently-entered password.



      Using Control+C doesn't seem to work, it appears that for some reason su just ignores it. It is untrue that the user who started the process can no longer kill it because of setuid -- su dies perfectly fine if you kill it with SIGTERM or SIGQUIT from another terminal (as a user that started it). SIGINT doesn't work, so su probably just ignores it.



      Control+D with an empty password input seems to be the only way to instantly kill a running su - if any text is entered, then hitting Control+D will induce a 3-second delay (unless you've actually typed in the correct password, in which case... it'll start a root shell).






      share|improve this answer


























        2












        2








        2







        I've found the best way to kill su during entering of an incorrect password is Control+U followed by Control+D. This should avoid annoying delays. You can also just clear the input with Control+U and re-try typing the password in.



        Control+U is a command that clears the current line of text, and also works in a shell (and probably other places too). It's also nice that it seems to work with su to clear the currently-entered password.



        Using Control+C doesn't seem to work, it appears that for some reason su just ignores it. It is untrue that the user who started the process can no longer kill it because of setuid -- su dies perfectly fine if you kill it with SIGTERM or SIGQUIT from another terminal (as a user that started it). SIGINT doesn't work, so su probably just ignores it.



        Control+D with an empty password input seems to be the only way to instantly kill a running su - if any text is entered, then hitting Control+D will induce a 3-second delay (unless you've actually typed in the correct password, in which case... it'll start a root shell).






        share|improve this answer













        I've found the best way to kill su during entering of an incorrect password is Control+U followed by Control+D. This should avoid annoying delays. You can also just clear the input with Control+U and re-try typing the password in.



        Control+U is a command that clears the current line of text, and also works in a shell (and probably other places too). It's also nice that it seems to work with su to clear the currently-entered password.



        Using Control+C doesn't seem to work, it appears that for some reason su just ignores it. It is untrue that the user who started the process can no longer kill it because of setuid -- su dies perfectly fine if you kill it with SIGTERM or SIGQUIT from another terminal (as a user that started it). SIGINT doesn't work, so su probably just ignores it.



        Control+D with an empty password input seems to be the only way to instantly kill a running su - if any text is entered, then hitting Control+D will induce a 3-second delay (unless you've actually typed in the correct password, in which case... it'll start a root shell).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 8 '18 at 16:54









        uukgoblinuukgoblin

        213




        213






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f266931%2fhow-can-i-ctrlc-out-of-a-password-prompt%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List directoties down one level, excluding some named directories and files

            list processes belonging to a network namespace

            list systemd RuntimeDirectory mounts