-->
Previous | Table of Contents | Next |
by Ed Treijs and Tim Parker
To understand how Linux works and to use the system beyond a superficial level, you must be familiar with the Linux notion of files and the file system into which they are organized. If youve worked with another operating system such as DOS or Windows, youve already seen these concepts because both operating systems base their approach for files, directories, and file systems on UNIX. As you will see, there is a lot more flexibility in the way UNIX and Linux handle file systems than the rather strict and limited way both DOS and Windows manage them.
The most basic concept of a fileand one you may already be familiar with from other computer systemsdefines a file as a distinct chunk of information that is found on your hard drive. Distinct means that there are many separate files, each with its own particular contents. To keep files from getting confused with one another, every file must have a unique identity. In Linux, you identify each file by its name and location. In each location or directory, there can be only one file by a particular name. So, for instance, if you create a file called novel, and you get a second great idea, either you will have to call it something different, such as novel2, or put it in a different directory to prevent overwriting the contents already in your original novel.
Files can contain various types of information. The following three types will become the most familiar to you on a Linux system:
While we have decided there are three different types of files, its important for you to realize that there is no difference between the type of files as far as the Linux file system is concerned. Each file is a chunk of data on the disk drives that contains information. What is inside each file is irrelevant to Linux until you try to use the file. The bash shell that weve been using, for example, can run any executable file, but may not be able to figure out what kind of data is in the user or system data files. The contents of the file are relevant only to the application that uses them, not to Linux as an operating system. The only exception to this general statement are the system data files that Linux uses when starting and running the system. In this case, Linux knows how to read the contents of the files itself.
Linux allows filenames to be up to 256 characters long. These characters can be lower- and uppercase letters, numbers, and other characters, usually the hyphen (-), the underscore (_), and the period (.). While Linux allows you to use 256 characters in a filename, there are two things to bear in mind.
First, not all the characters are significant. If you have two filenames both 250 characters long which differ only in the last (250th) character, to Linux the files have the same name. This is because Linux takes only the first 32 or 64 characters of the filename (depending on the version of Linux) as significant. The rest of the filename is there for your convenience, and Linux keeps track of the information, but usually doesnt consider the rest of the characters after the 33rd or 65th as important for its own uses.
Secondly, remember that you have to type all those long names. Sure, you can call a file by a name 256 characters long, but you also have to type it when you want access to the file (unless you use metacharacters or wildcards). Common sense indicates you should use reasonably short, descriptive filenames. If your file contains statistical data for January, you can call the file Jan_stats or simply data_Jan, which is a heck of a lot easier to type than the filename statistical_data_for_January. Theres nothing to stop you using the long name, though.
Filenames dont normally include reserved metacharacters such as the asterisk, question mark, backslash, and space because these all have meaning to the shell. We met some metacharacters when we discussed wildcards in the previous chapter. Other metacharacters will be introduced in the Linux shell chapters. (It is possible to create files that have metacharacters in them but they tend to pose problems for the operating system and applications.)
Previous | Table of Contents | Next |