Find the answer to your Linux question:
Results 1 to 10 of 10
i read once on a site that Code: in linux everything is file,if it is not a file it is a process i am not getting what this phrase means. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User bilal_jan's Avatar
    Join Date
    Mar 2008
    Location
    Pakistan
    Posts
    281

    in linux everything if file


    i read once on a site that
    Code:
    in linux everything is file,if it is not a file it is a process
    i am not getting what this phrase means.
    secondly is this an advantage of linux that here everything is file and how does this differ from windows
    thanks

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,217
    Quote Originally Posted by bilal_jan View Post
    i read once on a site that
    Code:
    in linux everything is file,if it is not a file it is a process
    i am not getting what this phrase means.
    secondly is this an advantage of linux that here everything is file and how does this differ from windows
    thanks
    What that means is that Linux treats hardware devices as files and Windows doesn't. Every device has a file corresponding to it (you'll find them in the /dev directory) and a program can open this file and read from or write to it just like with any other file. Each time that happens, the kernel intervenes and writes to/reads from the hardware, then passes back the result to the program. Which is a huge advantage if you are writing programs because you don't need to know how to actually access the hardware.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by bilal_jan View Post
    i read once on a site that
    Code:
    in linux everything is file,if it is not a file it is a process
    i am not getting what this phrase means.
    secondly is this an advantage of linux that here everything is file and how does this differ from windows
    thanks
    The second part of that statement is false. The correct statement is:

    In linux, everything is a file
    You just have to look at /proc to see the processes there as well:

    Code:
    # ls /proc/
    1      20087  242    3725  3847  4131  912        driver       mtrr
    174    20088  243    3737  3868  4135  914        execdomains  net
    175    20093  244    3779  3870  4137  9325       filesystems  pagetypeinfo
    176    20094  2474   3781  3886  4141  9326       fs           partitions
    182    20097  27541  3782  3887  4145  9367       interrupts   self
    185    20098  27551  3784  3888  4175  9368       iomem        slabinfo
    196    20099  27554  3804  3889  4191  9370       ioports      stat
    19652  20113  27556  3805  3890  4193  969        irq          swaps
    197    22576  27558  3806  3916  4280  acpi       kallsyms     sys
    2      22600  27560  3810  3917  4796  asound     kcore        sysrq-trigger
    20078  22606  27565  3811  3933  5     buddyinfo  kmsg         sysvipc
    20079  2378   27574  3812  3934  5027  bus        kpagecount   timer_list
    20080  2379   27959  3813  3945  5030  cmdline    kpageflags   tty
    20081  2380   27988  3814  3946  68    config.gz  loadavg      uptime
    20082  2381   3      3815  3947  69    cpuinfo    locks        version
    20083  2382   3683   3816  4     70    crypto     meminfo      vmstat
    20084  239    3684   3817  4011  8928  devices    misc         zoneinfo
    20085  240    3690   3818  4012  893   diskstats  modules
    20086  241    3699   3839  4016  895   dma        mounts
    All those numbers are the PIDs (process identification numbers) on my system right now.

    The meaning of those words is very simple: anything that is physically or logically attached to your machine, and that the linux kernel can see, is represented as a file in your file system.

    For example, your hard disks will be files into /dev, like /dev/hda, or /dev/sdb. The partitions will also be files there: /dev/sda1, /dev/sda2... And so on.

    The processes, your cpu, your ram, even your linux kernel memory can be viewed as files under the /proc directory. Anything, from processes, hardware, disks, sound cards, scannes, usb or com ports, modems,... anything, is a file somewhere on your file system.

    That why, in linux, you can format a partition, but you can also format a file and mount it as it was a hard disk, because ultimately, linux makes very little -if any- distinctions. The real nature of the device doesn't really matter. That's one of the wonderful things in linux, you really don't have to worry about the nature of the things, so you can concentrate on getting the job done.

    It's just like beer. Some people love it, some people hate it.

  4. #4
    Linux User bilal_jan's Avatar
    Join Date
    Mar 2008
    Location
    Pakistan
    Posts
    281
    thanks hazel and i92guboj for ur worthy replies they are very usefull.
    i have learned that whether it is process or it is hardware they are all treated as file in linux.
    another question is that does this feature(that in linux everything is a file) of Linux was the reason that linux has no VIRUS.

  5. #5
    Linux User dxqcanada's Avatar
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    259
    That statement should be corrected:

    In Unix/Linux/BSD, there are only files or process's



    Men occasionally stumble over the truth,
    but most of them pick themselves up
    and hurry off as if nothing had happened.

    Winston Churchill


    ... then the Unix-Gods created "man" ...

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by bilal_jan View Post
    thanks hazel and i92guboj for ur worthy replies they are very usefull.
    i have learned that whether it is process or it is hardware they are all treated as file in linux.
    another question is that does this feature(that in linux everything is a file) of Linux was the reason that linux has no VIRUS.
    That's inaccurate. There are viruses for every OS under the sun, though admittedly, the panacea for them is Windows. The whole point of unix and it's clones (linux amongst them) is that the user doesn't have god-like powers. In other words: you can only write in your home dir. So, if you get a virus on your mail box and accidentaly run it (it has to be executable on linux, which is another barrier) at most, it can compromise the data in your home dir, but nothing else. This is why I advise to run wine as a separate user, by the way.

    Note also that 99% of the windows virus come the same way: via a vulnerability in IE (don't you love activeX? :P ). Since we don't use dumb things like activex on linux, that's another wall. Denying exec permissions to javascript globally also help. Smart users only enable it on trusted sites. Anyway, most viruses are just product of script kiddies which use windows exclusive stuff like activex or vbscript and the like, so, even if we enable some malicious javascript on linux by accident, most times there will be no negative effect.

    Of course, that's just plainly circumstantial. I mean: there's nothing stopping the people from programming more linux viruses (even if it's just to foobar your home dir only). The only limiting factors there are the quality of the clients (browsers, MTA's etc) and the ignorance of those script kiddies who make silly viruses for windows and IE.




    Quote Originally Posted by dxqcanada View Post
    That statement should be corrected:

    In Unix/Linux/BSD, there are only files or process's
    As I already mentioned above, processes are seen as files too under /proc/<pid_number>. So, they are files as well in a sense.

  7. #7
    Linux User bilal_jan's Avatar
    Join Date
    Mar 2008
    Location
    Pakistan
    Posts
    281
    thanks for the reply
    it means that we should avoid logging on with root as in this case vius can trouble linux distribution.

  8. #8
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by bilal_jan View Post
    thanks for the reply
    it means that we should avoid logging on with root as in this case virus can trouble linux distribution.
    Not really, it means you shouldn't run user programs that connect to the outside world (mail clients, browsers, etc) as root.

  9. #9
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by bilal_jan View Post
    thanks for the reply
    it means that we should avoid logging on with root as in this case vius can trouble linux distribution.
    If you are root, the virus is root as well.

  10. #10
    Linux User bilal_jan's Avatar
    Join Date
    Mar 2008
    Location
    Pakistan
    Posts
    281
    most of viruses are written for Windows and windows EXEs do not run on LINUX thats why Linux cant be infected with viruses!!!
    i have tried alot to install a multimedia on Ubuntu but i failed,it is very difficut to install softwares on linux as conmaped to "NEXT-------NEXT --- FINISH"(i am refering to windows)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •