3 - Weber State University
3 - Weber State University
3 - Weber State University
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
88 Chapter 3 Exploring Linux Filesystems<br />
An understanding of the structure and commands surrounding the Linux filesystem<br />
is essential for effectively using Linux to manipulate data. In the first part of this chapter,<br />
you explore the Linux filesystem hierarchy by changing your position in the filesystem tree<br />
and listing filenames of various types. Next, you examine the shell wildcard metacharacters<br />
used to specify multiple filenames as well as view the contents of files using standard Linux<br />
commands. You then learn about the regular expression metacharacters used when searching<br />
for text within files, and are introduced to the vi editor and its equivalents.<br />
The Linux Directory Structure<br />
Fundamental to using the Linux operating system is an understanding of how Linux stores<br />
files on the hard drive. Typical Linux systems could have thousands of data and program<br />
files on the hard drive; thus, a structure that organizes those files is necessary to make it easier<br />
to find and manipulate data and run programs. Recall from the previous chapter that Linux<br />
uses a logical directory tree to organize files into different directories (also known as folders).<br />
When a user stores files in a certain directory, they are physically stored in the filesystem of a<br />
certain partition on a hard disk inside the computer. Most people are familiar with the Windows<br />
operating system directory tree structure as depicted in Figure 3-1. Each filesystem on a hard<br />
drive partition is referred to by a drive letter (such as C: or D:) and has a root directory (indicated<br />
by the \ character) containing subdirectories that together form a hierarchical tree.<br />
It is important to describe directories in the directory tree properly; the absolute pathname to a<br />
file or directory is the full pathname of a certain file or directory starting from the root directory.<br />
In Figure 3-1, the absolute pathname for the color directory is C:\windows\color, and the absolute<br />
pathname for the sue directory is D:\home\sue. In other words, we refer to C:\windows\color as<br />
the color directory below the windows directory below the root of the C drive. Similarly, we<br />
refer to D:\home\sue as the sue directory below the home directory below the root of the D drive.<br />
Linux uses a similar directory structure, but with no drive letters. The structure contains a<br />
single root (referred to using the / character), with different filesystems on hard drive partitions<br />
mounted (or attached) to different directories on this directory tree. The directories that<br />
each filesystem is mounted to are transparent to the user. An example of a sample Linux<br />
directory tree equivalent to the Windows sample directory tree shown in Figure 3-1 is depicted<br />
in Figure 3-2. Note that the subdirectory named “root” in Figure 3-2 is different from the root (/)<br />
directory. You’ll learn more about the root subdirectory in the next section.<br />
In Figure 3-2, the absolute pathname for the color directory is /windows/color, and the absolute<br />
pathname for the sue directory is /home/sue. In other words, we refer to the /windows/<br />
system<br />
C:\ D:\<br />
windows root<br />
color<br />
Figure 3-1 The Windows filesystem structure<br />
Source: Course Technology/Cengage Learning<br />
data etc home<br />
mary bob sue<br />
© Cengage Learning. All rights reserved. No distribution allowed without express authorization.