9

I recently installed zsh and now whenever I ls or ls -l or ls anything I get "illegal option". Not sure where to start looking to fix this.

3 Answers 3

10

Run which ls to see what exactly is ran why you type ls. ls may be configured as an alias with options not available on your system.

1
  • 2
    Yup, it was configured with --color=auto. Replaced with -G and it works. Thanks. Mar 21, 2010 at 2:51
1

Might be a broken alias. Try /bin/ls

3
  • How does one mean the alias? Hoping you're still kicking around from answering this 14 years ago 🤞
    – ckhatton
    Jan 31 at 22:47
  • 1
    All good now! I'm using fish shell and found I can just write alias ls="/bin/ls" to get the ls command working
    – ckhatton
    Jan 31 at 22:53
  • 1
    @ckhatton Glad you made it! :-)
    – jlliagre
    Feb 1 at 1:48
0

tip:

if you even find yourself without /bin/ls , (recovery limited shell / corruption / meltdown) then you can use

echo *

which will display file and directories in the current directory (it's not pretty, but it works!)

as echo is a shell built in, it will always work, without the help of external unix tools :-)

try

type echo

echo is a shell builtin

here a short list of the bash built-in's (I don't have zsh installed)

bash defines the following built-in commands: :, ., [, alias, bg, bind,
   break,  builtin,  case,  cd,  command,  compgen,  complete,   continue,
   declare,  dirs, disown, echo, enable, eval, exec, exit, export, fc, fg,
   getopts, hash, help, history, if, jobs, kill, let, local, logout, popd,
   printf,  pushd, pwd, read, readonly, return, set, shift, shopt, source,
   suspend, test, times, trap,  type,  typeset,  ulimit,  umask,  unalias,
   unset, until, wait, while.

You must log in to answer this question.

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