Filesystems, Directories and Devices NHF

Here are some explanations on file systems, directories, and devices between windows and Linux which people might not understand the terms and not migrate to Linux for some reason.

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 mac-os, W8, and W10 are relatively seamless. However, Linux demonstrates a new way of thinking for many users.

The purpose 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.


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. Do 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 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 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 on 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 file’s 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, the advice 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 offer 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.