I'd like to customize the colors of ls and as far as I understand the way to go is with dircolors.

I did:

dircolors > ~/.dircolors

Immediately after this I launch a terminal and get this error:

dircolors: /home/frank/.dircolors:1: invalid line;  missing second token

I have not changed anything in ~/.dircolors. Running Ubuntu 11.10 x64. The file looks like this.

export LS_COLORS

You can try

dircolors -p >.dircolors

It also can solve the problem

  • This is likely the only correct answer in this thread.
    – doctorG
    Jan 15 '17 at 15:03

I had the same problem under Ubuntu 12.04. The solution was to edit the ~/.dircolors file to remove the second line ('export LS_COLORS') and make the first line do the export:

export LS_COLORS='...

No, I have no idea why.

  • This is the answer, though don't know why.
    – Honghe.Wu
    Feb 22 '17 at 12:56

Looks like you're using csh.


dircolors -c > ~/.dircolors

(Note: some setups use .dir_colors instead.)


Preliminary assumption/expectation: the OP is somewhere running the command

dircolors /home/frank/.dircolors

probably in a bash config file as

eval "$(dircolors ~/.dircolors)"

From the man page for dircolors:

SYNOPSIS dircolors [OPTION]... [FILE]


If FILE is specified, read it to determine which colors to use for which file types and extensions. Otherwise, a precompiled database is used. For details on the format of these files, run 'dircolors --print-database'.

In other words, if you give dircolors a file argument, it expects a file format as given by 'dircolors -p'. Any other format will not work as intended as you are then getting the output of dircolors as intended for updating environment variables in shells. Deleting that second, "export", line may stop the error but the result will not be what you expect if you ever try to edit your dircolors database file.

The accepted answer by Mat likely was also the first answer that stopped the error message. But will not be doing what you hope!


what I found the solution was:- first of all check whether you have ~/.dircolors file or not? if not then put this in your terminal:-

dircolors -p > ~/.dircolors

then open your zshrc file from any text editor you want for eg using sublilme:-

subl ~/.zshrc

and add these lines into that file:-

eval "$(dircolors ~/.dircolors)"
alias dir='dir --color'
alias ls='ls --color=auto'

now you have got your solution done. if you want to change the colors open .dircolors through your editor and change the value of the color and other stuffs. go to this link for the colors : - http://linux-sxs.org/housekeeping/lscolors.html

Solution of other did not work for me. Perhaps because I am using zsh shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.