Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I added the following line to the end of my ~/.bashrc (This is on a Linode box) and logged out of my ssh session.

source ~/.profile

Now when I log in, the shell is unresponsive. I never get to the prompt and entering commands does nothing.

If I Ctrl-c then it closes the ssh connection. Ctrl-z does nothing either. I can't get access to the ~/.profile to try and see what the issue is.

How can I get the prompt back?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

To get your shell back, just use this procedure.

Hope you remember the contents of .bashrc what were earlier there. It should be something like this:

# .bashrc

# Source global definitions
    if [ -f /etc/bashrc ]; then
        . /etc/bashrc
    fi

Put them into a file with the same name, .bashrc, on the machine from where you can access your Linode machine.

Now use this command:

 # scp .bashrc server:.

This will replace your modified .bashrc with this default one and you should be able to get your shell back.

Please let me know in case you face any issues with this.

share|improve this answer
    
Yeah I was thinking of going this route but just wanted to check that there wasn't an obviously better way. Luckily there weren't many modifications and I found a default bashrc. –  duckyfuzz Mar 26 '13 at 4:38
    
Great. Glad to help. –  GeekRide Mar 26 '13 at 6:54
    
using similar mechanism, you could first scp FROM the machine to another one, and thus have its real content, take out the offendign line, and scp it back on the machine. –  Olivier Dulac Mar 26 '13 at 13:39
add comment

Usually you can tell bash to ignore these rc files with:

ssh -t your-host bash --noprofile --norc

After login, you can view and update the problematic rc files.

share|improve this answer
1  
This is a better solution in my opinion. You don't lose the offending files which allows you to recover useful parts and troubleshoot what caused the problem in the first place. –  Kenny Rasschaert Mar 26 '13 at 7:08
    
Yes. I often do this as I often mess up with my rc files or I need to get a clean shell env. :) –  whjm Mar 26 '13 at 7:23
add comment

People already have asked you how to fix this. But why this has happened to you?

In Debian/Ubuntu, there's this piece of code in ~/.profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

So, by default, ~/.profile is including ~/.bashrc. If you tell ~/.bashrc to include ~/.profile, you are creating an infinite loop.

share|improve this answer
add comment

Your Answer

 
discard

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.