LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "Everything is a file". (https://www.linuxquestions.org/questions/linux-newbie-8/everything-is-a-file-4175434719/)

jayeshsharma52 10-30-2012 03:19 AM

"Everything is a file".
 
When we say that everything is a file in linux what does it basically means,because in windows also we can find a file for everything eg for printer or any device or any log.
Thanks.

acid_kewpie 10-30-2012 03:26 AM

It means that devices live in /dev, memory can be directly access under /proc etc., whereas a windows printer is NOT a file. you can't literally write text to a printer file in windows and see it come out on paper. You really can do this on Linux (echo "THIS IS A TEST" > /dev/lp0) etc. A simpler example is a disk, you can open up /dev/sda1 in a text editor if you so desire and see the raw contents of a disk.

Note though that whilst it's nice to say so, LOADS of things actually aren't files. Like sound and network interfaces in most cases these days (I think)

jayeshsharma52 10-30-2012 03:45 AM

If lets say printer is not a file in windows then how come other programs able to use it?,what do they actually uses to have access on printer?
i.e if I want to use a printer in my program I will have to access printer's device driver.

acid_kewpie 10-30-2012 03:49 AM

*you* don't use the driver, there's no actual file that IS the printer. It disappears into hardware abstraction code and gets dealt with like that. I don't know all that much about how it works, but the basic point here is there is no c:\windows\systems32\davesprinter.prn or something similar.

Actually, there are shitty remnants of this is the DOS environment I believe. On unix you can run "echo TEST > /dev/ttyS0" which would write the word "TEST" to the first serial port, there IS a file at /dev/ttyS0. On windows the same would be "type TEST > COM1" But note here that COM1 is NOT a file. It was just a nasty nasty hack where using the word "COM1" would be arbitrarily pulled out of the ether and sent into the 1st serial port, rather than a file called "COM1"

TobiSGD 10-30-2012 05:25 AM

Quote:

Originally Posted by jayeshsharma52 (Post 4817966)
If lets say printer is not a file in windows then how come other programs able to use it?,what do they actually uses to have access on printer?
i.e if I want to use a printer in my program I will have to access printer's device driver.

You neither access a "printer file" nor the driver directly, you use functions of one of Windows' APIs to print something: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx


All times are GMT -5. The time now is 04:19 PM.