Solved

Wrong '.bashrc', wont let me login..

Posted on 2003-11-11
9
707 Views
Last Modified: 2008-03-17
Hi all...
I was trying to call a 'script' file when the system boots up. So I added the script path to /etc/rc.d/rc.local file. This didnt seem to work. So i added it to /root/.bashrc and i think this screwed up my system.
It wont let me login to 'root' account.
The system bootsup and after i try to login it just gives me a blue screen.
I'm thinking i did something wrong in the script file. It has nothing much but a single line....
"java filename"
Think i didnt set the PATH / CLASSPATH rite.. so may be the system is looking for it or something.

Is there anyway i can access the '.bashrc' file to modify it??

Thanks.
0
Comment
Question by:queryanalyzer
9 Comments
 
LVL 5

Accepted Solution

by:
g0rath earned 50 total points
ID: 9728237
if you created another non-root account, log in as that account
 su root

enter the root password and it doesn't execute the bashrc files...

if you do

su - root

then is does a proper login that runs the .bashrc file.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 9728281
use a linux bootable FD or CD, boot up the system to single user mode,
manually mount the partition that contains the /root/.bashrc , then edit
the file or just remove it.

You can get a mini-linux distributions from http://www.toms.net/rb/, http://www.kernel.org/pub/dist/superrescue/v2/ and boot up the mini-linux.
and then mount the partition if you don't have the FD or CD on hand.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9728978
either use yuzh suggestion or still easier, if it runs ftp service, ftp a new bashrc file !!!!
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 20

Expert Comment

by:Gns
ID: 9730359
Or if it doesn't run ftp, but ssh... use scp or sftp;).

With a variation, you can transform g0raths example into something working:
log on as a regular user, then
su -s <absolute path to another shell... /bin/tcsh or whatever...>
<passwd>
and you'd be running another shell entirely, thus not triggering the flawed .bashrc
Why is g0raths example bad?
Because .bashrc will be read both if you do "su root" and "su - root" (definitely for the former, very very probable for the latter)... ~/.bash_profile,  ~/.bash_login,  and  ~/.profile is another matter though.
man bash
explains the order files are read, depending on interactivity and login status.

You need use the -s flag to su, to set the shell that it'll execute, and not the -c flag, since that would invoke bash to invoke the other shell.
Do
cat /etc/shells
to see what shells you have available, and do
su --help
to see that your su is capable of using the -s (or --shell=...) option.

-- Glenn
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9731310
ah yes....doh! forgot about that...

So this won't work either?
su -c '/bin/bash --norc --noprofile'

I was thinking only of the ~/.bash_login and forgot the he said ~/.bashrc


/etc/shells shows the shells that you are allowed to run via the -s option.
0
 
LVL 20

Expert Comment

by:Gns
ID: 9731797
> So this won't work either?
> su -c '/bin/bash --norc --noprofile'
Exactly... It translates to
/bin/bash -c '/bin/bash --norc --noprofile'
where the first bash would read .bashrc, but not the second.
Wellplaced echos would demonstrate the effect nicely:-).

> I was thinking only of the ~/.bash_login and forgot the he said ~/.bashrc
Thought you mighthave;)

-- Glenn
0
 
LVL 1

Expert Comment

by:arn0ld
ID: 9735222
the " blue screen"  caught my attention - reminds me of an X problem. How about CTRL-ALT-F1 & see if you can liogin from the prompt?
0
 
LVL 20

Expert Comment

by:Gns
ID: 9737892
If he hangs in .bashrc.... You might get this for the most innocent of things... Like starting X:-).
If s/he still hangs after removing the java thing from .bashrc, then one might look a t the X problem as something separate... at least how I see it:)

-- Glenn
0
 

Author Comment

by:queryanalyzer
ID: 9745500
Thanks a lot guys...
   I tried to login from another user account and 'su root' and.......  it worked.
I know u guys said it wudnt... but it did. I dont know of anything else went wrong too.

But thanks a lot...  and sorry i took sometime to respond.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question