Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Misc
Reload this Page in linux everything if file
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Misc Any questions or Linux discussion that does not fit in any of the other technical areas.

Reply
 
Thread Tools Display Modes
Old 05-21-2008   #1 (permalink)
Linux Newbie
 
Join Date: Mar 2008
Posts: 166
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
bilal_jan is offline   Reply With Quote
Old 05-21-2008   #2 (permalink)
Linux User
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 279
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!"
hazel is offline   Reply With Quote
Old 05-21-2008   #3 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,153
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:

Quote:
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.
i92guboj is offline   Reply With Quote
Old 05-22-2008   #4 (permalink)
Linux Newbie
 
Join Date: Mar 2008
Posts: 166
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.
bilal_jan is offline   Reply With Quote
Old 05-22-2008   #5 (permalink)
Linux Newbie
 
dxqcanada's Avatar
 
Join Date: Sep 2006
Posts: 132
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" ...
dxqcanada is offline   Reply With Quote
Old 05-22-2008   #6 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,153
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.
i92guboj is offline   Reply With Quote
Old 05-23-2008   #7 (permalink)
Linux Newbie
 
Join Date: Mar 2008
Posts: 166
thanks for the reply
it means that we should avoid logging on with root as in this case vius can trouble linux distribution.
bilal_jan is offline   Reply With Quote
Old 05-24-2008   #8 (permalink)
scm
Linux Engineer
 
Join Date: Feb 2005
Posts: 1,003
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.
scm is offline   Reply With Quote
Old 05-24-2008   #9 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,153
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.
i92guboj is offline   Reply With Quote
Old 05-25-2008   #10 (permalink)
Linux Newbie
 
Join Date: Mar 2008
Posts: 166
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)
bilal_jan is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
 

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 12:16 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0