BTEP maintains several Question and Answer Forums of interest to the NCI/CCR community.
Currently, there are forums on these topics listed below:
If you wish to ask a question go to the Ask Question Page and submit your question.
Back to QuestionsHow to enable colors for the ls command
How do we get the "ls" command to print out directories/files in different colors?
1 Answer:
Typing "man ls" shows that -G is the flag that enables colorized output.
So to get it to print out colorized output, we would type "ls -G" in the terminal.
To make the "ls -G" be the default behavior for the ls command, we can add it as an alias (a shortcut) to our ~/.bashrc file
For the class, the ~/.bashrc file was created in this step of the computer set up instructions: https://www.biostarhandbook.com/bash-profile.html#bash-profile. and details about the .bashrc file are given here: https://www.biostarhandbook.com/terminal-init.html#terminal-init.
To edit your ~/.bashrc file, open it in a text editor (e.g. nano ~/.bashrc), and add the line:
alias ls='ls -G'
and save it.
Then either type: "source ~/.bashrc" or open a new terminal to see the changes.
Answered on April 22nd, 2020 by desiree.tillo@nih.gov