What is file-like objects in linux?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Linux Philosophy
Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.
Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.
linux ubuntu files filesystems
add a comment |Â
up vote
0
down vote
favorite
Linux Philosophy
Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.
Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.
linux ubuntu files filesystems
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Linux Philosophy
Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.
Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.
linux ubuntu files filesystems
Linux Philosophy
Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.
Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.
linux ubuntu files filesystems
asked Jan 13 at 9:46
coding_ninza
33
33
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.
Processes:
Each process has its folder /proc/$PPID/
, where $PPID
is the process id. You can find the command line for the process in /proc/$PPID/cmdline
, for example.
Devices:
Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda
and the first partition as /dev/sda1
. So if you read from /dev/sda
you are actually reading the raw data on the disk. This can be useful when making an image.
Network sockets:bash
uses /dev/tcp/$host/$port
to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp
Others:
Standard input is also a file and you can find it in /dev/stdin
, similar for standard output. You can read from the file /dev/zero
to get zeros and from /dev/random
to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.
The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.
Processes:
Each process has its folder /proc/$PPID/
, where $PPID
is the process id. You can find the command line for the process in /proc/$PPID/cmdline
, for example.
Devices:
Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda
and the first partition as /dev/sda1
. So if you read from /dev/sda
you are actually reading the raw data on the disk. This can be useful when making an image.
Network sockets:bash
uses /dev/tcp/$host/$port
to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp
Others:
Standard input is also a file and you can find it in /dev/stdin
, similar for standard output. You can read from the file /dev/zero
to get zeros and from /dev/random
to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.
The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.
add a comment |Â
up vote
4
down vote
accepted
They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.
Processes:
Each process has its folder /proc/$PPID/
, where $PPID
is the process id. You can find the command line for the process in /proc/$PPID/cmdline
, for example.
Devices:
Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda
and the first partition as /dev/sda1
. So if you read from /dev/sda
you are actually reading the raw data on the disk. This can be useful when making an image.
Network sockets:bash
uses /dev/tcp/$host/$port
to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp
Others:
Standard input is also a file and you can find it in /dev/stdin
, similar for standard output. You can read from the file /dev/zero
to get zeros and from /dev/random
to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.
The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.
Processes:
Each process has its folder /proc/$PPID/
, where $PPID
is the process id. You can find the command line for the process in /proc/$PPID/cmdline
, for example.
Devices:
Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda
and the first partition as /dev/sda1
. So if you read from /dev/sda
you are actually reading the raw data on the disk. This can be useful when making an image.
Network sockets:bash
uses /dev/tcp/$host/$port
to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp
Others:
Standard input is also a file and you can find it in /dev/stdin
, similar for standard output. You can read from the file /dev/zero
to get zeros and from /dev/random
to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.
The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.
They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.
Processes:
Each process has its folder /proc/$PPID/
, where $PPID
is the process id. You can find the command line for the process in /proc/$PPID/cmdline
, for example.
Devices:
Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda
and the first partition as /dev/sda1
. So if you read from /dev/sda
you are actually reading the raw data on the disk. This can be useful when making an image.
Network sockets:bash
uses /dev/tcp/$host/$port
to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp
Others:
Standard input is also a file and you can find it in /dev/stdin
, similar for standard output. You can read from the file /dev/zero
to get zeros and from /dev/random
to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.
The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.
edited Jan 13 at 10:30
answered Jan 13 at 10:16
Weijun Zhou
1,434119
1,434119
add a comment |Â
add a comment |Â
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%2f416778%2fwhat-is-file-like-objects-in-linux%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