ls, rm, cd commands not working in SUSE LINUX

1

Iam newbi to SUSE, I installed java in my SUSE linux Server edition, So i want to set the path in linux,So i created .bash_profile in in /root path using touch and added the path as "JAVA_PATH". When restart my linux the above command is not working and it show unknown command "JAVA_PATH", I can't able to boot in GUI mode, I can boot only in terminal mode, How to delete the file (.bash_profile in /root) ? And how to add java path in SUSE

Note: Before all the commands are working fine

Thanks in Advance, Jak...

Jak

Posted 2011-01-03T15:59:00.683

Reputation:

It's not a good idea to run as root, anyway. – Keith – 2011-01-04T07:53:10.087

Answers

3

You probably damaged your .bash_profile and now you don't have a functional PATH variable.

To delete your .bash_profile, you will have to call the fully qualified name of the executable /bin/rm (instead of just rm). The problem is that this will likely make your problem worse, not better.

To edit the existing .bash_profile and set it to a good state, use /usr/bin/vi and set it to

If you cannot revert you .bash_profile back to it's original form, you should attempt to set it to

# .bash_profile

# Get the aliases and functions 
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME
export BASH_ENV
export PATH

It is a very bad idea to do normal work as root, as you have the ability to irreversibly destroy your system (by creating more work to "set it back again" than it's worth).

Edwin Buck

Posted 2011-01-03T15:59:00.683

Reputation: 231

2

You have probably overwritten your PATH entirely. Try:

PATH=/bin:/sbin:/usr/bin:/usr/sbin

And then remove the .bash_profile:

rm .bash_profile

You can also specify programs with their full path:

/bin/rm /root/.bash_profile

chris

Posted 2011-01-03T15:59:00.683

Reputation: 131

1

Ah... I remember those newbie days. It is very easy to get burned when playing with fire.

    root# bash
    root# export PATH=/usr/bin:/bin:/sbin
    root# cd /root
    root# mv .bash_profile .bash_profile.backup-to-inspect
    root# shutdown -r now

Anyway, these commands will move ".bash_profile" away, but keeps a backup so that you can take a look at it and find out what naughty sort of thing you did to it. It will also reboot the computer.

Some important lessons that you should learn so as to avoid being burned in the future:

  1. Don't mess with root / system settings unless you really know what you're doing (edit your own ~/.bashrc file for your normal user account, before screwing with the root one, and try the command on the commandline and make sure it does what you expect before putting it in your ~/.bashrc).
  2. Always make backups. If there was a /root/.bash_profile, it is generally a good idea to copy it to /root/.bash_profile.orig (if it is the original copy) or /root/.bash_profile.backup before editing it.

When your computer reboots, you should take a look at what you put in that file:

cat /root/.bash_profile | less

I suspect that you did something like:

PATH=PATH:JAVA_PATH

Instead of:

PATH=$PATH:$JAVA_PATH

Or something else that modified your PATH environment variable.

Michael Aaron Safyan

Posted 2011-01-03T15:59:00.683

Reputation: 2 645