Filesystems, Directories and Devices NHF
ver. 1.0
Written By: 7DS
Introduction
So, you want to learn Linux? Well, it is a rewarding experience, but it
can be complex at times. Coming to Linux from an OS like Windows requires
you to learn not only how to operate, but how to understand what is going
on in your computer. Many people have a good understanding of the
underlying DOS directory structure and how it operates, so switching
between OS's such as NT, W95, and W98 are relatively seamless. However,
Linux demonstrates a new way of thinking for many users.
The purpose of this document, is aimed at introducing users to this new
way of thinking. Once you understand the basics of how files are
manipulated and stored; how devices are used etc, you will find that tasks
in Linux become a lot more straightforward. This is not a comprehensive
documentation, as whole textbooks have been published on this topic,
although some resources on the topic are included.
If you have any constructive feedback, please mail to 7DS
Assumptions:
1. A familiarity with common Operating Systems such as Microsoft
Windows,
and MS-DOS
2. A general knowledge of computing i.e. What a directory is etc.
1. Filesystems and Directory
Structures
For the purposes of this text, the term filesystem refers to an
organization
of files and directories on a storage medium. The bit in which we are
first
going to concentrate on is the organization of these files.
Linux organizes files and directories in a
hierarchical
system, similar to that of Windows and DOS. By this we mean that there
is a root directory, and other directories branch off from that root
directory,
forming a directory tree. That is where the similarities end however.
You know how the root directory in DOS systems is
c:\ ? and how important OS related files are often stored in c:\dos or
c:\windows ? Well, below is an outline of an average Linux system
directories,
and their role in the filesystem:
/ - This is the root directory. the command "cd /" would take you to
the root directory.
/home - user directories are contained in here. If you have some
software
to install, you can safely place it here without worrying about affecting
the system's operational status or procedures.
/etc - contains all the configuration files that affect the system as
a whole. By that I mean that the settings are not user specific, they
apply
universally.
/bin - As the name suggests, the system binaries are stored here. This
includes shells and commands. These binaries are all executable.
/tmp - The systems temporary directory. No files are really kept here
on a permanent basis.
/usr - This contains non-essential programs. These will not affect the
working of your system, but will provide you with the software tools you
require. Sub-directories such as /usr/bin provide similar functions to
their root equivalents.
/var - This directory will contain all the variable files, such as
mail,
error messages, and system logs.
/boot - This contains files related to your computers (or Linux's) boot
sequence.
2. Devices
Devices are not related to filesystems in *nix systems in the same way
as OS's such as DOS. A device can contain a number of filesystems, and
these filesystems can be accessed through linux via a mount point.
The idea is to mount a separate device by
allocating
it to its own directory. For example, to use the floppy device in Linux,
you must mount it to a directory i.e. /floppy. This then makes the
filesystem
contained in the floppy device, to all intents and purposes, part of the
Linux filesystem.
When mounting a device, it is necessary to address
the device itself, for the purpose of giving it a mount point. After that,
you no longer need to worry about what the device it is you are accessing.
Below is a list of example device names under
linux.
These are here to give you a feel for the devices you will be addressing
in Linux, and also give you some common examples of what information you
will need. All devices, are addressed through /dev. They are then further
identified depending on the type of device.
/dev/hda - This is your first device on your primary IDE controller.
numbers can be allocated to identify partitions of this drive. For
example,
/dev/hda2 is the second partition on the primary IDE drive
/dev/hdb2 - Following the logic laid out above, this is the second
partition
on your secondary IDE drive
/dev/fd0 - This is your floppy drive
/dev/ttyS1 - This is the second serial port on your machine. Is known
in DOS as COM2. As you can see, the devices specified do not just stop
at hard disks, and floppy drives, many other peripherals are addressed
in this way.
/dev/hdc - This is the first device on your secondary IDE controller.
this is also a common location for a CD-ROM drive. It is a good idea to
know where your devices are in your computer.
/dev/sda - This is the first device on your SCSI controller.
This can all seem rather overwhelming when comparing this to your
average
Microsoft OS, but it is no different to specifying a:\ or d:\. The
principle
behind it all is the same. The flexibility Linux provides is partially
due to this lower level addressing of devices.
3. Files
Files are very flexible in Linux. There are few restrictions on file
extensions and naming, and they are manipulated in similar ways to other
OS's. For example, you still use "cd" to change directories as you do in
DOS, and the "cp" is used to copy files from one directory to another.
However, a file's properties are a more prominent
issue in Linux. Users, groups (of users), and superusers (root) can all
have different levels of security on a file, making system management and
security an easier task. Each file contains information relevant to who
is allowed to read, write, or execute it.
'Read' permission means you can look at the files
contents, 'Write' permission means you can edit or delete the file, and
'Execute' permission means can run the file as a program. This is
all a good basis for a secure system.
Now for something that might seem a little more confusing.... Linux
(and Unix) considers everything to be a kind of file. Devices included.
It distinguishes these by just associating a type of file to the entity
it is addressing. Therefore a directory is one kind of file, a device is
another kind of file.
Other types of files using the definition above,
includes...
Symbolic Links - These are links which, when accessed, provide the
information
from the file they are linked to. Pretty similar to windows shortcut. You
access the file, and retrieve information from another location.
Pipes - Can be viewed as temporary storage. You can set up a pipe, read
data into it, and then retrieve that exact same information from it. Its
name comes from the analogy that what you put in at one end, is exactly
what emerges at the other end.
As you can see, the filesystem and structure of Linux offers a large
number of possibilities, especially when compared to some other
OS's.
It is important to understand the modus operandi of the filesystem, if
you are to use it to its potential.
Summary
This may seem a little strange, but it is worthwhile spending time
understanding
the principles and workings of Linux, even before you begin using it. As
with anything, a good background knowledge is good, and can even be
essential,
to accomplishing the tasks at hand.
Good sources of information on this topic include:
"Running Linux"
by Matt Welsh and Lar Kaufman, O'Reilly 1996 3rd Edition
This is a highly regarded book by most linux users as a perfect
introduction
to the OS.
http://howto.tucows.com/LDP/HOWTO/Unix-and-Internet-Fundamentals-HOWTO.html
Explains the above in a little more detail, with more technical
references, and includes internet related topics.
|