Solved

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

Posted on 2003-11-11
9
704 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now