Article

Fire Up your own Linux Server

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Next

A Quick Tour of the Filesystem

The Linux filesystem depicted in Figure 2.13 has a different structure than you're probably used to. Let's look at an outline of the filesystem structure, and explore its various functions and elements.

  • / (The Root Directory) This is the top level of any Linux system, known as the root directory. Unfortunately, there's also a directory named root. Don't worry: we'll explain the difference between these directories—and how to avoid confusion—in a minute.
  • /boot This directory contains all the files necessary to boot the operating system, including the Linux kernel.
  • /bin and /sbin These folders are similar in their contents—they both contain executable binary files—but differ in purpose. /bin contains executables that you're likely to use from the command line: commands such as ls, mv, and cp, which we'll be looking at in Chapter 3, The Command Line, live in this folder. /sbin contains commands and processes that are used by the operating system itself, so it might be best to stay away from this folder if you're just starting out.
  • /dev These are the device files—abstractions of all the devices that are actually in the system, as well as all devices that could be added to the system. These files provide the operating system with a description of, and instructions for handling, each device.
  • /etc This directory contains system-specific configuration files. As an administrator, you're likely to spend quite a bit of time in the /etc directory, because it contains configuration instructions for most of the applications on the system. For example, the configuration file for Apache is located at /etc/httpd/conf/httpd.conf.
  • /home This directory contains the home directories for each user of the system. For instance, our example user has the home directory /home/kermit, and other users on the same system have home directories /home/gonzo and /home/fozzie. By default, Gonzo or Fozzie can't read from or write to Kermit's files, and Kermit can't read from or write to theirs (only the root user has this ability).
  • /root (The root Directory) This is the home directory of the root user, and is not to be confused with the other "root directory", /.
  • /lib The /lib directory contains all the shared libraries that will be accessed by various applications in the system. It also contains libraries that will be used by the kernel in various system operations.
  • /media, /mnt These directories serve as mount points for temporarily mounted filesystems. For example, the CD-ROM drive will be accessible from /media/cdrom.
  • /opt This directory offers storage for packages that have been added to the system.
  • /tmp This directory provides system-wide storage for temporary files.
  • /usr Contains user commands and binaries, graphical interface files, include files for use in system applications, and optional source code files.
  • /var The /var directory contains variable data files: files that may change during the operation of an application with which they're associated, including log files and mailbox files.

Mount Points
The concept of mount points may be a bit confusing, despite their existence in every operating system, including Windows. To avoid confusion, think of mount points as containers into which the contents of a device or filesystem will be emptied. For example, /media/cdrom is a mount point for the contents of the CD-ROM device. Emptying the contents of the device into the mount point makes the files accessible to the system and its users. In general, devices and filesystems must be mounted—attached to a mount point—before they can be used. In a later chapter, we'll discuss a way by which we can mount these devices and filesystems automatically in Linux.

Figure 2.13. The Linux filesystem displaying in the File Browser application.
1505_2.13

Navigating the Filesystem

Navigating the filesystem begins on the desktop with Nautilus, GNOME's graphical representation of the filesystem. There are two icons sitting on the desktop that act as starting points to Nautilus: Computer and username's Home, as shown in Figure 2.14.

Figure 2.14. The desktop filesystem icons.
1505_2.14

The Computer icon begins at the top level of the system, similar to My Computer in Windows; while the username's Home icon begins within the current user's home directory.

Double-clicking the Computer icon presents us with a view similar to that shown in Figure 2.15. We see the removable media attached to the computer, as well as icons representing the root of the local filesystem and any other filesystems to which we have access over the network.

Figure 2.15. The Computer icon's top-level view.
1505_2.15

Double-clicking on the Filesystem icon opens a new window displaying the root directory of the filesystem, as shown in Figure 2.16. Double-clicking any of these icons will open another window, providing a view of the contents of the chosen directory, just like Windows Explorer or Finder on a Mac.

Figure 2.16. Viewing the Computer icon filesystem.
1505_2.16

Double-clicking on the username's Home icon on the desktop will jump straight to the current user's home directory. To start with, the home directory will only contain one visible folder icon, Desktop, as depicted in Figure 2.17.

Figure 2.17. The Home icon view.
1505_2.17

Handling Linux Files

Literally everything in a Linux system is a file, including directories, links, and so on. Even the commands are files, ranging from the simple to the extremely complex. Because of the nature of the Linux system and its files, it's important to understand the processes of file handling and editing on your new system.

In this section, we'll take a quick spin through the file permissions structure, get a grip on the system's ability to link from one file to another, and explore some of the more common text editing applications for Linux. Because everything in Linux is a file, it's very important that you understand how files are accessed and edited. These are skills you'll find yourself using nearly every day.

File Permissions

Linux utilizes one of the most granular file permissions systems of any computer operating system. As we've already seen, that granularity is due, in part, to the fact that everything in Linux is a file. Commands, configurations, device files: all are editable, depending upon who the editing user is, and how the permissions on the file have been set. Accordingly, it's important to understand the permissions structure and how it will affect both your and your users' interaction with system files.

At their most basic, Linux permissions are broken into three sets of permissions. These are:

  • Owner (or user) - The permissions granted to the user who owns the file (usually the user who created the file).
  • Group - The permissions granted to a specified group of users. Users can be added to any number of available groups, each of which can have permissions on files.
  • Other - The permissions granted to anyone who isn't the owner, or a member of a group that has permissions to access the file.

Each of these sets can grant any combination of the following, self-explanatory permissions:

  • read
  • write
  • execute

What's especially interesting in the Linux permissions structure is how these three sets of three permissions interact. A particular user may belong to a group that can only read a particular file, but if that user also happens to be the file's owner, the owner permissions of the file might also grant the user access to write to the file's contents.

As an example, let's look at the default permissions structure of a simple text file. Open the gedit application by choosing Applications > Accessories > Text Editor from the menu. Enter some text into gedit, then save the file in your home directory. Locate the file in Nautilus, right-click on the file, and select Properties. Click the Permissions tab to see the permissions that have been given to the file as shown in Figure 2.18.

Figure 2.18. Default permissions for a text file.
1505_2.18

Let's take an in-depth look at this dialog.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article