When we fire ls –all in linux cli, files may be listed in different colours
The color code of the files is as follows:
Blue: Directory file White: Normal file Green: Executable file Yellow: Device file Magenta: Picture file Cyan: link file Red: Compressed file
-(Hyphen) = Normal file d=directory l=link file b=Block device file c=character device file
Looking at the htdocs directory on Ubuntu, I see most html files are green and some are white. A couple of these html files are identical, so why are they marked differently?
Hi Jonathan, The reason is that, the green files will have execute permission also. Issue the command ‘ls -all’ to see the file permissions. The white files may not have execute permission. You can try it simply by creating a sample file and checking the permissions & colour. Then give u+x permission and again check the colour.
Yes, you are right. I wonder how this would happen?
I develop these files using the same IDE, and publish them to the web server in the same manner using rsync. They are in the same directory. Yet, most have x perm applied, but just a couple do not have x perm applied.
Thanks for clarifying ‘how’ the colors are determined.
I think I figured out why some files have different perms. I previously used Netbeans and Eclipse for PHP editor. I recently started using PHPStorm. The most recent files that were created with PHPStorm do NOT have x perms, but the previously created files by Netbeans and Eclipse do have x perms.
Why on earth would those other IDE’s apply x perms on new html files is beyond me…but I’m glad I know the story now.
I probably shouldn’t make that assumption quite yet. Another factor I didn’t think of is, I initially uploaded these files using WinSCP. I might have had the initial upload perm configured incorrectly…? Since moving fully to Ubuntu for my dev box, I started using rsync. This very well could be the reason new files do not have x perms, but old files do. I don’t know, and don’t care at this point. Just wanted to add to my comment so I don’t lead someone to believe it was a problem with the IDE’s referenced.