Why can I cat /dev?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I can cat /dev
, I can ls /dev
, I can't less /dev
. Why does cat
let me cat
this directory but no other directories?
linux cat
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
2
down vote
favorite
I can cat /dev
, I can ls /dev
, I can't less /dev
. Why does cat
let me cat
this directory but no other directories?
linux cat
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
What exact OS is this? What exactcat
is this? What is the output ofls -ld /dev
? What is the output (if available) ofLC_ALL=C mountpoint -d /dev
?
– Kamil Maciorowski
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
@KamilMaciorowski, here's the output andneofetch
for your information :) i.imgur.com/3azpnDt.png
– haboutnnah
2 hours ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I can cat /dev
, I can ls /dev
, I can't less /dev
. Why does cat
let me cat
this directory but no other directories?
linux cat
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I can cat /dev
, I can ls /dev
, I can't less /dev
. Why does cat
let me cat
this directory but no other directories?
linux cat
linux cat
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago


haboutnnah
1164
1164
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
haboutnnah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
What exact OS is this? What exactcat
is this? What is the output ofls -ld /dev
? What is the output (if available) ofLC_ALL=C mountpoint -d /dev
?
– Kamil Maciorowski
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
@KamilMaciorowski, here's the output andneofetch
for your information :) i.imgur.com/3azpnDt.png
– haboutnnah
2 hours ago
add a comment |Â
2
What exact OS is this? What exactcat
is this? What is the output ofls -ld /dev
? What is the output (if available) ofLC_ALL=C mountpoint -d /dev
?
– Kamil Maciorowski
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
@KamilMaciorowski, here's the output andneofetch
for your information :) i.imgur.com/3azpnDt.png
– haboutnnah
2 hours ago
2
2
What exact OS is this? What exact
cat
is this? What is the output of ls -ld /dev
? What is the output (if available) of LC_ALL=C mountpoint -d /dev
?– Kamil Maciorowski
3 hours ago
What exact OS is this? What exact
cat
is this? What is the output of ls -ld /dev
? What is the output (if available) of LC_ALL=C mountpoint -d /dev
?– Kamil Maciorowski
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
@KamilMaciorowski, here's the output and
neofetch
for your information :) i.imgur.com/3azpnDt.png– haboutnnah
2 hours ago
@KamilMaciorowski, here's the output and
neofetch
for your information :) i.imgur.com/3azpnDt.png– haboutnnah
2 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
Less is a text file viewer, cat is a tool for copying arbitrary data. So less performs its own checking to make sure you're not opening something that will have massive amounts of data or behave very strangely. On the other hand, cat has no such checking at all – if the kernel lets you open something (even if it's a pipe or a device or something worse), cat will read it.
So why does the OS allow cat to open directories? Traditionally in BSD-style systems all directories could be read as files, and that was how programs would list a directory in the first place: by just interpreting dirent structures stored on disk.
Later on, those on-disk structures began to diverge from the dirent used by the kernel: where previously a directory was a linear list, later filesystems began using hashtables, B-trees, and so on. So reading directories directly wasn't straightforward anymore – the kernel grew dedicated functions for this. (I'm not sure if that was the main reason, or if they were primarily added for other reasons such as caching.)
Some BSD systems continue to let you open all directories for reading; I don't know whether they give you the raw data from disk, or whether they return an emulated dirent list instead, or whether they let the filesystem driver decide.
So perhaps macOS is one of those operating systems where the kernel allows it as long as the filesystem provides the data. And the difference is that /dev
is on a devfs
filesystem that was written to allow this in the early days, while /
is on an APFS filesystem that omitted this feature as unnecessary in modern times.
Disclaimer: I haven't actually done any research on BSDs or macOS. I'm just winging it.
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed/etc
would, so I used that as my benchmark.
– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – runmount
or/sbin/mount
to see what's currently mounted where.
– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
Less is a text file viewer, cat is a tool for copying arbitrary data. So less performs its own checking to make sure you're not opening something that will have massive amounts of data or behave very strangely. On the other hand, cat has no such checking at all – if the kernel lets you open something (even if it's a pipe or a device or something worse), cat will read it.
So why does the OS allow cat to open directories? Traditionally in BSD-style systems all directories could be read as files, and that was how programs would list a directory in the first place: by just interpreting dirent structures stored on disk.
Later on, those on-disk structures began to diverge from the dirent used by the kernel: where previously a directory was a linear list, later filesystems began using hashtables, B-trees, and so on. So reading directories directly wasn't straightforward anymore – the kernel grew dedicated functions for this. (I'm not sure if that was the main reason, or if they were primarily added for other reasons such as caching.)
Some BSD systems continue to let you open all directories for reading; I don't know whether they give you the raw data from disk, or whether they return an emulated dirent list instead, or whether they let the filesystem driver decide.
So perhaps macOS is one of those operating systems where the kernel allows it as long as the filesystem provides the data. And the difference is that /dev
is on a devfs
filesystem that was written to allow this in the early days, while /
is on an APFS filesystem that omitted this feature as unnecessary in modern times.
Disclaimer: I haven't actually done any research on BSDs or macOS. I'm just winging it.
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed/etc
would, so I used that as my benchmark.
– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – runmount
or/sbin/mount
to see what's currently mounted where.
– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
add a comment |Â
up vote
6
down vote
accepted
Less is a text file viewer, cat is a tool for copying arbitrary data. So less performs its own checking to make sure you're not opening something that will have massive amounts of data or behave very strangely. On the other hand, cat has no such checking at all – if the kernel lets you open something (even if it's a pipe or a device or something worse), cat will read it.
So why does the OS allow cat to open directories? Traditionally in BSD-style systems all directories could be read as files, and that was how programs would list a directory in the first place: by just interpreting dirent structures stored on disk.
Later on, those on-disk structures began to diverge from the dirent used by the kernel: where previously a directory was a linear list, later filesystems began using hashtables, B-trees, and so on. So reading directories directly wasn't straightforward anymore – the kernel grew dedicated functions for this. (I'm not sure if that was the main reason, or if they were primarily added for other reasons such as caching.)
Some BSD systems continue to let you open all directories for reading; I don't know whether they give you the raw data from disk, or whether they return an emulated dirent list instead, or whether they let the filesystem driver decide.
So perhaps macOS is one of those operating systems where the kernel allows it as long as the filesystem provides the data. And the difference is that /dev
is on a devfs
filesystem that was written to allow this in the early days, while /
is on an APFS filesystem that omitted this feature as unnecessary in modern times.
Disclaimer: I haven't actually done any research on BSDs or macOS. I'm just winging it.
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed/etc
would, so I used that as my benchmark.
– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – runmount
or/sbin/mount
to see what's currently mounted where.
– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
Less is a text file viewer, cat is a tool for copying arbitrary data. So less performs its own checking to make sure you're not opening something that will have massive amounts of data or behave very strangely. On the other hand, cat has no such checking at all – if the kernel lets you open something (even if it's a pipe or a device or something worse), cat will read it.
So why does the OS allow cat to open directories? Traditionally in BSD-style systems all directories could be read as files, and that was how programs would list a directory in the first place: by just interpreting dirent structures stored on disk.
Later on, those on-disk structures began to diverge from the dirent used by the kernel: where previously a directory was a linear list, later filesystems began using hashtables, B-trees, and so on. So reading directories directly wasn't straightforward anymore – the kernel grew dedicated functions for this. (I'm not sure if that was the main reason, or if they were primarily added for other reasons such as caching.)
Some BSD systems continue to let you open all directories for reading; I don't know whether they give you the raw data from disk, or whether they return an emulated dirent list instead, or whether they let the filesystem driver decide.
So perhaps macOS is one of those operating systems where the kernel allows it as long as the filesystem provides the data. And the difference is that /dev
is on a devfs
filesystem that was written to allow this in the early days, while /
is on an APFS filesystem that omitted this feature as unnecessary in modern times.
Disclaimer: I haven't actually done any research on BSDs or macOS. I'm just winging it.
Less is a text file viewer, cat is a tool for copying arbitrary data. So less performs its own checking to make sure you're not opening something that will have massive amounts of data or behave very strangely. On the other hand, cat has no such checking at all – if the kernel lets you open something (even if it's a pipe or a device or something worse), cat will read it.
So why does the OS allow cat to open directories? Traditionally in BSD-style systems all directories could be read as files, and that was how programs would list a directory in the first place: by just interpreting dirent structures stored on disk.
Later on, those on-disk structures began to diverge from the dirent used by the kernel: where previously a directory was a linear list, later filesystems began using hashtables, B-trees, and so on. So reading directories directly wasn't straightforward anymore – the kernel grew dedicated functions for this. (I'm not sure if that was the main reason, or if they were primarily added for other reasons such as caching.)
Some BSD systems continue to let you open all directories for reading; I don't know whether they give you the raw data from disk, or whether they return an emulated dirent list instead, or whether they let the filesystem driver decide.
So perhaps macOS is one of those operating systems where the kernel allows it as long as the filesystem provides the data. And the difference is that /dev
is on a devfs
filesystem that was written to allow this in the early days, while /
is on an APFS filesystem that omitted this feature as unnecessary in modern times.
Disclaimer: I haven't actually done any research on BSDs or macOS. I'm just winging it.
answered 3 hours ago
grawity
224k34462524
224k34462524
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed/etc
would, so I used that as my benchmark.
– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – runmount
or/sbin/mount
to see what's currently mounted where.
– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
add a comment |Â
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed/etc
would, so I used that as my benchmark.
– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – runmount
or/sbin/mount
to see what's currently mounted where.
– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed
/etc
would, so I used that as my benchmark.– haboutnnah
2 hours ago
This seems to make sense. Are there any other sections of storage that differ from the standard OS filesystem? I assumed
/etc
would, so I used that as my benchmark.– haboutnnah
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – run
mount
or /sbin/mount
to see what's currently mounted where.– grawity
2 hours ago
On the contrary, generally /etc is just a regular folder containing regular files. There may be other virtual filesystems though – run
mount
or /sbin/mount
to see what's currently mounted where.– grawity
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
You're right! See this: i.imgur.com/pcVpo1o.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
This is really neat @grawity, i.imgur.com/8QuR0FK.png
– haboutnnah
2 hours ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
Well, directly reading a disk is fairly normal operation because disks just have a flat structure anyway (this is how you can make an .iso image of a CD).
– grawity
1 hour ago
add a comment |Â
haboutnnah is a new contributor. Be nice, and check out our Code of Conduct.
haboutnnah is a new contributor. Be nice, and check out our Code of Conduct.
haboutnnah is a new contributor. Be nice, and check out our Code of Conduct.
haboutnnah 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%2fsuperuser.com%2fquestions%2f1372086%2fwhy-can-i-cat-dev%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
2
What exact OS is this? What exact
cat
is this? What is the output ofls -ld /dev
? What is the output (if available) ofLC_ALL=C mountpoint -d /dev
?– Kamil Maciorowski
3 hours ago
Looks like macOS to me.
– grawity
3 hours ago
@KamilMaciorowski, here's the output and
neofetch
for your information :) i.imgur.com/3azpnDt.png– haboutnnah
2 hours ago