ls: illegal option
iMac, Mac OS X (10.6.8)
Are you just hitting return at the end of line?
Check the terminal preferences, Encodings. In fact go through all your terminal preferences to see if they make sense (particularly Settings, Advanced for terminal type -- I use xterm, character encoding).
Also, is ls the only command this happens with, or all terminal commands? If just ls then is it possible you aliased it in one of the bash startup scripts to something with an illegal option? I'm assuming you know what I am talking about with respect to the bash startup scripts.
They're referring to a setting in a bashrc configuration file.
Here is a similar configuration for a linux bash kernel (which is very similar) where they set the following:
alias ls='ls --color=auto'
Note the 'alias' not 'alis'.
So it appears that through some process, the definition for 'ls' was changed. I had this same issue and it turns out I had to check all locations where this definition could be. Those places possibly include the following (if they exist):
/etc/bashrc
~/.profile
~/.bash_profile
~/.bashrc
Check if any of those files have an additional entry for the 'ls' command.
OK cool, thanks I found the /etc/bashrc but no mention of any colour presets etc.
I then checked ~/.profile and found this:
[ "$TERM" = "xterm" ] && TERM="xterm-256color"
alias ls='ls --color'
So I made it like this:
alias ls='ls --auto'
Saved and restarted Terminal, but it still gives this message:
jb:~ tom$ ls
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
BUT THEN I FIXED IT: by just deleting the ~/.profile file altogether! 😁 😁
So it appears this line in this file is definitely causing the issue. It would be nice to know if deleting the file is bad but for now I'm stoked to be able to type is "ls" once again!
Thanks!!
I just found out. I set alis ls="ls -FH --color". But after the update, the --color is replaced by -G. I have set alis ls="ls -FHG", and it works now.
Which was what I asked when I was updating my post while you posted yours.😉
when you say:
I have set alis ls="ls -FHG", and it works now.
how do you do that? is that a terminal command right there or... ?
ls: illegal option