COMPS [ Under OPL ]  

The Structure of Linux


Wireless LANs
Sawfish on RH8
Why C++





Yahoo! Search

Search This Site
Search WWW

Hold mouse over words above for more information.

Made with Emacs

Get Firefox!

[ Up ] [ Introduction ] [ The Structure of Linux ] [ Common Linux Applications ] [ References ]

  1. The Linux kernel
  2. The File-system organization
  3. The multi-user concept
  4. The GUI system
    • The X Server and the client/server model, xlib
    • The Window Managers, Enlightenment
    • The Desktop Environment, GNOME 1.2, GTK+

1. The Linux kernel

The Linux kernel is a marvel of a designer's vision of continuing development. Since it's early stages of development many designers were involved in a way that they only communicated electronically. This called for minimum useless interaction between the (loose) team and thus the Linux Kernel was designed with easy modifiability as one of the prime goals.

One of the greatest advantages of Linux Kernel is it's modular structure. Most of the Linux kernel is built as a collection of source modules. The required modules are compiled together while the kernel is being built. But that's not all. The Linux kernel has the ability to load and unload the modules according to the requirement on the fly without the requirement of system shutdowns. That is the reason why the Linux kernel is a Dynamic Kernel. This is the reason why Linux can run on such a wide variety of hardware platforms. A developer has only to port the machine specific modules to support new hardware.

The Linux kernel structure

As seen in the image above, the Linux Kernel consists of five components:

  • The Process Manager (Scheduler): This is the component that handles the Process Scheduling and accounting information. It also has real-time process management capability, thus making Linux a Soft Real-Time System. The Process Manager also has the capability for Symmetric Multi-Processing and, as an example, it can control up to 16 Intel 32bit CPUs, which is the maximum possible on Intel architecture. The Linux kernel, by default, spawns threads, instead of full-blown processes, that have a unique Process ID (PID) and other identification information but share the parent's address-space. As soon as the child tries to write in the parent's address space, a new copy of the parent's memory is generated and the child is allotted that new address space. This is known as copy-on-write. This technique is especially useful in boosting performance of non-waiting servers.
  • The Memory Manager: The Memory manager handles the Virtual Address Space and handles the job of mapping the Virtual Memory Addresses to the Real Memory Addresses. It also handles requests for run-time memory allocation
  • VFS: VFS (Virtual File System) is a layer that sits between the kernel and the file-system drivers. This makes adapting the Linux kernel to any file-system extremely easy. All that a developer has to do is write a file-system driver that provides services required by VFS and compile it into the rest of the kernel.
  • Network Interface: This is the component that enables the Linux kernel to talk to the world. Internally, the communication is handled by BSD Sockets.
  • IPC Interface: This is the part that is responsible for Inter-Process Communication inside the Linux system. The Linux kernel, by default, supports the Sys V IPC, BSD IPC and POSIX IPC mechanisms but any of these can be turned off at build-time.

On top of these five components comes the System Call Interface that hides the hardware layer for the user applications.

2. The File-System Organization

In Linux (and Unix), everything is a file. Rather, everything is mapped by the system on to a file. Thus, a hard-disk partition is one file, an SVGA terminal is another, a semaphore for IPC is still another and so on. The Linux file-system structure is like a tree with the root Directory (Windows Folder == Linux Directory) being denoted as '/'. The entire system resides under this root directory. The delimiter for directories is '/' instead of '\' in DOS and Windows. In the beginning there was '/'. Then Bill Gates came and in his quest for Dollars got it all wrong - thus the '\'!

There are several well defined subdirectories of / that are designed to serve specific purposes. Nothing restrictive here, just a matter of discipline and uniformity. Let us briefly explore the structure now. Running ls / reveals the following sub-directories:

bin    boot    dev    etc    home    lib    lost+found    misc    mnt
opt    proc    root    sbin    tmp    usr    var 

/bin: This directory contains many basic Unix commands like ls, vi, cp, login, mv etc.

