Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Step By Step:

  1. On i paste line "sudo -s" to file "~/.bashrc" in home directory for "mylogin"
  2. SSH Login to
  3. After login:$

  4. But, press cntrl+D for exit$ exit$ exit


    5.Do not quit.


Please, tell me the correct method.

share|improve this question

migrated from May 21 '11 at 22:44

This question came from our site for professional and enthusiast programmers.

The command sudo -s runs a new shell, which executes your .bashrc.

So what happened here, is that you created a loop where each new shell runs sudo -s, which in turn creates a new shell. At some point, the loop reached the RLIMIT_NPROC limit for the system, and the loop stopped, leaving a huge stack of nested shells. This limit is too high on most system (8192 or unlimited) for you to exit them using your keyboard.

share|improve this answer

You can store a flag in an environment variable:

if [ -z $INITIAL_SUDO ]; then
    exec sudo -s INITIAL_SUDO=1

In this case, initial shell invoked by ssh won't have the INITIAL_SUDO flag on and it will spawn sudo process. Shell invoked by sudo, on the other hand, will have INITIAL_SUDO variable set and won't try to call sudo again.

Note that I call exec sudo -s instead of sudo -s. Otherwise, you'll have to press ctrl+D twice: first for a root shell and second for an initial shell which invoked sudo in the first place.

share|improve this answer
Also note that if sudo -s breaks for any reason, you are locked out of the machine—at least in interactive mode. If you remember what is going on you can do a non-interactive ssh in to fix things. – Seth Robertson May 22 '11 at 3:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.