Linux Lite Forums
ls: unrecognized/unknown option «--color [» - Printable Version

+- Linux Lite Forums (https://www.freecinema2022.gq/forums)
+-- Forum: Software - Support (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=5)
+--- Forum: Other (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=20)
+--- Thread: ls: unrecognized/unknown option «--color [» (/showthread.php?tid=4622)



ls: unrecognized/unknown option «--color [» - Moltke - 11-06-2017

Hi everyone! Hope you're all having a nice life! Smile
I wanted to list files/folders in a directory with
Code:
ls
and got this 
Code:
ls: unrecognized option «--color [»
Why am I seeing this? What does it mean? I've googled for this  without any luck Sad
Any help/advice is really appreciated.
Thanks in advance for your answers.
By the way, since my system is in Spanish I translated the error message so I don't know if that's what you'll see in English. Wink


Re: ls: unrecognized/unknown option «--color [» - MohamedKhaled - 11-06-2017

don't know ... mine working well ... whats the directory you are trying to get ls from ... maybe you are asking without giving root permission


Re: ls: unrecognized/unknown option «--color [» - JohnD - 11-06-2017

(11-06-2017, 09:02 PM)Moltke link Wrote: I wanted to list files/folders in a directory with
Code:
ls
and got this 
Code:
ls: unrecognized option «--color [»
Why am I seeing this?

Often there are predefined aliases. For Example in my system there are for example those aliases:

Code:
alias cd..='cd ..'
alias c~='cd ~'
alias la='ls -a | grep '\''^\.'\'' | column'
alias ls='ls --color'

In many cases those aliases are defined in the file "[tt]home/USERNAME/.bashrc[/tt]" or in "[tt]/home/USERNAME/.bash_aliases[/tt]". (Of course you have to replace "USERNAME" by your account name.)

In my opinion there might be a typo in the definition of the alias for "ls". You might test it by typing:

Code:
alias ls='ls --color:always'
ls

If now you get no error message as before, it should be a typo in the alias definition.

But to make this change permanent you have to edit the file ".bashrc" (or ".bash_aliases"), in which the alias is wrong defined.

HTH



Re: ls: unrecognized/unknown option «--color [» - Moltke - 11-06-2017

Quote:Often there are predefined aliases. For Example in my system there are for example those aliases:

alias cd..='cd ..'
alias c~='cd ~'
alias la='ls -a | grep '\''^\.'\'' | column'
alias ls='ls --color'
By predefined you mean predefine "by user" or "by the system"? I could use ls command before without any issues whatsoever and I haven't created any aliases for it.

Quote:don't know ... mine working well ... whats the directory you are trying to get ls from ... maybe you are asking without giving root permission

Mine was working fine too last time I checked. No need for root when using ls command.



Re: ls: unrecognized/unknown option «--color [» - JohnD - 11-06-2017

(11-06-2017, 09:36 PM)Moltke link Wrote:
Quote:Often there are predefined aliases. [...]
By predefined you mean predefine "by user" or "by the system"? I could use ls command before without any issues whatsoever and I haven't created any aliases for it.

In my opinion they are defined by the maintainers of a distribution. But by the way: There is an older thread on this topic in the web: superuser.com/questions/1145543/unable-to-use-ls-command-in-linux

They also suppose, it might be a wrong alias definition.

You might use the followong command to find a file, in which the alias for ls is defined:

Code:
grep --files-with-matches -e "alias ls=" ~/.bashrc ~/.bash_aliases ~/*profile /etc/*profile 2>/dev/null



Re: ls: unrecognized/unknown option «--color [» - Moltke - 11-06-2017

(11-06-2017, 09:44 PM)JohnD link Wrote: [quote author=Moltke link=topic=4786.msg36342#msg36342 date=1510004199]
Quote:Often there are predefined aliases. [...]
By predefined you mean predefine "by user" or "by the system"? I could use ls command before without any issues whatsoever and I haven't created any aliases for it.

In my opinion they are defined by the maintainers of a distribution. But by the way: There is an older thread on this topic in the web: superuser.com/questions/1145543/unable-to-use-ls-command-in-linux
They also suppose, it might be a wrong alias definition.
[/quote]

Hi [member=6215]JohnD[/member]
Thank you so much! The solution from the superuser forum worked like a charm Smile Now I'm able to run ls just like I used to before. 
I simply had to run
Code:
unalias ls
and that did the trick.


Re: ls: unrecognized/unknown option «--color [» - JohnD - 11-06-2017

(11-06-2017, 09:55 PM)Moltke link Wrote: I simply had to run
Code:
unalias ls
and that did the trick.

You might have the problem, that the wrong alias definition is again there, if you restart your system, because it might be defined in a file, which will be read at system start or if you open a shell.


Re: ls: unrecognized/unknown option «--color [» - Moltke - 11-06-2017

(11-06-2017, 10:00 PM)JohnD link Wrote: [quote author=Moltke link=topic=4786.msg36345#msg36345 date=1510005318]
I simply had to run
Code:
unalias ls
and that did the trick.

You might have the problem, that the wrong alias definition is again there, if you restart your system, because it might be defined in a file, which will be read at system start or if you open a shell.
[/quote]

Yes, you're right. I did
Code:
grep --files-with-matches -e "alias ls=" ~/.bashrc ~/.bash_aliases ~/*profile /etc/*profile 2>/dev/null
and in .bashrc there are two aliases which I didn't create; one for du command and the one for ls command, deleting those will solve it for good? 


Re: ls: unrecognized/unknown option «--color [» - Moltke - 11-06-2017

I just did it; I deleted those lines in my .bashrc file, restarted the pc and it's working fine. By the way, when I was checking the .bashrc file I found what caused the problem; few days ago I tried this app called "hollywood" which is a "hacker terminal emulator" making you terminal look as if you were doing some "hacker stuff" I wanted to pull a prank on my wife like "oh look I'm hacking you"  :Smile but it was a total waste of my time so I removed it, the thing's  I saw some lines referring to it which I deleted as well. Guess the prank was on me  ;D