4

Every time when I enter my user in ubuntu I get this error:

Command 'ls' is available in '/bin/ls'

and I solved it by:

export PATH=/usr/bin:/bin

but the problem is when I end the session and reenter, the same error appear ..

I'm beginner in using ubuntu OS, also I'm working in an account without sudo access ..

Edited: as @steeldriver requested in the comments:

> /usr/bin/diff /etc/skel/.bashrc ~/.bashrc
export PATH=/home/bghanem/python/python27/bin
export PATH="~/anaconda/bin:$PATH"
10
  • have you tried putting PATH=/usr/bin:/bin in ~/.bashrc?
    – j-money
    Jul 23, 2018 at 13:51
  • 5
    Please edit your question to include the output of diff /etc/skel/.bashrc ~/.bashrc Jul 23, 2018 at 13:53
  • 1
    oh... definitley meant ~/.bash_profile...
    – j-money
    Jul 23, 2018 at 13:59
  • 2
    @justinbenge no, the problem was the $PATH that you forgot
    – damadam
    Jul 23, 2018 at 14:00
  • 2
    @Minion replace diff by /usr/bin/diff will typing the command; that the manual way to access at command; so the command of @steeldriver would be /usr/bin/diff /etc/skel/.bashrc ~/.bashrc
    – damadam
    Jul 23, 2018 at 14:30

4 Answers 4

6

According to the diff output, your problem is definitely inside your ~/.bashrc. You should correct it by editing. (To edit files in your home directory (~), root permissions should not be necessary unless something else is messed up.)

In the first export command, you overwrite the current PATH contents by not including $PATH. To extend the existing list, the command should read:

export PATH="/home/bghanem/python/python27/bin:$PATH"

You can also merge both export commands into one. Moreover, you should use $HOME instead of ~ when setting the PATH variable (thanks @DavidFoerster for the explanation!), so the result is:

export PATH="$HOME/anaconda/bin:$HOME/python/python27/bin:$PATH"

Use your favorite editor to edit the file. In your current situation, you might need to invoke it using the full path, e.g. /bin/nano. After that, don’t forget to reload .bashrc using . ~/.bashrc or by opening a new shell.

8
  • I did the same, but I got the same error again! : Command 'ls' is available in '/bin/ls' The command could not be located because '/bin' is not included in the PATH environment variable. ls: command not found
    – Minions
    Jul 23, 2018 at 14:58
  • @Minion You need to reload the edited file, see my update.
    – Melebius
    Jul 23, 2018 at 15:01
  • yes I did that but it not work .. when I run the first command "the one with python", then then "source ~/.bashrc" .. If I checked this command: /usr/bin/diff /etc/skel/.bashrc ~/.bashrc nothing changed ! the same output appeared
    – Minions
    Jul 23, 2018 at 15:05
  • 3
    There's another problem: PATH="~/..." doesn't lead to tilde expansion. It should be PATH="$HOME/..." instead. Jul 23, 2018 at 16:54
  • 1
    It's a Bash thing: PATH="~/bin" ./test-path-tilde-expansion my-program and PATH="~/bin" dash -c 'exec my-program' fail but PATH="~/bin" bash -c 'exec my-program' works. Thus programs relying on glibc to discover executables won't find them inside ~/bin. If that's what you want, fine; otherwise use $HOME instead of ~. (There's no mention of tilde expansion in the manual of exec*(3) either.) Jul 24, 2018 at 12:24
1

You have to edit 3 files :

  • ~/.bashrc and ~/.profile

You must add your command line in both files, at the end (your command line is export PATH=$PATH:/usr/bin:/bin)

  • /etc/environment

You must add your command at the end of the file, but without export (in your case, just add PATH=$PATH:/usr/bin:/bin)

Now, to apply your change, you have to reboot your computer, or you can also type these following commands which will apply these changes without reboot :

source ~/.bashrc
source ~/.profile

NB : don't forget the $PATH inside your export, PATH isn't empty so you can have some issues if you forget to add it

7
  • I don't have permissions to do so , It's a user account in a cluster
    – Minions
    Jul 23, 2018 at 14:39
  • don't you have access at sudo command?
    – damadam
    Jul 23, 2018 at 14:41
  • no, "MY_USER_NAME is not in the sudoers file. This incident will be reported"
    – Minions
    Jul 23, 2018 at 14:41
  • would be almost impossibleto solve, we need to have read and write access on system file (not for ~/.bashrc or ~/.profile but for /etc/environment)
    – damadam
    Jul 23, 2018 at 14:45
  • it was working before a day with a problem, but when I was trying to install python virtualenv locally I did something wrong ..
    – Minions
    Jul 23, 2018 at 14:47
1

open ./bashrc in any editor then write at the end of file

PATH="$PATH:/usr/bin:/bin"

or you can add as many path appending to it ":path" and then update it by

source ./bashrc
0

I solved it following the answer here: Setting "export PATH=/usr/bin:/bin" permnently

I edited ~/.bashrc file:

pico ~/.bashrc

at the end of the file I found these lines:

PATH="/home/common/bin:$PATH" 
export PATH=/home/MY_USER/python/python27/bin 
export PATH="~/anaconda/bin:$PATH"

I added below them:

PATH="/usr/bin:/bin"

and I saved it ..

8
  • 1
    I doubt this. The export statements after the PATH=… statements are pointless. And if the last line is really just PATH="/usr/bin:/bin" then your PATH will only contain these two directories (and not /home/MY_USER/python/python27/bin, for example). You definitely did not get those commands from the URL you refer to.
    – PerlDuck
    Jul 23, 2018 at 15:53
  • Sorry, I updated the scripts .. I copied them incorrectly .. the "export" is in the beginning .. for the second part "You definitely did not get those commands", I entered the script "/usr/bin/diff /etc/skel/.bashrc ~/.bashrc" again, and all of them appeared except the first one "PATH="/home/common/bin:$PATH" .. you can try it ..
    – Minions
    Jul 23, 2018 at 15:57
  • 1
    I cannot follow. But now I reckon that you just get /usr/bin:/bin when you type echo $PATH. Still not what you want.
    – PerlDuck
    Jul 23, 2018 at 15:59
  • Yes, this what I get .. but why not what I want ?!
    – Minions
    Jul 23, 2018 at 16:04
  • 3
    That said, your main problem is the second one: export PATH=/home/MY_USER/python/python27/bin, because it doesn't honor the old $PATH, which already includes /bin and /usr/bin until you overwrite it with that command. If you change it to PATH=$HOME/python/python27/bin:$PATH (the exports aren't needed here -- for any of these lines), then you won't need the last PATH=/usr/bin:/bin, and thus will avoid the harm that command causes (as it prevents your local Python and Anaconda PATH entries from having any effect). Jul 23, 2018 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .