Why is the first field in 'ls - l' not a 'f' when viewing a file?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question









New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    55 mins ago











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    55 mins ago










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    54 mins ago






  • 1




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    48 mins ago










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    23 mins ago














up vote
2
down vote

favorite
1












When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question









New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    55 mins ago











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    55 mins ago










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    54 mins ago






  • 1




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    48 mins ago










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    23 mins ago












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question









New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.







terminal ls






share|improve this question









New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 37 mins ago





















New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









Monica Heddneck

1113




1113




New contributor




Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Monica Heddneck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    55 mins ago











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    55 mins ago










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    54 mins ago






  • 1




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    48 mins ago










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    23 mins ago
















  • Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    55 mins ago











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    55 mins ago










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    54 mins ago






  • 1




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    48 mins ago










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    23 mins ago















Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
– Sergiy Kolodyazhnyy
55 mins ago





Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
– Sergiy Kolodyazhnyy
55 mins ago













Wow, thanks for the links. Reading now.
– Monica Heddneck
55 mins ago




Wow, thanks for the links. Reading now.
– Monica Heddneck
55 mins ago












Let me know if you have any questions or any parts of the answers need clarification.
– Sergiy Kolodyazhnyy
54 mins ago




Let me know if you have any questions or any parts of the answers need clarification.
– Sergiy Kolodyazhnyy
54 mins ago




1




1




If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
– Wumpus Q. Wumbley
48 mins ago




If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
– Wumpus Q. Wumbley
48 mins ago












Understanding UNIX permissions and file types might be relevant here.
– Stephen Kitt
23 mins ago




Understanding UNIX permissions and file types might be relevant here.
– Stephen Kitt
23 mins ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    27 mins ago










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    25 mins ago










  • A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
    – Sergiy Kolodyazhnyy
    18 mins ago










  • @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    13 mins ago











  • @StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
    – Sergiy Kolodyazhnyy
    11 mins ago

















up vote
0
down vote













In principle, each dash represents a bit, which can only be on or off. In this case, the first bit is the 'directory' bit. If it's 1 (on), then the file is a directory. If it's 0 (off), then the file is a regular file. The same thing goes with permissions. Each dash represents a 0 bit, and each letter represents a 1 bit. It would be fairly easy to change the display from a dash to a letter, but it's more realistic to show the dash instead of a letter because permissions are stored in bit form, where a bit can only be on or off.



As an example:



- --- --- ---



Or:



* *** *** ***



(Stars to represent bits)



Or:



d rwx rwx rwx



1 bit for directory (yes/no).

3 bits for owner permissions (read, write, execute).

3 bits for group permissions.

3 bits for other permissions.






share|improve this answer










New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 1




    A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
    – Sergiy Kolodyazhnyy
    43 mins ago











  • This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
    – Stephen Kitt
    39 mins ago










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470751%2fwhy-is-the-first-field-in-ls-l-not-a-f-when-viewing-a-file%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    27 mins ago










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    25 mins ago










  • A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
    – Sergiy Kolodyazhnyy
    18 mins ago










  • @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    13 mins ago











  • @StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
    – Sergiy Kolodyazhnyy
    11 mins ago














up vote
3
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    27 mins ago










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    25 mins ago










  • A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
    – Sergiy Kolodyazhnyy
    18 mins ago










  • @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    13 mins ago











  • @StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
    – Sergiy Kolodyazhnyy
    11 mins ago












up vote
3
down vote










up vote
3
down vote









Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer














Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.







share|improve this answer














share|improve this answer



share|improve this answer








edited 27 mins ago

























answered 43 mins ago









Stephen Kitt

146k22320386




146k22320386











  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    27 mins ago










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    25 mins ago










  • A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
    – Sergiy Kolodyazhnyy
    18 mins ago










  • @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    13 mins ago











  • @StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
    – Sergiy Kolodyazhnyy
    11 mins ago
















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    27 mins ago










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    25 mins ago










  • A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
    – Sergiy Kolodyazhnyy
    18 mins ago










  • @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    13 mins ago











  • @StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
    – Sergiy Kolodyazhnyy
    11 mins ago















wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
– Monica Heddneck
27 mins ago




wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
– Monica Heddneck
27 mins ago












I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
– Stephen Kitt
25 mins ago




I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
– Stephen Kitt
25 mins ago












A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
– Sergiy Kolodyazhnyy
18 mins ago




A file in computer science is just collection of bytes organized together in some logical form. What normally users think of a "file" is not the same meaning to the computer. So think of it as "collection of bytes". Unix/Linux itself won't really care what particular arrangement of bytes that is, besides the special types relevant to the OS itself - those types that Stephen cited in the answer. Now, special applications, like your desktop environment or GNOME specifically, those additionally will look at the header of file - that's called mime type.
– Sergiy Kolodyazhnyy
18 mins ago












@Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
– Stephen Kitt
13 mins ago





@Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
– Stephen Kitt
13 mins ago













@StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
– Sergiy Kolodyazhnyy
11 mins ago




@StephenKitt Agreed, I probably should have explained that from the magic number, which is the header part.
– Sergiy Kolodyazhnyy
11 mins ago












up vote
0
down vote













In principle, each dash represents a bit, which can only be on or off. In this case, the first bit is the 'directory' bit. If it's 1 (on), then the file is a directory. If it's 0 (off), then the file is a regular file. The same thing goes with permissions. Each dash represents a 0 bit, and each letter represents a 1 bit. It would be fairly easy to change the display from a dash to a letter, but it's more realistic to show the dash instead of a letter because permissions are stored in bit form, where a bit can only be on or off.



As an example:



- --- --- ---



Or:



* *** *** ***



(Stars to represent bits)



Or:



d rwx rwx rwx



1 bit for directory (yes/no).

3 bits for owner permissions (read, write, execute).

3 bits for group permissions.

3 bits for other permissions.






share|improve this answer










New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 1




    A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
    – Sergiy Kolodyazhnyy
    43 mins ago











  • This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
    – Stephen Kitt
    39 mins ago














up vote
0
down vote













In principle, each dash represents a bit, which can only be on or off. In this case, the first bit is the 'directory' bit. If it's 1 (on), then the file is a directory. If it's 0 (off), then the file is a regular file. The same thing goes with permissions. Each dash represents a 0 bit, and each letter represents a 1 bit. It would be fairly easy to change the display from a dash to a letter, but it's more realistic to show the dash instead of a letter because permissions are stored in bit form, where a bit can only be on or off.



As an example:



- --- --- ---



Or:



* *** *** ***



(Stars to represent bits)



Or:



d rwx rwx rwx



1 bit for directory (yes/no).

3 bits for owner permissions (read, write, execute).

3 bits for group permissions.

3 bits for other permissions.






share|improve this answer










New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 1




    A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
    – Sergiy Kolodyazhnyy
    43 mins ago











  • This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
    – Stephen Kitt
    39 mins ago












up vote
0
down vote










up vote
0
down vote









In principle, each dash represents a bit, which can only be on or off. In this case, the first bit is the 'directory' bit. If it's 1 (on), then the file is a directory. If it's 0 (off), then the file is a regular file. The same thing goes with permissions. Each dash represents a 0 bit, and each letter represents a 1 bit. It would be fairly easy to change the display from a dash to a letter, but it's more realistic to show the dash instead of a letter because permissions are stored in bit form, where a bit can only be on or off.



As an example:



- --- --- ---



Or:



* *** *** ***



(Stars to represent bits)



Or:



d rwx rwx rwx



1 bit for directory (yes/no).

3 bits for owner permissions (read, write, execute).

3 bits for group permissions.

3 bits for other permissions.






share|improve this answer










New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









In principle, each dash represents a bit, which can only be on or off. In this case, the first bit is the 'directory' bit. If it's 1 (on), then the file is a directory. If it's 0 (off), then the file is a regular file. The same thing goes with permissions. Each dash represents a 0 bit, and each letter represents a 1 bit. It would be fairly easy to change the display from a dash to a letter, but it's more realistic to show the dash instead of a letter because permissions are stored in bit form, where a bit can only be on or off.



As an example:



- --- --- ---



Or:



* *** *** ***



(Stars to represent bits)



Or:



d rwx rwx rwx



1 bit for directory (yes/no).

3 bits for owner permissions (read, write, execute).

3 bits for group permissions.

3 bits for other permissions.







share|improve this answer










New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited 21 mins ago





















New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 47 mins ago









wispi

123




123




New contributor




wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






wispi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
    – Sergiy Kolodyazhnyy
    43 mins ago











  • This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
    – Stephen Kitt
    39 mins ago












  • 1




    A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
    – Sergiy Kolodyazhnyy
    43 mins ago











  • This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
    – Stephen Kitt
    39 mins ago







1




1




A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
– Sergiy Kolodyazhnyy
43 mins ago





A single bit doesn't explain why you can have s for sockets and l for sym links. so it's not exactly true/false type of info
– Sergiy Kolodyazhnyy
43 mins ago













This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
– Stephen Kitt
39 mins ago




This is wrong: regular files do have a bit set; S_IFREG is 0100000 octal. See man 7 inode for details.
– Stephen Kitt
39 mins ago










Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.












Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.











Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470751%2fwhy-is-the-first-field-in-ls-l-not-a-f-when-viewing-a-file%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

What does second last employer means? [closed]

One-line joke