• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editing the bashrc file

 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gte the following message when I open my terminal



 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Login as root (which should have an OK environment) and edit it as root. Don't forget to fix the permissions after, if needed!
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have only one user created. How do I log in as root?
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11852
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic