Introduction to Linux

October 6, 2009

Table of Contents




Objectives

Our objectives are:
  1. To explain the differences between working with Linux and working with other operating systems.
  2. To help you understand the basics of using Linux so that you can:

Return to top of page




What is Linux?

Linux is an operating system that evolved from a kernel created by Linux Torvalds. A kernel is the nucleus of the operating system. It tells the processor what you want it to do. A kernel is pretty much useless without other programs to interface with parts of your computer and you.

Originally Linux was not for everyone. You accessed it from a command line interface (CLI) like MS DOS but to get Linux working you had to spend a lot of time learning how to install all the programs.


High points:

Return to top of page




Brief Introduction to Linux

Command-Line Interface

The *nix Shell

The shell is your workspace in the terminal. It is a command language interpreter that executes commands read from the standard input device or from a file.

Shell Name    Developed by Where Remark
BSH (Bourne-Again SHell) Brian Fox and Chet Ramey Free Software Foundation Most common shell in Linux
CSH (C SHell) Bill Joy University of California (For BSD) The C shell'ssyntax and usage are very similar to the C programming language.
KSH (Korn SHell) David Korn AT & T Bell Labs
TCHS See the man page. Type $ Man tcsh
--
TCSH is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).
  • The 't' in tcsh comes from the T in TENEX, an operating system which inspired Ken Greer, the author of tcsh, with its command-completion feature.

To find available shells in your system type:
cat /etc/shells

Cat types out the contents of a file as you saw above. The file "shells" in the "/ etc" directory holds all available shells in the system.

To find your current shell type:
echo $SHELL

The command "echo" echos or types what follows it. The "$" sign says echo the cont ents of the following system variable. The "SHELL" is a system variable set up in your init file or by using the "export" command.

To find out where your shell and other basic information is stored:

To get back to your home directory type:
cd
Now, to list all files including the hidden ones type:
ls -al

class=action> Here is what it will look like on "Tezpur":





Return to top of page




Environment Variables

What are they?

The shell's environment is that umbrella of persistent knowledge under which the shell operates. This information is stored as "environmental variables", which are global variables that may be used at any point by the shell -- either internally or when explicitly required by the user. Other variables can be customized by the user using a specific set of files contained in their HOME directory. (Thanks to Brett Estrade for this paragraph.)

Why should I know about them

Being able to know which environment variables affect which aspect of your environment means that you are able to customize your environment. In many shell scripts and using many applications or programming languages you will need to know the values of these variables.

Your global environment consists of environment varibles such as:

Return to top of page




Linux Architecture

Return to top of page




Kernel

Return to top of page




Filesystem Information

Return to top of page




Users and Groups

In Linux a user is identified by their username. Linux usernames are similar to Windows logon IDs. Linux maintains a list of users, called a name space, either locally on each individual machine or across the network via NIS for a group of machines.

User == uid

Each user on a Linux machine has a unique username that corresponds to a unique uid. The uid is a numeric value used to determine if the user is authorized to perform a particular task. It is important to note that the Linux operating system is concerned only with the numeric value of the uid and not the text that describes the user's name.

Group == gid

Groups are also associated with unique numbers called gids. Users may belong to more than one group, although they can be associated with only one group at a time. Groups may have zero, one, or more members. Like uids, the Linux operating system is concerned only with the numeric value of the gid and not the textual name of the group.

Authentication

Each time a user tries to login, Linux attempts to authenticate that user against a name space. The login process prompts for a username and, usually, a password. Linux then encrypts the entered password and checks to see if the encrypted text matches the stored version of the user's encrypted password. If there is a match, the user is authenticated; if not, the user is denied access.

/etc/passwd

Linux keeps a table of information about each user in the file /etc/password. Each line of this file represents a different user and has seven different fields:

  1. username
  2. encrypted password
  3. uid
  4. gid
  5. identification
  6. path to home directory
  7. initial program

In the Terminal window, type cat /etc/passwd

Permissions

Since Linux treats everything as a file, learning about file permisions is very important. Linux allows access to a file based upon affiliation as defined by user, group, and other. The possible permissions for each affiliation are read (r), write (w), and execute (x). Linux actually uses one bit to indicate these three permissions for each of the three affiliations.

In the Terminal window, type ls -l /etc/passwd

Your output should look similar to this:

The first dash is a flag specifying the type of file. The next three characters are the permissions for the user who owns the file. The next three characters are the permissions for the group associated with the file. The final three characters are the permissions for any user who is not the owner of the file nor belongs to the group associated with the file.

Each of the permissions has a different meaning depending on whether it is set for a file or a directory:

Return to top of page




Shells

The shell is your workspace in the terminal. It is a command language interpreter that executes commands read from the standard input device or from a file.

Shell Name    Developed by Where Remark
BSH (Bourne-Again SHell) Brian Fox and Chet Ramey Free Software Foundation Most common shell in Linux
CSH (C SHell) Bill Joy University of California (For BSD) The C shell'ssyntax and usage are very similar to the C programming language.
KSH (Korn SHell) David Korn AT & T Bell Labs
TCHS See the man page. Type $ Man tcsh
--
TCSH is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).

To find available shells in your system type:
cat /etc/shells

Cat types out the contents of a file as you saw above. The file "shells" in the "/etc" directory holds all available shells in the system.

To find your current shell type:
echo $SHELL

The command "echo" echos or types what follows it. The "$" sign says echo the contents of the following system variable. The "SHELL" is a system variable set up in your init file or by using the "export" command.

To find out where your shell and other basic information is stored:

To get back to your home directory type:
cd
Now, to list all files including the hidden ones type:
ls -al

class=action> Here is what it will look like on "Tezpur":





Return to top of page




Environment Variables

What are they?

The shell's environment is that umbrella of persistent knowledge under which the shell operates. This information is stored as "environmental variables", which are global variables that may be used at any point by the shell -- either internally or when explicitly required by the user. Other variables can be customized by the user using a specific set of files contained in their HOME directory. (Thanks to Brett Estrade for this paragraph.)

Why should I know about them

Being able to know which environment variables affect which aspect of your environment means that you are able to customize your environment. In many shell scripts and using many applications or programming languages you will need to know the values of these variables.

Your global environment consists of environment varibles such as: