PATH: IRCC Portal> Faculty/Staff> Faculty Web Site> Computer Science> Randy Gibson> Classes Portal> CGS 2760>

Linux Fundamentals


Underlined items below link to other web pages when selected. To return to this page, tap your Backspace key. Items in [brackets] will open a completely new browser window, allowing you to toggle between this one and it using the Alt+Tab keys. Close the new window when done viewing it by clicking on the close button image button in the upper right-hand corner.

Linux is a vast topic of study, described in literally thousands of printed and online documents. Many novices (or "newbies") are overwhelmed by the quantity of tutorial and reference documentation published about Linux and can find it somewhat contradictory, as it seems to cover many different versions over many years of development. The purpose of this document is to introduce some key concepts for Linux users and to provide a basic of set of documents that can provide readers a working foundation for self-study.

"FILESYSTEM" vs. "FILE SYSTEM"

A major impediment to early understanding of how Linux handles data storage and labeling can be a student's ignorance of the difference between the use of the term "filesystem" as opposed to the term "file system" (two words). This is particularly compounded by the fact that many otherwise competent authors use these two terms very carelessly (or in ignorance themselves).

The term "filesystem" (one word) relates to the physical coding patterns or formatting of data on a storage device. MS-Windows uses filesystems named FAT, VFAT, and NTFS to write data onto disks. Linux used its own coding/formatting patterns with names such as Ext2 and Swap.

