5

Whenever opening the terminal, I always end up with this same error.

-bash: export: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/hadoop/bin': not a valid identifier

And whenever running command lines, the terminal throws an error, like

-bash: sudo: No such file or directory

I can't even edit ~/.bashrc through gedit ~/.bashrc which I think could be the problem. But a echo $PATH gives me a empty line though.

By the way, all those stuff happen under my personal account. There's a dedicated hadoop user account, which I created specifically for running hadoop and in fact works fine without a glitch.

I really appreciate it if anyone could tell me what's going on here, and it's been frustrating me for a week or so. Thanks in advance.

EDIT:

It turned out that before I created the second account(for hadoop), I modified its bashrc at the end of the file, which I totally forgot. Therefore it was bound to run into trouble. Hugh thanks again to you guys for helping me out, reminding me to check the bashrc file and obviously how to run command line in this situation.

Biffen
  • 6,249
  • 6
  • 28
  • 36
James Wong
  • 1,107
  • 3
  • 15
  • 26
  • Looks like you have a syntax error in the line where you try to export `$PATH` (my best bet is a space). Could you show us that line? As for editing, using the full path of the editor should still work, e.g. `/usr/bin/gedit ~/.bashrc`. – Biffen Jun 13 '16 at 10:15
  • Show the contents of bashrc file please – 123 Jun 13 '16 at 10:15
  • Thank you guys indeed. Problems solved. – James Wong Jun 13 '16 at 11:13

1 Answers1

5

Run this:

/bin/bash --noprofile --norc

Then you should have a bash prompt that is tame enough for you to use without getting errors all the time.

Now use /bin/mv ~/.bashrc ~/.bashrc-old to get rid of the .bashrc file that is presumably causing the problems.

Then use /bin/cp /etc/skel/.bashrc ~/ to get yourself a new .bashrc

Alternatively, you can try this, which will probably work with your existing .bashrc, but is a bit of a punt:

/bin/sed -i.bak 's/export PATH /export PATH=/' ~/.bashrc

This replaces the line export PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/hadoop/bin with the same thing except with an = instead of a space, which looks like the root of the problem.

Chris Lear
  • 6,592
  • 1
  • 18
  • 26