/boot: This contains the binaries required to boot up a Linux system. It is usually (but not always) mounted as a separate 16 MB partition on the hard-disk.

/dev: This contains all the devices mapped to the files in this sub-directory. For example, IDE hard-disks partitions are listed as yz, where y is a letter representing the drive and z is the partition number. Thus /dev/hdb3 represents the 3rd partition on the second (b) disk. Similarly, tty is used to denote terminals, fdx for floppies, ttys for serial ports etc.

/etc: This directory tree contains the configuration files for various system programs and services. For example, /etc/fstab contains information of the various file-systems and their mount-points (directories on to which they are mapped), the directory /etc/skel contains the configuration files that are copied by default into the personal directory of a newly added user, and so on

/home: This is the directory tree under which all the users get their personal writeable space. A user Joe, for example, would have /home/Joe for his personal directory. Similarly for other users.

/lib: This contains lots of dynamically loadable shared libraries.

/lost+found: This directory is created by the system on every partition to store recovery data from a disk check after a file-system corruption.

/misc: This is meant for miscellaneous purposes and is usually empty (big deal!)

/mnt: This directory is used to serve as the mount point for various removable devices like floppies and cd-roms. /mnt/cdrom, for example, is the place where you should look to see what's on the CD-ROM you just inserted.

/opt: This directory is meant to install additional software that you might be installing for trial or testing purposes etc.

/proc: This directory is mapped not to a storage device but to the process manager and memory manager of the kernel. It contains dynamically updated files that stay on the RAM and are updated with information about the running environment (RAM usage, processor load etc.) but some static data is also stored here like /proc/cpuinfo stores information about the CPU, like it's clock speed, cache size, whether fpu is present etc.

/root: This is the personal directory of the root user.

/sbin: This is the directory containing critical system commands like fsck, lilo, mkfs etc. It does not lie in the default command search path of normal users.

/usr: This is the directory where all the Linux programs, libraries, documentation and sharable data and more reside. On an application server, this would be the largest directory.

/tmp: This directory is used to store temporary data, lock files etc.

/var: This directory contains all the data that is supposed to be changing dynamically

There are distinct advantages of this kind of a layout. The most obvious is the fact that it is very easy to present the user with a transparent interface to a distributed computing system. Thus, the personal directory of Joe, /home/joe, might be on a file-server that is mapped to the directory /home, the /usr directory might be connected to an application server and so on. Another advantage of this system is that the "files" are just not there in name. You can use the same read() and write() system calls to read from and print to a character terminal, send output to a remote printer, exchange data with another computer thousands of miles away - whatever!

3. The multi-user concept

The multi-user concept is something that will be alien to someone who has never worked on an environment other that Windows. Windows NT/2000 is a single-user Operating System. This means that at a time only one user can be using a running instance of WinNT.

Now you would say that we can login to a WinNT server through telnet etc. Yes, you can but that is not multi-user. You are connecting to a service (telnet daemon) that is running on the server. On that server, you are not working, it is the telnet daemon that is working for you. To make things more clear, suppose you have a WinNT/2000 workstation connected to another one. There is Microsoft Office Suite installed on the other machine but not on yours. Can you work on MS Word on that machine by logging in through yours? The simple answer is - no. There are some workarounds (RDP etc.) that enable this kind of functionality but it piles up an extra layer of abstraction and you still have to have Windows on the remote machine.

Linux is a multi-user OS. That is, a running instance of Linux can support multiple users logged on to it merrily doing their job, without probably being aware of others. They can be aware if they know they're supposedly working on a shared system ;-)

The immediate advantage of this additional feature (is there a better word for a majorly useful feature?) is that a Linux system can function in a distributed environment. Take for instance a simple office intranet. We have Windows NT/2000 workstations networked together. Each has it's own installed programs and user files. Now, suppose I am involved with two projects simultaneously. One requires software A on machine M1 and the other requires software B on machine M2. Can you see any redundancy here? Well, I have user accounts on two machines so my personal settings are stored twice - most probably they will be identical (I can't be liking blue on one machine and gray on the other, can I?). I'll be surfing the Net, off and on, so I have Internet cache files on both machines - images from frequently visited sites would be duplicated again, some personal data may also be duplicated, and so on. Think of a huge software suite, say, a DBMS development and administration package eating up 1 GB, that everyone in the office needs. It's got to be installed on n number of machines, out of which n - 1 are duplicates - for 18 people that is 17 GB of wasted space for a single suite!

