Changing colour of text and background of terminal?

I can change the colour through preference , but how can I change the background colour and text colour of terminal through the command line?