Skip to content

Instantly share code, notes, and snippets.

@qisantanu
Last active January 30, 2025 13:58
Show Gist options
  • Save qisantanu/fc254416b3f46c96062ca0eb586e78ec to your computer and use it in GitHub Desktop.
Save qisantanu/fc254416b3f46c96062ca0eb586e78ec to your computer and use it in GitHub Desktop.

Restoring My Ubuntu Terminal After a Corrupt .bashrc

Recently, I encountered an issue with my .bashrc file on my Ubuntu system that left my terminal unusable, eventually all stuffs like developing, running, testing halts. Here’s how I identified and resolved the problem.

The Issue Begins

I was trying to install WebLogic on my local system to check for compatibility issues. My Java version at the time was:

openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

When I attempted to execute the WebLogic installer JAR file with the command:

java -jar fmw-....jar

it fails.

Checking the error logs, I found the following message: the openjdk jvm is not supported on this platform.

Switching to Oracle Java

The installer required Oracle Java, but I was using SDKMAN! to manage my Java versions. SDKMAN is similar to RVM for Ruby, but due to licensing restrictions, it no longer provides Oracle Java.

To work around this, I decided to switch to Zulu JDK but ultimately opted to manually install Oracle JDK 8 instead.

Steps I Took:

  1. Downloaded Oracle JDK 8 and extracted it.

  2. Placed it in /opt/java/jdk.

  3. Set JAVA_HOME, ensuring it pointed to the new JDK instead of SDKMAN.

    After setting the new path, I verified the Java version:

java version "1.8.0_431"
Java(TM) SE Runtime Environment (build 1.8.0_431-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.431-b10, mixed mode)

😆

💚 Now, Java was correctly set up.

The Persistent PATH Issue

Later, I navigated to the installer’s directory in a new terminal window and re-ran the command—only to face the same error. Checking the Java version revealed that my shell was still using OpenJDK instead of the newly installed Oracle JDK.

At this point, I realized that my PATH was not updated permanently. Since .bashrc is responsible for configuring interactive non-login shells, I needed to reload it.

source ~/.bashrc

The Real Problem Begins

The command froze. Nothing happened. Even pressing Ctrl + C didn’t work.

  • I opened a new terminal—same issue, it was stuck.
  • I restarted my system multiple times—no improvement.
  • The terminal simply hung, waiting indefinitely. 😨

Troubleshooting .bashrc

Realizing that .bashrc was likely causing the issue, I manually edited the file:

I undid all my recent changes—but the problem persisted. As a last resort, I deleted all content inside .bashrc, and my terminal started working again. 🚀

Unfortunately, this also meant I lost all my Java, Ruby environment configurations. 😞. And all my projects starts throwing error.

Finding the Culprit

I carefully restored my .bashrc content line by line to identify which one was causing the issue. Eventually, I found the problematic line:

source <(ng completion script)

This stale Angular CLI autocomplete command was preventing the script from executing correctly, causing the terminal to hang.

Final Fix

I removed the problematic line, then ran:

source ~/.bashrc

Now, the terminal worked smoothly! 🎉

I re-ran the WebLogic installer, and this time, the installation window popped up successfully.

Lessons Learned

  1. Be cautious when modifying .bashrc A single incorrect command can render your terminal unusable.
  2. If your terminal hangs after updating .bashrc try restoring an earlier version by editing or clearing the file.
  3. Use source ~/.bashrc carefully. Ensure the file is free from syntax errors before sourcing it.
  4. Check your PATH persistence. If Java (or any tool) isn’t behaving as expected, verify that the correct PATH is applied across all terminal sessions.

💡 Tip: Keep a backup of your .bashrc file before making major changes:

cp ~/.bashrc ~/.bashrc.bak

This way, you can always restore a working version if things go wrong!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment