Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Linux/Bash - I broke it...

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
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.
(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/e...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.
(Aug 7, 2012 05:38 PM)Αrtificial Wrote:  Unless I am reading http://docs.oracle.com/javase/tutorial/e...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.
(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.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by NightmareMay 7, 2023 05:42 AM 0 70 May 7, 2023 05:42 AM
Last Post: Nightmare
by Leroy Jethro GibbsApr 10, 2017 02:39 AM 6 203 Apr 10, 2017 02:39 AM
Last Post: Leroy Jethro Gibbs
by H0ᚁp0ck3TMar 19, 2012 04:44 PM 0 63 Mar 19, 2012 04:44 PM
Last Post: H0ᚁp0ck3T