The Linux way of doing it? Well, we have an application server with all the software we ever need installed on it. A print server could handle the print jobs - it could even handle several different printers simultaneously and try to do job scheduling too, in case they are identical. A file server can contain our personal directories. Internet cache and personal settings are stored in a user's personal directory only, by the way. We may also create and delete (work)groups and their files would also be on the same file server. Every user has a cheap diskless SVGA terminal with a little RAM (XF86 SVGA server requires ~ 10M, so 32MB RAM may be good enough) that is connected to the servers. Nobody is tied down to a terminal - all data and programs reside on the servers and every terminal (should) connects equally well to them. It's marvelous! Note that the above mentioned Servers may be a single high-capacity machine or each server in turn could be several machines working together - that's the spirit of distributed computing!

4. The GUI System

The greatest misconception about Linux that people I have come across have is that Linux (and UNIX) do not have a GUI. To admit it, till a few years back I used to think that UNIX is a non-GUI OS while Linux is UNIX + GUI! This is as far from the truth as anything possibly can be. To put it straight, GUI was not invented by Microsoft and Apple was offering GUI on its Macs much earlier than Windows 3.x. Also, UNIX has had GUI ever since the word GUI became en-vogue.

Linux GUI is based on a client-server model that gives it a wide range of operational flexibility. Detaching GUI from the basic OS gives you the advantage of having the latest version of the OS on limited-resource systems too. So while Windows Me can't run on systems having less than 64 MB RAM, you can have the latest release of Linux running happily on a 486 with 16 MB RAM in GUI mode! It also facilitates remote usage in a server(s) - terminal environment.

The Linux GUI system is a 3 layered one. Every terminal running Linux in GUI mode has an X Server running in its memory. This thing is responsible for putting the pixels on to the screen and handling the keyboard and mouse. On top of the X Server is a Window Manager. The Window Manager (obviously) does the job of handling windows, menus and their appearance. In addition to that, it is also responsible for handling Desktop Shortcut Keys. By far, the Window Manager has the greatest impact on the appearance of your GUI. Finally, we have the Desktop Environment. Desktop Environment is the set of Programs that enhance desktop utility, for example a file manager, and control the appearance of stuff that is inside the windows - buttons, toolbars etc. This three-layer approach offers a lot of choices by way of various combinations of the three. Getting a feeling of the richness of the Linux GUI? Let's explore.

The X Server

The X Server is the most important part of the Linux GUI as it is the software that interacts directly with the hardware. The Client-Server architecture allows the use applications directly off an application server on completely heterogeneous machines. This is especially useful in distributed environments because whichever terminal you site on, you'll get to see the graphics exactly as you like them. The basic engine behind this client-server model is xlib, a set of API and shared libraries that allows a developer to write applications for the display, without bothering about the underlying hardware.

There are several X servers available in the market but the default X Server for almost all the Linux distributions is XFree86. XFree86 is an Open Source X Server and supports a very wide range of hardware. It can support all the standard CRT Monitors as well as LCD Screens etc. On PCs, it can do up to 32 bit (4.3 billion) colors at a maximum resolution of 3200x3200 pixels. The top-end systems today run on 24/32 bit colors at a resolution of 1280x960 pixels even on 17" monitors. Good support is available for TrueType, Type1 and Web Fonts and since XFree86 4.2, Anti-aliasing (smoothing of the edges) of fonts is also possible. It can also handle most of the common keyboards and advanced pointing devices like PS/2 scroll-mice, trackballs and graphical tablets.

