Real Files and Virtual Files


Linux sees virtually everything as a series of files. This might sound absurd and certainly requires further explanation.

Let's start with the example of plugging in a piece of hardware. Whenever you attach something to a USB socket, the Linux kernel finds it, sees if it can make the hardware work, and, if everything checks out okay, it will usually make the hardware available as a file under the /dev directory on your hard disk (dev is short for devices). Figure 15-1 shows an example of a /dev directory.

image from book
Figure 15-1. Hardware devices under Linux are accessed as if they were files and can be found in the /dev folder.

The file created in the /dev directory is not a real file, of course. It's a file system shortcut plumbed through to the input and output components of the hardware you've just attached.

Note 

As a user, you're not expected to delve into the /dev directory and deal with this hardware directly. Most of the time, you'll use various software packages that will access the hardware for you, or use special BASH commands or GUI programs to make the hardware available in a more accessible way for day-to-day use.

Here's another example. Say you're working in an office and you want to connect to a central file server. To do this under Linux, you must "mount" the files that the server offers, making it a part of the SUSE Linux file system. Doing this involves creating an empty directory (or using one that already exists) and using the mount command at the BASH shell to make the server's contents magically appear whenever that directory is accessed. We'll discuss how this is done later in this chapter, in the "Mounting" section (but remember that Konqueror will do this automatically, as discussed in Chapter 12).

Once the network server is mounted, it is treated exactly like a directory on your hard disk. You can copy files to and from it, just as you would normally, using the same tools as you use for dealing with any other files. In fact, less knowledgeable users won't even be aware that they're accessing something that isn't located on their PC's hard disk (or, technically speaking, within their SUSE Linux partition and file system).

By treating everything as a file, Linux makes system administration easier. To probe and test your hardware, for example, you can use the same tools you use to manipulate files.

So how do you know which files are real and which are virtual? One method is to use the following command, which was introduced in the previous chapter:

ls -l 

The -l option tells the ls command to list nearly all the details about the files. If you do this in Konsole, you'll see that the listing is color-coded. Table 15-1 shows what each color indicates. The command returns a lot of additional information, including who owns which file and what you and others can do with it. This requires an understanding of users and file permissions, which we'll discuss next.

Table 15-1. Color-Coding Within Konsole

Color

Type of File

Black text

Standard file

Light-blue text

Directory

Black outline with yellow text

Virtual device[1]

Green text

Program or script[2]

Cyan text

Symbolic link to another file[3]

Pink text

Image file

Red text

Archive[4]

[1]This is found only in the /dev directory.

[2]Technically speaking, green text indicates a program or script that has merely been marked as being executable.

[3]This is similar to a Windows desktop shortcut.

[4]Installation files are also marked red because they're usually contained in archives.

Tip 

The command ls -la will give you even more information—perhaps too much for general use. In most instances, ls -l should show enough information.




Beginning SUSE Linux from Novice to Professional
Beginning SUSE Linux: From Novice to Professional
ISBN: 1590594584
EAN: 2147483647
Year: 2005
Pages: 293
Authors: Keir Thomas

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net