I have a centos and an ubuntu VM in my PC, and whenever I run ls command in centos VM it prints out text with light font weight. But in ubuntu, the same command prints out text with bolder font. Why?
2 Answers
As others have noted, the colorization is controlled by the --color flag. Many Linux distributions put an alias for ls in ~/.bashrc or another shell startup file, and the alias includes this flag.
The colors themselves are controlled by the $LS_COLORS environment variable. This is usually also set up in one of your shell startup scripts by calling the dircolors command which reads a configuration file telling it how to construct $LS_COLORS. On CentOS and other RHEL derivatives, the default configuration file is /etc/DIR_COLORS. It just happens that CentOS and Ubuntu chose different color schemes for ls output.
The ls command is common to almost all linux distros and behaves similarly. However, there may be an alias for the command in the shell configuration file.In Ubuntu 20.04, the default bash config file is located in the user's home directory and is named .bashrc. It contains the following line:
alias ls='ls --color=auto'
So when you type in ls, you are actually executing ls --color=auto. There may be a different alias or no alias at all in CentOS, or there may be a different alias than the one mentioned above in your Ubuntu installation. This could be the reason for the different behaviour
aliasfile: `alias ls='ls --color=auto' But it may just be the default font used for the terminal. Usually a fixed width font. My Kubuntu install uses Hack 10 (which until now in checking have never heard of). I think Ubuntu uses a different fixed font.