Some of the distinguishing features of the XF86 Server are the ability to draw a virtual screen that is many times larger that you real screen (up to 3200x3200 pixels - over 21 times the area of a standard 800x600 pixel display). Another feature I like very much is that text once selected is automatically put into the clipboard (no Ctrl+c or right-click > Copy needed). To paste it, all that is needed is the click of the middle button in the right place. Think of the number of saved mouse-clicks. Oh! your mouse doesn't have a middle button? No problems, you can ask XF86 to emulate the middle button by recording simultaneous right and left clicks as a middle click.

The Window Manager

The Window Manager is what contributes greatly to the appearance of your GUI as it is responsible for drawing and controlling the windows and menus. There are many window managers available for Linux and your choice of one may depend on the factors of memory consumption, appearance and richness of features. For example, TWM is a small and very fast window manager that packs just the bare minimum functionality. On the other hand, Enlightenment (my ex-favorite), Sawfish and KDE Window Manager are a little bulkier ( ~ 2 - 3 MB) for the memory to carry, but in return offer a tide of features and lots of easily configurable preferences. A good list of Window Managers can be found at http://www.plig.org/xwinman/. I'll discuss Enlightenment now on. Here are a few top features that bring MS Windows down to its feet:

  • Shaped Window Decorations: Unlike MS Windows, you get 3D Window decorations that have shapes. Your Title bar may have curved edges and the window-buttons may appear sitting separately on top. Their shapes too could be anything - round, oval, shaped according to function etc. The Title-bars usually glow when active. Ditto with mouse over on buttons.
  • Multiple Desktops: You can have not one but multiple desktops running at once - each with its own windows and applications. It's like working on many different computers at the same time.
  • More Window Attributes: Maximize-Minimize-Restore-Resize-Move - this is all that you can do with your MS Windows. Now check this out.
    1. Layers help you control the visibility of your windows. There are three modes of layers - above (keep above the last active window), below (converse of above) and top (show it above all other windows, like "Always on top" in Winamp).
    2. You can make your windows have no borders, no borders and title-bars (great for visualization plug-ins for media players) or just borders and no title-bars.
    3. You can shade / unshade your windows (shading means hiding everything but the title-bar - great for running monitor apps).
    4. The windows may Stick (stay as you switch desktops)
    5. You can maximize in three modes - maximize (the normal mode), maximize available (expand as far as empty space is available) and maximize absolute (maximize to the full size of the screen, even covering the taskbar).
  • Remember Window Attributes: You can make any of your windows remember its attributes - the ones mentioned above - individually or all together. For example, you may want to place your mp3 player in such a way that when you maximize your windows, the player appears just to the left of the buttons. You don't feel like having a Title-bar and borders for it and want it to be always visible on all desktops. This is done simply by moving your mp3 player to the desired position, setting its layer to the top, making it sticky, making its title-bar and borders disappear and finally asking it to remember its attributes. It all needs just a drag and 4 mouse-clicks! In case you grow unhappy of the settings later, you can make the windows forget them too.
  • Special Effects: There are many special effects that are possible. You can control the style of movements and resizing (opaque, box, translucent - this is really cool, semi-solid), the way windows are activated - by clicking inside the window (as in MS Windows) or by simply moving the mouse into the window - no clicks needed (my preference) or let only the keyboard control activation. You can make your active windows get automatically raised (made completely visible) either instantly or after some delay.
  • Shortcut Keys: This is perhaps the most useful of all features. You can have your custom shortcut keys for all the window manager's functions plus launching your applications and running commands. For example, I have set the sequence Ctrl+Shift+e to launch Emacs (a text editor with everything and the kitchen sink). This is so much better than Windows where you first have to create a shortcut file and then specify a key combination. Also, if you want to make major changes in your shortcuts, it is better to have them all in one place unlike MS Windows.

This feature list is nowhere close to complete. There are other great Window Managers too and your choice, primarily, would depend on the kind of functionality they offer, their themes and memory requirements.

The Desktop Environment

