2

While using VirtualBox, I'm unable to use the ls command, it shows

ls: unrecognized option '--color=auto'
ls: use the --help option for usage information

Can anybody give me suggestion?

I searched google and came through the alias command where it shows

alias cp='cp -i'
alias dmesgg='dmesg | grep'
alias l='ls $LS_OPTIONS -lA'
alias lh='ls $LS_OPTIONS -lh'
alias ll='ls $LS_OPTIONS -l'
alias ls='ls $LS_OPTIONS'
alias lt='ls $LS_OPTIONS -lht'
alias mv='mv -i'
alias pss='ps -ef | grep'
alias rm='rm -i'

Please provide any suggestion for it.

2
  • I'd say look in your .bashrc or .profile file for lines containing --color=auto, and look for signs of bad formatting, but that trailing <br/> has me wondering where you could possibly be getting that value. what do you get when you run echo $LS_OPTIONS? Nov 14, 2016 at 8:55
  • Sorry that was copy paste error. I use echo $LS_OPTIONS it shows this message : [1] 2318 bash:LS_OPTIONS: command not found [1]+ Done echo
    – bp04
    Nov 14, 2016 at 9:15

3 Answers 3

2

First run unalias ls. Then run ls as normal.

You will have to do that every time you start a new shell unless you find where the bad alias is being created, e.g. in /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile as described by @dirkt above, or perhaps in ~/.bashrc. Alternatively you can add unalias ls to the end of your ~/.profile, though that is a pretty nasty hack.

1

You probably have a misconfigured .profile or similar file. (see the man command for your shell, there's a bunch of them. If you don't know which shell you have, use ps.) which either sets the option wrongly as '--color=auto'<br/> (if this is not a cut and paste error) using an alias similar to the ones you googled, or you have an ls command that does not unterstand this option.

To make ls work, try calling it directly as /bin/ls. If it's not in /bin, try which ls to find out where it is.

With the working ls command, look at the various shell-profile files, and fix the problem.

4
  • I search for ls by bin, the path /bin/ls is there but when i typed which ls it showed /usr/bin/ls
    – bp04
    Nov 14, 2016 at 9:30
  • ps commands showed me this output **PID TTY TIME CMD 1996 tty1 00:00:00 login 2020 tty1 00:00:00 bash 2269 tty1 00:00:00 bash 2332 tty1 00:00:00 ps **
    – bp04
    Nov 14, 2016 at 9:33
  • You have a bash, so the files are /etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile (at least on my system). The tilde ~ means your home directory. Read man bash for details (long, use the search function). If on your system it's /usr/bin/ls, then use that.
    – dirkt
    Nov 14, 2016 at 10:06
  • i used !/bin/ls command it showed me ls (GNU coreutils) 5.97 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by Richard Stallman and David MacKenzie.
    – bp04
    Nov 14, 2016 at 10:14
0

To use ls temporarily without unaliasing it simply run \ls or command ls

To fix the root cause permanently you'll need to find where the alias was defined. Run

bash -ixlc : 2>&1 | grep -w ls

and it'll show the actual alias command that was run on shell start up. Then you can grep for that string to find the file and edit it, or you can also run bash -ixlc : 2>&1 | grep -P '^\++ (\.|source)\s' to list the files that were sourced and edit the alias definitions in them

Or simply run

bash -ixlc : 2>&1 | grep -P '\bls\b|^\++ (\.|source)\s'

and it'll show the source file following by the alias(es) in that file

You must log in to answer this question.

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