aspose file tools*
The moose likes Linux / UNIX and the fly likes Editing the bashrc file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Editing the bashrc file" Watch "Editing the bashrc file" New topic
Author

Editing the bashrc file

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9618
    
    2

Guys,

I somehow messed up my bashrc under /etc/bash.bashrc when I was trying to set Maven and Java home variables. Now when I open my terminal, it complains that it cannot find /usr/bin. I'm not able to remove the PATH variable that I have set when trying to set Java and Maven home. Now I'm even not able to execute the sudo command. Is there a way to edit this file and restore everything?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9618
    
    2

I gte the following message when I open my terminal



Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Login as root (which should have an OK environment) and edit it as root. Don't forget to fix the permissions after, if needed!


[Jess in Action][AskingGoodQuestions]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9618
    
    2

I have only one user created. How do I log in as root?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9618
    
    2

I tried giving root as username and root as password and was not able to log in... tried giving only the username as root with empty password, also not able to log in... Any ideas?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9618
    
    2

Just managed to get rid of this by typing /usr/bin/sudo su and then was able to edit the bashrc file.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Incidentally, on a RedHat/Fedora system, the master bashrc comes from the RPM named "setup". You'd have to forcibly reinstall it or install to an alternate location and copy the /etc/bashrc original file from the alternate location.

Of course, all of the above requires that you be running as root.


Customer surveys are for companies who didn't pay proper attention to begin with.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11524
    
100

Most Unix systems allow you to boot into single user mode at the time you boot the computer. However without knowing anything at all about what flavor of Unix / Linux / ... it is difficult to advise on how to do this.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Both Grub and LILO allow single-user boots as long as you haven't disabled the ability to edit the boot directives. Just add "single" to the list of options on the "kernel" directive.

My normal panic recovery is just to boot off a Fedora/RedHat/CentOS install cd/dvd and when the intial screen displays, type in "linux single" at the prompt. That way I can modify files that would be difficult to maintain if I was actually running under them.

Incidentally, the original messages indicated that the variable name wasn't provided on an export command. That is, instead of


it was coded incorrectly as


Actually, I suspect that there was a directory named "Apache Foundation", and it's possible that the actual offending statement was more like


which I think would be interpreted as 2 separate exports separated by the blank in the directory name "Apache Foundation"

This is why "user friendly" names with embedded spaces in them are bad.

If you absolutely positively insist on spaces in pathnames, code the directive like one of the following:


The one with quotes around it is somewhat safer for most of us.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Editing the bashrc file