I used this command on my folder in unix:
chmod -R go-rwx *
in order to change permissions for group and others. Doing this, many files turned green coloured, even simple data files. Why did this happened?What does it mean? Is it going to affect my files in a bad way? They seem to work right now, but I'm concerned about their general functionality. Thanks!
It is very unlikely that the command you mentioned would cause ls
to print your files in green. When ls
colors are enabled, executable files are printed in light green by default. Since chmod +R go-rwx
only removes permissions, it cannot have caused any files to be marked as executable, and hence won't have made ls
print them in green.
Instead, I believe the cause of this is a different command you must have entered, which accidentally marked all those files as executable. This is actually pretty common. Here is the typical scenario: You want to make a directory and all subdirectories readable and possible to enter for all users. So you do chmod -R a+rx top_directory
. This works, but as a side effect you have also set the executable flag for all the normal files in all those directories too. This will make ls
print them in green if colors are enabled, and it has happened to me several times. You can avoid this by doing chmod -R a+rX top_directory
instead, which will only set the executable bit for directories.
To make your files stop being green, you must clear those executable bits. If none of the files in these directories are actually supposed to be executable, this is simple:
$ chmod -R a-x top_directory
$ chmod -R u+X top_directory
This will remove the executable flag for all files and directories, and then add it back for directories only (for the current user). But if some of the files are actually supposed to be executable, you will have to go through them and fix things manually, which can be tedious.
Having some files incorrectly marked as being executable is not a big problem. They will still function normally. It's just a bit messy, and they may show up in command tab completion if the current directory (.
) is in your $PATH
. So you can safely ignore this issue.
That is an ls
functionality:
--color[=WHEN]
colorize the output. WHEN defaults to 'always' or can be 'never' or 'auto'. More info belowUsing color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.
You can try with ls --color=never
and you won't see the colors anymore.
You can see your color configuration with dircolors -p
.
This is the line where the executables files configuration resides:
# This is for files with execute permission:
EXEC 01;32
That's just to help you identify file types, so it's not affecting your files in any bad way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With