The term "file system" (two words) relates to the logical organization of data on a storage device. This term relates to the technique of organizing files and folder into hierarchies of top level directories and sub-directories that can be illustrated as a "tree". For a simple explanation of this term, see

    [http://www.control-escape.com/linux/lx-filesys.html]

Knowledge of this distinction can be very illuminating when reading documentation. Ignorance of it can make the same reading profoundly confusing. Remember that many authors get this mixed up or use one of these terms to mean both things; so read with care.

THE LINUX VIEW OF HARDWARE

The most important basic concept here is that Linux was written to treat all physical devices as if they were simple files which could be read (input from) or written (output to). This technique is accomplished through the development and use of drivers for each device that are stored in the /dev directory and associated with file labels in the file system through a process called "mounting". This approach allows easy substitution of true files in place of devices whenever we want to redirect input or output to come from or to someplace other than a physical device. For example, input that would normally come from a terminal can be redirected to come from a text file; or output that would normally be sent to a terminal could be redirected to a printer (or a file). Our textbook focuses on redirection in Chapter 7. But many authors use redirection in examples of commands when they are explaining other topics, so a basic understanding of the principle and the use of the symbols >, >>, <, and | can be quite helpful.

A good basic explanation of redirection (and the cat and tac commands) can be found at

    [http://ceu.fi.udc.es/docs/debian-user-guide_1.0/node59.html]

LINUX USAGE – ABSOLUTE BASICS

If you want one document to read that summarizes the absolute minimum that you should know to as a Linux user, read the online "Linux Basics" chapter from "Sams Teach Yourself Red Hat Linux in 24 Hours" at

    [http://vig.pearsoned.com/samplechapter/0672318458.pdf]

Pay particular attention in that chapter to the concept of "virtual terminals" (a.k.a. "virtual consoles", but not to be confused with "virtual desktops" which are a feature of GUI's). This feature of Linux allows a user to interact with the system as if he or she were multiple independent users working from separate terminals. The software presents independent console windows for each virtual user that can be accessed (toggled between) by pressing the keystroke combination Alt+F# (where # is replaced by a digit - typically 2-7).

When you login on most distributions, the initializing process typically establishes six virtual terminal console (non-GUI) windows (VT1 through VT6) and then launches an X Windows session in the first one before you login. That session is treated as a seventh Virtual Terminal (VT7), but it is a GUI. Once VT7 is active, VT1 will be effectively locked out, since is the one hosting the GUI session. The important thing to realize here is that the keystrokes used to access this feature depends on whether you are using a GUI window at the time or a CUI (console) window. For example, to toggle from VT7 (a GUI) to VT2 (a CUI), the user must press Ctrl+Alt+F2. Notice the added requirement of holding the Ctrl key. This is necessary because the keystroke combination Alt+F2 alone was already defined in most GUI systems. So if you are in a GUI virtual terminal window and want to toggle to a normal console window, you must include the use of the Ctrl key. Normally, to simply toggle from one CUI VT to another, you need only hold the Alt key and the Function key that corresponds to the VT you want to use. For example, to toggle from any CUI VT to VT3, the user need press only Alt+F3 (without the Ctrl key). Play around a bit with these virtual terminals. But remember to toggle back to and logout of each one before you shutdown the system. Note: this feature will not be available to remote access users of the IRCC Linux Server or to users of the Cygwin emulator.

SHELL COMMAND SYNTAX

Once an installation is well defined and stable, the next most important thing to learn about Linux is how to communicate with it. Since most students are already familiar with learning to use graphic user interfaces (GUI's) and the many different GUI's offered under Linux are all quite similar to those found in Windows or Mac OS's, our efforts will focus on learning the syntax and specifics of the character-based, command-line interfaces (a.k.a. CUI's or CLI's) known as "shells". Some of you may think that these are somewhat similar to the Command Prompt console window interface offered in Windows (based on the old command.com program in PC-DOS). But there are many important functional differences that can be major surprise to a novice and cause a lot of confusion until they are realized.

  1. Linux is highly case-sensitive! This is true for commands, identifiers, configuration files, everything! It can be extremely frustrating if you are not used to it.

  2. Beware of quotes! Linux shells "interpret" every character on the command line and treat each symbol based on very specific rules of syntax. The quote symbol ( " ) is interpreted entirely differently from the apostrophe symbol ( ' ) and the backwards apostrophe symbol ( ` ). Readers of English have become relaxed about the use of these symbols and often use them interchangeably, but Linux shells do not. Some people use the terms "double quote" and "single quote" to distinguish between the ordinary quote mark and the apostrophe being used as a quote mark respectively. A clear understanding of the distinction between these symbols will require that you learn about metacharacters, environment variables, and scripting, but for now just be careful to pay attention to the use of these symbols in written examples and use them just as you saw them written (without substitution). It is equally important to pay attention to where blank spaces were used and not used. For a quick summary of quote interpretation by Linux shells, see
        [http://linux.about.com/library/bl/open/newbie/blnewbie3.4.6.htm]

    An equally brief summary of some of the other popular metacharacters can be found at

        [http://linux.about.com/library/bl/open/newbie/blnewbie3.4.8.htm]
  3. There are many different Linux shells, grouped into families, with very different capabilities and syntax. The most common nowadays is bash. You can determine which shell your account uses with the command
        echo $SHELL
    The bash shell typically displays a system prompt message that ends with one of two symbols, depending on how you are logged-in. If you are logged-in as the root user (administrator), your prompt typically ends with a # symbol. If you are logged-in as an ordinary user, your prompt typically ends with a $ symbol. For an explanation of how to customize your shell prompt, see
        [http://linux.about.com/library/bl/open/newbie/blnewbie3.4.2.htm]
  4. In MS-DOS/Windows, some commands are "internal", meaning that they are part of the command interpreting program itself ("command.com" in Windows). In the UNIX/Linux world, such commands are called are "builtin" commands, as they are part of the code of the shell itself. All other commands are called "utilities" ("external commands" in DOS/Windows), because each is actually a separate program that must be loaded into memory from disk each time it is used. Because Linux offers its users many different shells, we sometimes have difficulty remembering which commands are builtin vs. utilities for each shell. To find out which commands are builtins for bash, use the manpage command
        man bash

    This will produce a massive text file that documents all of the major issues in the bash shell. It is a lot of reading, but most of it you will need to know eventually. Approximately 70% into the file, you will find a major heading in all capital letters for the "SHELL BUILTIN COMMANDS". Below this is a detailed list of each builtin command in the bash shell. Any command that is not listed there is actually a utility program. Some shells add a command to the builtin commands after it has proved itself as a utility. So there may actually be two versions of it on a system. In some rare cases, enhanced versions of a builtin command are added to a distribution as a utility. The utility can be run by typing the path to it when entering the command. Otherwise, the builtin will be used.

  5. The many different utility programs written for the Linux kernel were all written by different programmers to serve different user groups. A program that may seem intuitive to one user may seem almost absurd to another. Lack of consistency is traded for versatility. Don't believe that one area of similarity between two programs implies that they will be alike in all ways. For example, there are three (or more) different versions of the text searching utility originally known as grep, each with their own unique features and syntax (see grep, egrep, and fgrep). Indeed each different utility AND each shell makes its own unique interpretation of each character typed on a command line. For a user, this situation is somewhat like getting acquainted with different people. People have many similarities, but they also have many individual traits and react uniquely to given input.

  6. The final point that I will make here regards some of the important quick keystrokes used by Linux. Look over these online pages for an overview of some of the useful keystrokes in Linux. Even experienced Linux users sometimes discover something new here.
        [http://rute.2038bug.com/node5.html.gz#SECTION00560000000000000000]

    The most important keystrokes I can think of for new users are:

    Lowercase 'q' to exit almost all pager utilities (such as more and less - often used in the man command) when all you seem to see is MORE or END at the bottom of the screen.

    The keystroke combination Ctrl+U to abort an entire line of input when all else fails. If your backspace key doesn't seem to serve you well, you can abort an entire line and start over with Ctrl+U.

    One final keystroke that is a must for shell users is the simple up arrow, which rolls back through the history list of most recently typed commands. It can save you hours of typing!

SUMMARY

For a good overall summary of the all of the topics described above, see the Consoles and Terminals online chapter from Brian and Tom's Linux Book at

    [http://linuxbook.orbdesigns.com/ch15/btlb_c15.html]

It is based on the Caldera OpenLinux distribution, but offers a relatively generic overview.

Another useful overall read is

    [http://rute.2038bug.com/node7.html.gz]

Go to Home Page to the Course Home Page

Last Revised: 31 August 2007 Valid XHTML 1.0 Transitional Valid CSS! © 2006 Randolph Gibson
www.gibson.vero-beach.fl.us/classes/cgs2760/linuxfund.html E-mail: rgibson@ircc.edu