UNIX For Dummies [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

UNIX For Dummies [Electronic resources] - نسخه متنی

John Levine, Margaret Levine Young

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Divide and Conquer

Interestingly, a directory can contain other directories. You may have a directory called Budget , for example, for your departmental budget. The Budget directory may contain several other directories (also called subdirectories) such as Year2003 , Year2004 , and Estimates . If a directory contains so many files that you can’t find things, you should create some subdirectories to divide things up.
Files and directories are stored on hard drive. Every hard drive has a main directory that contains everything on the disk. This directory is called the root directory. The designers of UNIX were thinking of trees here, not turnips. They imagined an upside-down tree with the root at the top and the branches reaching downward, as shown in Figure 6-1. This arrangement of directories is called a tree-structured directory.

Figure 6-1: A tree structured directory.

Strangely, you don’t type root when you’re talking about the root directory. Rather, you press /. Just like that: A single slash means "root" in UNIX-ese.


Paths to power


Unfortunately, UNIX never shows you the directory structure as a nice picture, as shown in Figure 6-1. That would be too easy. Rather, to tell UNIX which file you want to use, you type its pathname. The pathname is the step-by-step map UNIX follows to get to a file, starting at the root. The pathname for the file named freds-04-budget in Figure 6-1, for example, contains these steps:



/ : The root, where you start.



Budget : The name of the first directory you move to on your way to the file.



/ : Confusingly, this slash doesn’t refer to another root; it’s just the character used to separate one name from the next in a pathname.



Year2004 : The next directory on your way to the file.



/ : Another separator character.



freds-04-budget : The filename you want.


When you type this pathname, you string it all together, with no spaces:


/Budget/Year2004/freds-04-budget

Luckily, you don’t often have to type big, long pathnames like this one; it’s devilishly hard to get all that right on the first try!


Family matters


You can also think of the tree structure of directories as a family tree. In this way of thinking, the Year2004 directory is a child of the Budget directory, and the Budget directory is the parent of the Year2004 directory. You see these terms sometimes if you read more about UNIX.


Names for directories


Tip Choose names for directories in the same way as you choose names for files: Avoid funky characters and spaces, and don’t make the name so long that you never type it correctly, for example. Some people capitalize the first letter of directory names to make it easier to tell what’s a directory and what’s a file. When you type ls to list the contents of a directory, the command lists both filenames and the names of subdirectories. When you use capitalization to distinguish between directory names and filenames, you can quickly tell which are which.









Technical Stuff Getting the big picture


If you have a UNIX workstation that’s all your own, most or all of the files on its hard drive are yours. If you connect from a PC and share a UNIX computer with others, the computer’s hard drive has files that belong to all the users. As you can imagine, we are talking about oodles of files. To keep the files — and users! — organized, UNIX has lots of different directories.

UNIX has lots of directories for the UNIX program files themselves, program files for other programs, and other stuff you definitely are not interested in. The files that belong to users (such as yourself) usually are stored in one area. A directory called /usr (or sometimes /home ) contains one subdirectory for every user. If your username is zacyoung , for example, the /usr directory contains a subdirectory called zacyoung , which contains your files.











/ 213