The Desktop Environment is a set of applications that enable you to manage your Desktop. It is responsible for allowing you to browse files, handle desktop shortcuts, provide a "Start Menu" (known with different names in different Environments) and a "Taskbar" (again having many names). The most popular and widely supported Desktop Environment is GNOME (GNU Network Object Model Environment). It offers a Desktop, Panel (aka Taskbar in Windows), loads of themes and a host of utility applications. Although the primary responsibility of the Desktop Environment is giving functionality to the Desktop, it also controls the appearance of buttons, menus and toolbars displayed by the applications and the Start Menu. Note that these are different from the Window Manager's buttons and menus. Some of the high points of GNOME are:

  • Panel: The panel is the most functional part of the GNOME Desktop. It houses the Start Menu, Applets, swallowed apps, Launchers, Drawers and the Logout button. Applets are small applications running inside the panel, like a visualization plug-in for your media player or a clock. Swallowed apps are similar to applets but here it is as if you have reduced the size of the application's window and pasted it into the panel. Launchers are similar to quick-launch of the Windows Taskbar. The only difference is that unlike Windows, Launchers are integrated with the panel. Drawers are chests that open when you click on them to reveal more items (launchers, applets etc.) - very good for reducing crowd on your panel. The GNOME Panel comes in 7 sizes (height) to suit every desktop and has two more options for hiding besides the Auto-Hide a la Windows task-bar. You can also set it to always appear above the windows or otherwise. You can set the panel background can be an image, a color independent to that of the Desktop Theme (see "Themes" below) or the color of the theme itself.
  • Start Menu: Start Menu has much the same functionality in GNOME as in Windows. It too can be displayed with large or small Icons. Another option is that you can set it not to reveal a sub-menu just by mouse over. You have to click to show it. This really helps in slow going old computers. The greatest advantage of the GNOME Start Menu is that it can be made to pop-up anywhere on the Desktop. You'll love this feature once you start using it.
  • Themes: GNOME comes with a load of themes for your desktop and they not only alter the colors and fonts but also the texture of the windows. That means you can have patterned backgrounds and not just solid colors. They can change the size and shape of buttons and menu items, the way check-buttons and radio-buttons "click" (In Windows, check-buttons show a tick-mark and radio-buttons get filled by a dot, but more can be done in GNOME), the way of selection of menu-items, the way of selection of text and even the scroll-bars can have mouse-over and mouse-click effects!.
  • Interface Options: GNOME Toolbars and Menu-bars can be torn off (detached from the application window). This could really be helpful when your workspace is cluttered and you want to access a toolbar or menu very frequently. You can simply detach it and set its Layer on "Top" so that it is always visible. You can even make it sticky so that it's available on all desktops! Besides this, you can control whether the menu-bars and toolbars appear raised or flush with rest of the window elements and ditto with buttons inside them. To change key-bindings of a menu item, just hold the mouse over it and press the key combination you want to use. Voila!

Desktop Environments commonly include a libraries to help developers rapidly create applications GUI that conforms to the look and feel of a particular Desktop Environment. For example, GTK+ (The GIMP Toolkit +) is a library for GUI creation for GNOME. GUI written in GTK+ will look and feel exactly like that of other applications that may ship with GNOME by default. Also, when a new theme is applied, the GUI of that application automatically registers the changes. GTK+ is written entirely in C but it is Object Oriented. Similarly, Qt Toolkit is used for writing GUI for KDE. Qt is in C++. Tcl/Tk is another library that is not 'associated' with any desktop environment.

[ Up ] [ Introduction ] [ The Structure of Linux ] [ Common Linux Applications ] [ References ]

© 2002 - 2004 Tahir Hashmi. Unauthorized copying, alteration and redistribution in any media is prohibited, except where explicitly stated as being distributed under the OpenContent License (OPL). Last updated: 21 February, 2021. Update Log. Personal Email: tahir AT tahir.ws [PGP Key: ASCII, Binary]; code_martial AT softhome.net [PGP Key: ASCII, Binary] IM: Yahoo! Messenger [tn_hashmi]