149 152




Linux Unleashed, Third Edition:Using the File System





-->















Previous
Table of Contents
Next




Chapter 8Using the File System

by Ed Treijs and Tim Parker

In This Chapter
•   Files: an overview
•   Directories: an overview
•   Navigating the Linux file system
•   Creating and deleting files
•   Removing files and directories
•   Important directories in the Linux file system

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 you’ve worked with another operating system such as DOS or Windows, you’ve 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.

Files: An Overview
The most basic concept of a file—and one you may already be familiar with from other computer systems—defines 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.
Common Types of Files
Files can contain various types of information. The following three types will become the most familiar to you on a Linux system:


•  User data: Information that you create and update. The simplest user data is plain text or numbers. You will learn to create these simple files later in this chapter. More complicated user data files might have to be interpreted by another program to make sense. For instance, a spreadsheet file looks like gibberish if you look at it directly. To work with a spreadsheet, you have to start the spreadsheet program and read in the spreadsheet file.
•  System data: Information, often in plain text form, that is read and used by the Linux system—to keep track of which users are allowed on the system, for example. As a system administrator, you are responsible for changing system data files. For instance, when you create a new user, you modify the file /etc/passwd, which contains the user information. Ordinary users of the system are usually not concerned with system data files, except for their private startup files.
•  Executable files: These files contain instructions that your computer can perform. This set of instructions is often called a program. When you tell the computer to perform them, you’re telling it to execute the instructions given to it. To human eyes, executable files contain meaningless gibberish—obviously your computer doesn’t think the way you do! Creating or modifying executable files takes special tools. You learn how to use these programming tools in Part V, “Linux for Programmers.”

While we have decided there are three different types of files, it’s 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 we’ve 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.
Filenames
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 doesn’t 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. There’s nothing to stop you using the long name, though.
Filenames don’t 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














Wyszukiwarka

Podobne podstrony:
149 152
149 Ustawa o us ugach turystycznych
149 ind (3)
23 (152)
152 153
demo cgi 149
149 menu (2)
152 00
Mazowieckie Studia Humanistyczne r2001 t7 n2 s141 152
Nuestro Circulo 149 Claude Shannon
148 149
152 ind (2)

więcej podobnych podstron