Why is the first field in 'ls - l' not a 'f' when viewing a file?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
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
New contributor
add a comment |Â
up vote
2
down vote
favorite
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
New contributor
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
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
New contributor
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
terminal ls
New contributor
New contributor
edited 37 mins ago
New contributor
asked 1 hour ago
Monica Heddneck
1113
1113
New contributor
New contributor
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
add a comment |Â
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
add a comment |Â
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:
s
: file is small (smaller than 4096 bytes)l
: file is large
d
: file is a directoryx
: file is executableu
: 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.
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
 |Â
show 2 more comments
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.
New contributor
1
A single bit doesn't explain why you can haves
for sockets andl
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. Seeman 7 inode
for details.
â Stephen Kitt
39 mins ago
add a comment |Â
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:
s
: file is small (smaller than 4096 bytes)l
: file is large
d
: file is a directoryx
: file is executableu
: 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.
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
 |Â
show 2 more comments
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:
s
: file is small (smaller than 4096 bytes)l
: file is large
d
: file is a directoryx
: file is executableu
: 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.
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
 |Â
show 2 more comments
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:
s
: file is small (smaller than 4096 bytes)l
: file is large
d
: file is a directoryx
: file is executableu
: 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.
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:
s
: file is small (smaller than 4096 bytes)l
: file is large
d
: file is a directoryx
: file is executableu
: 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.
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
 |Â
show 2 more comments
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
 |Â
show 2 more comments
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.
New contributor
1
A single bit doesn't explain why you can haves
for sockets andl
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. Seeman 7 inode
for details.
â Stephen Kitt
39 mins ago
add a comment |Â
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.
New contributor
1
A single bit doesn't explain why you can haves
for sockets andl
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. Seeman 7 inode
for details.
â Stephen Kitt
39 mins ago
add a comment |Â
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.
New contributor
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.
New contributor
edited 21 mins ago
New contributor
answered 47 mins ago
wispi
123
123
New contributor
New contributor
1
A single bit doesn't explain why you can haves
for sockets andl
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. Seeman 7 inode
for details.
â Stephen Kitt
39 mins ago
add a comment |Â
1
A single bit doesn't explain why you can haves
for sockets andl
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. Seeman 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
add a comment |Â
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.
Monica Heddneck is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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