Hack Forums
Linux/Bash - I broke it... - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: Linux/Bash - I broke it... (/showthread.php?tid=2756338)



Linux/Bash - I broke it... - Αrtificial - Aug 7, 2012

I was messing around with my Linux VPS to get a better feel of it, but I broke it...

I was trying to install JDK and I was reading the docs at oracle and I ended up editting my .profile and added the following code:
Code
PATH=/usr/local/jdk1.7.0_05/bin
export PATH
I was told that it sets your PATH for you automatically, so you do not have to set it every time you log in.

Now linux commands "ls -la", "pwd", etc, do not work and I keep getting -bash:
Quote:ls: No such file or directory

Any idea why this is happening?

.profile
Code
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n
I added
Code
PATH=/usr/local/jdk1.7.0_05/bin
export PATH
echo $PATH
to the end, so now it looks like
Code
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n

PATH=/usr/local/jdk1.7.0_05/bin
export PATH
echo $PATH



* - Super Effective - Aug 7, 2012

You did the export command wrong.

Code
PATH=$PATH:/data/myscripts
export PATH

You just put the jdk path and didn't re-add the other paths stored in the $PATH variable. Therefore you just overwrote the entire PATH with the jdk path.

Your only hope is to revert to a previous state or get the default paths off another Linux machine. If you want, I can give you my default path's from my linux box, but I won't guarantee they will work in your VPS.


* - Αrtificial - Aug 7, 2012

(Aug 7, 2012 05:23 PM)Super Effective Wrote:  You did the export command wrong.

Code
PATH=$PATH:/data/myscripts
export PATH

You just put the jdk path and didn't re-add the other paths stored in the $PATH variable. Therefore you just overwrote the entire PATH with the jdk path.

Your only hope is to revert to a previous state or get the default paths off another Linux machine. If you want, I can give you my default path's from my linux box, but I won't guarantee they will work in your VPS.

Unless I am reading http://docs.oracle.com/javase/tutorial/essential/environment/paths.html wrong, it is pretty shit document. I just followed their guide.

Thanks for this. Shouldn't it be it look like the below?
Code
PATH=/data/myscripts:$PATH
export PATH
Wouldn't we want the path to be in the beginning?

Did I put the code in the right place? I have no idea what the original .profile does.


* - Super Effective - Aug 7, 2012

(Aug 7, 2012 05:38 PM)Αrtificial Wrote:  Unless I am reading http://docs.oracle.com/javase/tutorial/essential/environment/paths.html wrong, it is pretty shit document. I just followed their guide.

Thanks for this. Shouldn't it be it look like the below?
Code
PATH=/data/myscripts:$PATH
export PATH
Wouldn't we want the path to be in the beginning?

Did I put the code in the right place? I have no idea what the original .profile does.

It doesn't matter if it's dir:$PATH or $PATH:dir as far as I know. It just changes the order at which the directories are checked. If you want a different program with the same name to be the default, you'd put that one at the beginning and the other one after it.

As for putting your code in the right place I have no idea. This should be in the Unix section under computing, they'd probably know more than I do.


* - Αrtificial - Aug 7, 2012

(Aug 7, 2012 05:43 PM)Super Effective Wrote:  It doesn't matter if it's dir:$PATH or $PATH:dir as far as I know. It just changes the order at which the directories are checked. If you want a different program with the same name to be the default, you'd put that one at the beginning and the other one after it.

As for putting your code in the right place I have no idea. This should be in the Unix section under computing, they'd probably know more than I do.

Thanks for the help. Going to close this thread, so I can post the new thread in that section.