LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2010, 10:03 AM   #1
unityxx311
LQ Newbie
 
Registered: Jun 2004
Location: Atlanta,GA
Distribution: RHEL5.0
Posts: 19

Rep: Reputation: 0
I put an 'exit' in my /etc/bashrc and now can't open a terminal or modify!


Hi,

This was a very bad move, but I put an exit in my /etc/bashrc file and now I can not open a new terminal or modify the file. I can't su and their are no users in the sudoers file. Please let me know if you have any ideas. TIA

T.
 
Old 08-19-2010, 10:11 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Idea #1: Try using your `run command` dialog box (should be something like this in your menus somewhere) and starting your terminal manually, giving the command with /bin/bash and the --norc and/or --noprofile option to tell it to ignore the broken file(s).

Something like below in your run dialog:
Code:
gnome-terminal -c /bin/bash --norc --noprofile
You didn't tell us what OS you're running; I'm guessing Ubuntu or RHEL, but depending what OS it is, you'll want to specify whatever terminal program you normally use.

Idea #2: Ubuntu has Dash shell installed. You could reboot and edit your kernel boot line to include init=/bin/dash which should boot you to a minimal environment shell prompt, from where you could repair the file.

NOTE: There might be an easier idea(s) but this is what comes to mind.

Last edited by GrapefruiTgirl; 08-19-2010 at 10:13 AM.
 
1 members found this post helpful.
Old 08-19-2010, 10:14 AM   #3
unityxx311
LQ Newbie
 
Registered: Jun 2004
Location: Atlanta,GA
Distribution: RHEL5.0
Posts: 19

Original Poster
Rep: Reputation: 0
Thank you - I will go try this now. Sorry it's a RHEL5.0 box.
 
Old 08-19-2010, 10:21 AM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
OK, I don't know what RHEL has for a terminal program, but surely it has `xterm`; it might be lacking gnome-terminal though.

Oh, and believe I have made a mistake above; it should be -e to execute a command with for example xterm, not -c (-c is for bash). So your run dialog would look something like:

Code:
xterm -e /bin/bash --norc --noprofile
Note: the -e option gives me an error even though syntax is correct according to the manpage, but if I leave it out, it works fine:
Code:
xterm /bin/bash --norc --noprofile
Sorry about that mistake above - and good luck!

Last edited by GrapefruiTgirl; 08-19-2010 at 10:27 AM.
 
1 members found this post helpful.
Old 08-19-2010, 10:22 AM   #5
thorkelljarl
Senior Member
 
Registered: Jun 2008
Posts: 1,787

Rep: Reputation: 211Reputation: 211Reputation: 211
Or, if you can boot into it...

If you know your error, you should also be able to re-edit the file that is causing your misery using a linux live-cd, one that will give you "root"(read/write) privileges. PCLinuxOS with KDE is a suggestion, but there are others with Gnome if that is more familiar to you.

You may have to boot into "guest" and change the log-in to "root" thereafter, as is the case with PCLinuxOS.

Last edited by thorkelljarl; 08-19-2010 at 10:24 AM.
 
1 members found this post helpful.
Old 08-19-2010, 10:41 AM   #6
unityxx311
LQ Newbie
 
Registered: Jun 2004
Location: Atlanta,GA
Distribution: RHEL5.0
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by GrapefruiTgirl View Post
OK, I don't know what RHEL has for a terminal program, but surely it has `xterm`; it might be lacking gnome-terminal though.

Oh, and believe I have made a mistake above; it should be -e to execute a command with for example xterm, not -c (-c is for bash). So your run dialog would look something like:

Code:
xterm -e /bin/bash --norc --noprofile
Note: the -e option gives me an error even though syntax is correct according to the manpage, but if I leave it out, it works fine:
Code:
xterm /bin/bash --norc --noprofile
Sorry about that mistake above - and good luck!
Thanks for the help! That allowed me to pop a new terminal..the only problem is that when I su to edit the /etc/bashrc file I exit back to the non-root prompt. This is a tricky problem.
 
Old 08-19-2010, 10:45 AM   #7
DJ Shaji
Member
 
Registered: Dec 2004
Distribution: Fedora 22 (Twenty Two!), ArchLinux
Posts: 506
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
login as root from the gdm
 
Old 08-19-2010, 10:46 AM   #8
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Hmm. I wonder, what if you `su` and directly give su a command to either `mv` the offending file immediately to a backup? For example:

Code:
su -c mv /etc/bashrc /etc/bashrc.bak
Or, specify your bash shell with the options given earlier:
Code:
su -s /bin/bash --norc --noprofile
for the same effect as earlier.
 
1 members found this post helpful.
Old 08-19-2010, 10:53 AM   #9
unityxx311
LQ Newbie
 
Registered: Jun 2004
Location: Atlanta,GA
Distribution: RHEL5.0
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by GrapefruiTgirl View Post
Hmm. I wonder, what if you `su` and directly give su a command to either `mv` the offending file immediately to a backup? For example:

Code:
su -c mv /etc/bashrc /etc/bashrc.bak
Or, specify your bash shell with the options given earlier:
Code:
su -s /bin/bash --norc --noprofile
for the same effect as earlier.
You solved it - can't say thanks enough! This worked:
su -c "mv /etc/bashrc /etc/bashrc.bak"
I then went in with vi and edited out the mistake.

I thought I would have to boot from a live disk as noted in a reply above. THANK YOU!
 
Old 08-19-2010, 10:56 AM   #10
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Cool, you're welcome - I'm glad it worked! I see you're posting from the RHEL box now

Cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] exit in script files cause konsole terminal itself to exit Star_Gazer Programming 11 04-12-2010 09:32 AM
Can't Modify .bashrc as root Ukuntu Linux - General 2 04-07-2009 10:58 AM
Do I put PATH in bash_profile or bashrc or both? nick623 Linux - General 14 03-31-2007 07:41 PM
How to modify my .bashrc in general to accomodate running binaries (e.g. SCHEME)? Erik_the_Red Linux - Software 1 08-01-2005 01:23 PM
how to modify .bashrc file amadan_in Linux - Newbie 1 01-01-2003 04:55 AM


All times are GMT -5. The time now is 01:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration