0

Hey Guys,


I am trying to figure out how Linux determines whether an object in directory is a file or folder. There's got to be a property (I am guessing in Stat) that Linux references from which lets it know quickly. It's hard to find information on google because when you enter a query like "how linux differentiates between file folder" you get a lot of tutorials on what physically makes them different which is annoying :P.


Thanks!

5
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by shibblez
0

Hmm, I am starting to think this should have been posted in the Kernel forums. My apologizes. I would delete it and repost it but can find the deletion button.

0

I don't know too many of the internals of Linux (not as many as I'd like). But if you run the ls -a -l command in a directory, you see complete information on the listed files. In the file permissions part of the listing for each item, the first property indicates whether a listed item is a file or a directory. For files there is a dash - (flag not set). For directories it's d (flag set). The other flags rwxrwxrwx relate to the items read/write/execute privileges for the owner, members of the owners group and all other users. So there's at least a flag that gets set.
I don't know much more than that.

0

I natively run slackware so my command prompt is in color. So blue is folder, red is compressed file, green is executable, white is just a general file (script, or text file.) etc.... If I find myself on another linux platform that doesn't natively differentiate I do "ls --color=always" or "dir --color=always." Don't have much experience with ubuntu or debian, I know it works on redhat and redhat clones. I assume ubuntu or debian isn't much different. You could always ls --help or dir --help it to see how its set up for your flavor.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.