Professor Cullen Lecture Notes

COMS148 Introduction to the LINUX Operating System


Week 1
Linux Installation and Getting Started


Definition:

GRUB (Grand Unified Loader) is used to perform an IPL (Initial Program Load) or boot of the Linux operating system. Another loader in limited use is called LILO (Linux Loader).

The Recommended Partitioning Scheme for Linux consists of a SWAP partition (at least 2 times the size of the computers real memory space), a BOOT partition (about 128M bytes), and a ROOT partition which would contain all other files.

Linux is CASE-SENSITIVE for commands and data. Most commands and applications are lower-case named.

Linux co-existing with other Operating Systems on the same physical drive is not supported by all other operating platforms nor their manufacturers. It is recommended to install each OS on their own exclusive hard disk (or set of hard disks).

The Shell Prompt is a command line interface between the user and the operating system. The shell interprets commands entered by the user and passes them on to the operating system.

The X-Window System is a network transparent window system which runs on a wide range of computing and graphics machines including Linux. If you are in X-Windows then you are executing in a graphical environment as opposed to using line commands in a console environment.

GNOME provides the Graphical User Interface (GUI).  GUI is a general term for interactive windows, icons, menus, and panels which allow a user to initiate actions such as starting applications and opening files using a mouse and keyboard, as opposed to text line commands.

Root is an administrative user account created during installation and has full privileges and complete access to the system. You must be logged in as root to accomplish certain system administration tasks, such as changing administrative passwords, running system configuration tools, and installing software.

Virtual Consoles are logical terminal devices that are simulated by Linux to provide multiple logins from the same physical terminal or monitor. CTL+ALT+Fn combination keys are used to toggle in/out of the virtual consoles.

MAN Pages are the online manual pages for applications, utilities, and shell prompt commands. You can access a man page by typing man ..command_name.
    Example:  man ls   

Commands:

ifconfig displays your machine's IP address for each of its active network interfaces.

id shows the identity of the user that is logged on to this console.

ping bounces a signal off of another IP address and returns an affirmative response and travel time information if the other site is reachable.

neat is an application that will bring up a gui for configuring the network connections.

serviceconf & displays a gui listing the services available on your Linux system along with their automation options.

su command places your userid into SuperUser mode. The 'exit' command drops you back to normal unprivileged mode.

/usr/bin/redhat-config-packages displays a GUI listing the software packages that have been installed (and are available to install from the CD) on your Linux platform.

uname -a shows system information regarding kernel build and cpu.

hostname will query the name of this Linux OS assigned name.

users gives you a list of logged on users to your system.

who tells you the name of the user that is logged on here.



Week 2
Using the Desktop


Definition:

GUI (Graphical User Interface) is an interface that allows the user to access and manipulate applications and the operating system via grapical icons, windows, the mouse and the keyboard. The two major Linux GUIs are GNOME and KDE.

The Control Center folder provides facilities to adjust your user preferences such as screensaver, mouse speed, sounds, etc.

The WorkSpace Switcher on the Launcher toolbar allows you to switch between multiple desktops under your logonid.

The Home Folder presents you with a GUI of each directory or file defined under your /home/userid/. Clicking through each directory will show you any subdirectory or files defined below that folder.

/ (The Root) This is the lowest level of the UNIX file system hierarchy. All other files and directories are constructed and stored relative to the root.

/home This part of the directory tree houses all user information.

The user ROOT is the super authorized user that has access and privileges to manipulate the entire Linux system.

Files that begin with a period (.) are hidden files.

Commands:

gnome-terminal creates a terminal command window.

chkconfig --list will show all servers that are available to be set to running or not_running.

cat will type out the contents of a file to the terminal window.

clear will clear the screen of all data from the terminal window.

find command searchs the system for filenames.

ls lists directory contents.

man command_name will display the manual page for the requested command.

reset will return the terminal window to its default values.

startx will start X-Windows and the graphical user interface.

top shows real-time performance and task consumption data.


Week 3
Disk Management and Processes


Definition:

/boot is the part of the directory tree contains IPL (Initial Program Load) or BOOTSTRAP information.

A PAGING I/O operation is performed by the storage management subsystem to move a defined contiguous amount of memory (usually of size 4K bytes) between main memory and a mapped hard drive file.

A SWAPPING operation is performed by the storage management subsystem to move an entire address space between main memory and page frames located on a hard drive.

The SWAP  PARTITION of the hard drive (or a separate hard drive) is used by the storage management subsystem for paging and swapping operations.

An active PROCESS is any task running under Linux that consumes memory, and/or CPU cycles and it may perform Input/Output.

Machine processing time is spent in the following operating modes:
    User CPU consumption
    System CPU consumption on behalf of the user.
    System CPU consumption for supervisory services.
    NICE time spent on tasks with negative nice values
    I/O WAIT time.  Waiting for I/O to complete and there are no ready-to-run tasks.
    IDLE time.  No system or user task is using the CPU nor waiting for I/O to complete.

A process' RUN or EXECUTION state is either:
    ACTIVE or RUNNING
    INACTIVE, IDLE or SLEEPING.  This is an ENABLED state.
    ZOMBIE, generally a hang condition (waiting for an event that will never happen)
    STOPPED.  This is a DISABLED WAIT state.  

A Ready-to-Run process is any task that requires the CPU and is not waiting for I/O to complete.

A time-slice is the standard amount of CPU time that a single task receives to execute until it is pre-empted by the operating system.

A CPU-bound process will attempt to consume more CPU cycles than its time-slice will permit.  This task performs relatively little input and output.

An I/O-bound process will use only a fraction of the CPU cycles that it is allotted.  Most of this task's wall clock time will be spent performing input and output. 

An Interactive process will spend relatively little time consuming CPU or performing I/O, but will use most of wallclock time waiting for an input event, usually from the keyboard, to occur.

/etc/fstab (File State Table) is the file that is used to define the disk allocation and devices that can be mounted to the Linux system.

The /boot/grub/grub.conf file contains the parameters and pointers for the GRUB loader to IPL the system.

Utilities

man     Displays the documentation manual pages for a given command or utility.

pinfo   Displays the top-level directory for documentation of all Linux commands.

Commands:

cd changes the current directory.

cd .. drops back to the parent directory.

cd ../directory_name drops back to the parent directory then forward to directory_name.

cd /  brings you to the root directory.

cd -  moves you back to the last directory you were in.

df reports filesystem disk space usage.

du reports disk usage by user.

    Example:    du  -h    

echo $_variablename_ is used to display one or all of the user/system environmental variables.

fdisk is a utility for formatting, partitioning and managing hard drives.

find is used to locate any files under the directory or subdirectory tree.

    Example:    find  /  -name fstab

free will show the allocation of memory and swap areas.

grep (Global Regular Expression Parser) allows you to find specific character strings within files.

    Example:    grep -r  'Cullen'    /home/gjcullen/   (will search files in this subdirectory tree for Cullen)

                        ls -slS  |  grep '.'  -c    (will count the files in the current directory)

kill can be used to terminate a process.

locate will find files and directories that contain a particular character string in their names.

    Example:    locate 'Cullen'        (will find all directories with the string Cullen imbedded)

mkdir will make a directory.

rmdir will remove an empty directory.

mount and umount is used to display current mounted devices, mount and dismount devices.

    Examples:   mount
                        mount -t ext3  /dev/hdb2  /mnt/linux2
                        mount -t ntfs  /dev/hdb2  /mnt/winxp
                        mount -t vfat  /dev/fd0  /mnt/floppy 

mkfs is used to make a file system on a given device such as a hard drive partition or a floppy.

    Examples:    mkfs.vfat  -v  /dev/fd0  -i  abcdef12 
                        mkfs.ext3  -v  /dev/hdb2

more and less controls the amount of display data that is directed toward the console.

ps command will show the processes on the system.

    Example:    ps -ax   

rm removes a file or directory.

rmdir removes an empty directory.

service service_name STATUS | STOP | START | RESTART script is used to manipulate server task execution and check run status.

set is used to display, set or change a user or system environmental variable.

shutdown is used to quiesce, halt or restart the operating system.

    Example:    shutdown -h    now
                       shutdown -r     now

whereis will search standard Linux places for a particular executable file or manual.

which will search your PATH concatenation of libraries for a particular executable command file.


Week 4
Shell Scripting


Definition:

The term bash stands for Bourne Again Shell.

A text file is one in which consists of human readable characters that are grouped into distinct lines terminated by a line-feed (LF) and/or carriage-return (CR) character. Both the line-feed and carriage-return characters are non-printable (also known as white-space).  Some examples are programming source code, script files, this html page that you are reading.

A text editor is a program that is used to create and modify a text file. Some text editors that come packaged with Linux are: VI and gedit.

BASH Scripting is a programming language packaged with all UNIX systems with features of variables, operators, functions, wildcarding, and input-output capabilities.

The .bash_profile is a script file that Linux executes on behalf of each user logging into the system. The .bash_profile can be used to set or modify the profile characteristics of the userid with which it is associated.  It usually sets up the library PATH Environmental Variable for each user. You can adjust your PATH variable by editing this file.

The /etc/profile is a script file that Linux executes on behalf of all users logging into the system.  The systems administrator maintains this script.

A PIPE connects the standard output of one command (or application) to the standard input of another command (or application). The pipe character is the '|' .

Re-Direction is a feature that allows alteration of standard output or input. The redirection characters are the  '<'  for input and the  '>'  for output. Using  '>>'  will cause the output to be appended to the target file.

All bash scripts begin with   #!/bin/bash  or   #!/bin/sh  as their first line.

Commands:         

bash must precede any shell script that is not marked as executable for it to run.

The dot-slash  ./  prepended to any script forces Linux to look for the script first in the current directory prior to using any library concatenation found in the PATH environment variable.

clear will clear the terminal screen.

reset will return the terminal to its default values. You may need to use this after attempting to edit or display a binary file.

BASH Special Characters and Wildcards:

* Multicharacter wildcard 

? Single character wildcard

< Redirect input

> Redirect output

>> Redirect and append output

| Pipe the output to another process's input

$ Variable expression

' Strong quote, ignores contained variables

" Weak quote, allows interpretation of contained variables

~ HOME directory

# Comment line 

` (The Graven). Issue a command.

\ (Escape). Interpret the next character literally.

[set] SET operator, where the brackets delimit the range and 'set' lists the

alphanumeric characters making up the range.

example. [abcde] or [a-e] the set of characters a thru e

[!abcde] the set that does not contain characters a thru e.

BASH Input/Output from the keyboard/console:

echo     Will write data to the console (terminal window)


Options
-n     Do not output the trailing new line.
-e     Enable interpretation of the following backslash escaped characters in the strings:
\a     alert (bell)
\b     backspace
\c     suppress trailing new line
\n     new line
\r     carriage return
\t     horizontal tab
\\     backslash



read     Will wait the program, read from the keyboard until the ENTER key is pressed, then continue.



BASH Special Variables:

$0 Contains the name of the script.
$1 Contains the first input parameter received.
$2 Contains the second input parameter received.
$3 Contains the third input parameter received.
$# Contains the number of input parameters received.
$* and $@ Contains all input parameters received.
$? Contains the numeric return code from a command or called subroutine.
$$ Contains the Process ID of this task.

BASH In-Script Variables:

varname=value Assignment: will set variable "varname" to value of "value".

$varname Is used when a reference is made to variable "varname".

$(varname) More general form of above referencing.

BASH Indirect Referencing of Variables:

The notation {!something} provides an indirect reference to a variable.  It means the value of the variable corresponding to the interpretted text contained within variable $something.

    Example:    for ((ix=1;  ix<$#;  ix=ix+1))
                             do
                             echo  "Variable $ix contains content ${!ix}"
                             done  

BASH Alphanumeric String Comparison Operators:

Operator Expression True for str1 <operator> str2

Equality
= str1 matches str2
== str1 exactly matches str2
!= str1 does not matches str2

Relational
< str1 less than str2
<= str1 less than or equal to str2
> str1 greater than str2
>= str1 greater than or equal to str2

Logical
|| or
&& and
! not

BASH Numeric Comparison Operators:

Operator Expression True for var1 <operator> var2

Equality
-eq var1 equals var2
-ne var1 not equal var2

Relational
-lt var1 is less than var2
-gt var1 is greater than var2
-le var1 is less than or equal to var2
-ge var1 is greater than or equal to var2

BASH Test Operators:

-z var1 operand has zero length, the NULL string.

-n var1 operand does not have zero length, a non-null string.

BASH Condition Logic (IF-THEN-ELSE):

if [condition is true]; then
 ....
 ....
....
else
 ....
 ....
 ....
fi
 

Example:
#!/bin/bash
if [ $# == 0 ]; then
echo "No parameters received."
option='NOOPT'
else
echo "Number of Parameters received: "$#
echo "Parameters received: "$*
option=$1
fi

BASH Condition Logic (CASE SELECTION):

case argument_value in
pattern1)
....
....
;;
pattern2)
....
....
;;
..(number of other cases)..
patternN
....
....
;;
*) The default case
....
....
;;
esac



Example:
case "$light" in
green | GREEN )
echo "You can GO."
;;
amber | AMBER )
echo "Hit the gas, the light is going to change"
;;
red | RED )
echo "You must stop."
;;
*)
echo "An invalid color, exiting."
exit 255
;;
esac


BASH Loop Control Logic (FOR variable value LOOP ):

for (( initial_value; terminating condition; increment/decrement variable ))
do
....
....
done


BASH Loop Control Logic (WHILE a CONDITION is TRUE):

while [ condition is TRUE ]
do
....
....
done



BASH Loop Control Logic (BREAK and CONTINUE):

do
...
   continue   (Will exit this iteration of the loop and begin the next iteration)
....
....
   break  (Will exit the loop and begin next instruction following the loop)
....
done


BASH Arithmetic Operators:

Operator Expression Description

+ addition
- subtraction
* multiplication
** exponentiation
/ integer division, no remainder
% modulus division, only remainder
= assignment

BASH Arithmetic Operations (3 ways to perform computation):

a=1
b=2
let c=a + b
c=$(expr $a + $b)
c=$(($a + $b))


BASH Debugging:

set -x       Will cause debugger to show every interpreted line during execution.

set -y       Will cause debugger to show each source line that has been executed     


BASH Functions:

Functions make scripting much easier to code and simpler to maintain. Functions allow you to break up the program into smaller manageable pieces. A function performs an action defined by you, and it can return a numeric value if you wish.
You simply must enure that your script has access to the functions, such as placing the code in the same directory.


See Bash Scripts Examples Page

File operations
-e file True if file exists.
-d file True if file exists and is a directory.
-f file True if file exists and is a regular file.
-L file True if file exists and is a symbolic link.
-r file True if file exists and is readable.
-w file True if file exists and is writable.
-x file True if file exists and is executable.
file1 -nt file2 True if file1 is newer (according to modification date) than file2.
file1 -ot file2 True if file1 is older than file2.
file1 -ef file2 True if file1 and file2 have the same device and inode numbers.
Less frequently used operations
-a file True if file exists.
-b file True if file exists and is a block special file.
-c file True if file exists and is a character special file.
-g file True if file exists and is set-group-id.
-h file True if file exists and is a symbolic link.
-k file True if file exists and its "sticky'' bit is set.
-p file True if file exists and is a named pipe (FIFO).
-s file True if file exists and has a size greater than zero.
-t fd True if file descriptor fd is open and refers to a terminal.
-u file True if file exists and its set-user-id bit is set.
-O file True if file exists and is owned by the effective user id.
-G file True if file exists and is owned by the effective group id.
-S file True if file exists and is a socket.
-N file True if file exists and has been modified since it was last read.


Week 5
File Architecture and Management


Definition:

/bin Non-System binaries, executable programming.

/boot Contains files, programs and data to support Initial Program Loading operations.

/etc Contains system and application parameters, configurations, etc.

/root This directory houses the ROOT's home area.

/home This part of the directory tree houses all user information.

/lost+found data, possibly corrupt, from file recovery programs.

/mnt Mounted device definitions and support code.

/media Automounted USB devices.

/sbin System binaries, executable programming.

/var Contains transient data and logs.

/usr Contains installed programming and source code accessible to users.

Commands:

name=something creates a local shell variable.

        Example:    ABC=123

export creates a system environmental global variable.
export ABC
unset removes the global variable.
unset ABC
env will display all the system environmental global variables in effect.

cp is used to copy one file to another of the same or different name

cp -p /home/gjcullen/abc123.data /home/misc/

cp -p /home/gjcullen/abc123.data /home/misc/xyz123.data

diff compares the contents of two files.

mv is used to move a file to another directory.

rename is used to change the name of 1 or more files matching a pattern.

Given files abc123.jpg and abc456.png

rename abc xyz abc*.*

will change all files beginning with string abc to xyz123.jpg and xyz45.png

mkdir will make a directory.

pwd will display your current directory location in the file system.

rm is used to remove or delete files and directories

rm abc123.jpg ,will delete 1 file.

rm abc123.* ,will delete all files of the pattern.

rm dirname -f -r ,will delete directory and recursively all files below it.


Week 6
User Management


Definition:

The user ROOT is the super authorized user that has access and privileges to manipulate the entire Linux system.

File Permissions are settings placed on a file that dictate what user may have Read, Write and Execute access to them. There are a set of 9 permission bits. The first three describe owner permission, the middle three group permission, and the last three describe access to all others. Each set of three have corresponding bit values of 4,2,1. (ie a setting of 755 would give the owner Read-Write-Execute access and all others Read and Execute.)

.bash_profile is a script that executes at the login to the user enviroment. This allows the user to set a default configuration at logon time.

.bash_rc is a script that executes at the initiation of a shell. This allows the individual user to set a default configuration at the start of each shell environment.

/etc/profile is a script that executes upon the login of each user.  This allows an administrator to set a system-wide default configuration at logon time.

Commands:

chmod modifies the read, write, execute permissions for a file or director.

chown changes the ownership of a file or directory.

passwd command allows you to set/change the password of a user.

useradd command adds userids from the system.

usermod command modify userid on the system.

userdel command deletes userids from the system.


Week 7
Software Package Management


Definition:

Products that come packaged as tar.gz, also known as "tarballs", are compressed archive files used to package software programs among other uses.

RPM stands for Redhat Package Management. It is a packaging standard provided by RedHat for delivering software programs to the installer.

YUM stands for YellowDog Update Management.  It is a packaging program used for searching for products, updates and their requisites across the Internet.

A symbolic link is a file that acts as a pointer to another file. Many times used for plug-in programming.

Commands:

The rpm command is used to list, install, and remove software packages.  Yum leverages rpm to provide a higher level of abstraction for managing software installation.

RPM's design goals are: 

Upgradability of individual components without the necessity of uninstalled old and installing new.            Configuration files are preserved.

Querying the software via the RPM database for such information as to what package a file belongs to, where did a package come from, where is it installed, who is the vendor, etc. 

System Verification to ensure that the software has an environment of met pre-requisites and co-requisites; and that all install components are present.

Some options for YUM include:

yum list   *xxxxx*     : find information on a package that contains string xxxxx

yum -v install  xxxxxx    : install a package

yum -v remove  xxxxxx     : remove a package

yum -v check-update  xxxxxx    : query updates available

yum -v update xxxxxx    : update a package


Some options for RPM include:

rpm  -qa  |  egrep  'xxxxx'     : find a package that contains string xxxxx

rpm -iv    : install a package

rpm -e     : remove a package

rpm -qi    : display information regarding a package

rpm -qR   : display information regarding package requisites

rpm -ql     : display information regarding list of files in the package

rpm -qc    : display list of files marked as configuration files in the package

rpm -qd    : display list of files marked as documentation.

rpm -f        : queries that package which owns this file

rpm -Va     : verify entire system

rpm  -qa  |  egrep 'kernel'     : display all kernel related rpms installed

The tar command is used to compress and de-compress software packages.

The gzip and gunzip commands are used to further compress in "zip" format a package.

Examples:

tar -cvf abc.tar file1.doc file2.jar file3.README file4.script     : compress a set of files

gzip abc.tar     : zip the package of files

gunzip abc.tar.gz     : unzip a package

tar -xvf abc.tar     : extract package files

tar -zxvf abc.tar.gz     : unzip and extract package files in a single step

gunzip -dc abc.tar.gz | tar -xvf     : unzip and extract package files via piping

tar -tvf abc.tar     : displays files that make up the tarball



Week 9
Backup and Recovery


Definition:

Backup refers to any procedure that creates a copy or image of a software component and moves it to another place. 

Examples are: copy to another directory, copy to another hard drive, transmit to another machine, flash drive to hard drive, copy to optical media.


Types of Backup


Full -- Everything on the hard drive.

Incremental -- Only files that have been modified or added since the last full backup.

Physical -- Backup based on the physical characterists of the input media. Such as the sectors, tracks and                             cylinders of the hard drive.

Logical -- Based upon the file construction attributes of the input data being backed up.


What is not important to backup?
Each of the following can be restored from installation media:

Vendor software code.

The operating system components.



What should be backed up?
The following is critical since the data involved is usually unique and requires much effort to rebuild:

User data -- Most everything in the /home directory tree.

Configuration files -- /etc directory tree.

Recovery or restoration refers to any procedure that copies the software component that had previously been saved, backed up or transiently stored, and places it back into production.

.bash_history contains a queue of the last 500 or more commands entered by the user.

Commands:

mkisofs will create a filesystem according to ISO standards selected.

        Example:    mkisofs  -o /tmp/cd.image  /home/mike

cdrecord will take a file and write it to a CDROM optical media.

        Example:    cdrecord -v dev=0.0.0 -data /tmp/cd.image

dvdrecord will take a file and write it to a DVD optical media.

e2fsck utility will check a disk device for errors, and attempt to repair.

kill will stop a process from running.

mke2fs this command will format a given device for a particular filesystem.

dump is used to do linux ext2 filesystem backups of either the entire partition or individual directories.

        Example:    dump 0uf  /dev/rft0  /dev/hda2

        This command specifies that the file system on /dev/hda2 should be backed up on the magnetic tape device         /dev/rft0.  The backup should use backup level - (full backup) and write the time of the backup to the                  /etc/dumpdates  file.

restore is used to restore from a dumped media an entire partition, individual directories or individual files. 

        Example:    cd  /home
                            restore rf /dev/rft0

        Restore must be run inside the directory that is going to be restored.  In the above example the /home                     directory is restored.  The r flag tells restore to restore the entire archive rather than just some files.  The f flag         tells restore that the archive is located on the device /dev/rft0.

Other backup/recovery methods:

    FTP File Transfer Program (FTP) for backing up files to another network connected machine.

    Tape Archives (TAR) will place a directory tree of files into a single archived file that can be offloaded.

    Copy your important files to second installed hard drive.

    


Week 10
Networking and TCP/IP


Definition:

A computer "network" consists of two or more computers that are capable of communicating with one another over a data communication link.

Device IP Addresses are made up of 4 octets separated by periods. Each octet has a range of 0-255 in decimal (or 0 to FF in hexadecimal) Every device on the Internet must have a unique address.

Intranets consist of devices that are physically connected to each other and share the same network number, but different host numbers.

        Example:    123.456.789.100   using  mask  255.255.255.0 

        The network part of the address would be the first 3 octets.
        The host part would be last octet.

Datagrams are small packets of data into which information is divided prior to transmission across the network.  

Why are smaller packets transmitted over the Internet?

Sending smaller packets rather than the original fullsize of the data has the following benefits and efficiencies:
    1) No single transmission monopolizes the bandwidth while smaller packets wait.
    2) In the event of packet failure, only the affected packet need be re-transmitted.


A Router is a device that allows machines in separate networks to communicate with each other.

A Gateway is a device usually a router that is designated as the portal to reach another network.        

A Bridge connects networks with no additional routing or checking.

LAN is a Local Area Network. A set of machines defined under the same intranet.

WAN stands for Wide Area Network. A set of machines that may be in the same intranet, but geographically dispersed and usually connected by a secured communications link.

Network Topologies
    Star -- Easy to setup, but single point of failure.
    Ring -- Fastest but single point of failure.
    Bus -- Fairly secure, no central failure point.
    Mesh -- Most secure, no central failure point.
    Tree -- Used by ISPs, root becomes failure point.

 

TCP is an acronym that stands for Transmission Control Protocol. IP stands for Internet Protocol. Both are just two of the protocols contained in a group of protocols developed by the US Department of Defense.

ICMP stands for Internet Control Message Protocol.   ICMP supports packets containing error, control, and informational messages.

ARP stands for Address Resolution Protocol.  Provides conversion of network protocol addresses to 48.bit Ethernet address for transmission on Ethernet hardware.  Matches physical addresses to IP addresses.

UDP stands for User Datagram Protocol.  This protocol provides a procedure for application programs to send messages to other programs with a minimum of protocol mechanism. The protocol is transaction oriented, and delivery and duplicate protection are not guaranteed. Applications requiring ordered reliable delivery of streams of data should use the Transmission Control Protocol (TCP). 

RIP stands for Routing Informatin Protocol.  It is based on the same set of algorithms that use distance vectors to mathematically compare routes to identify the best path to any given destination address.  

Subnet denotes a subset of a network. The network is divided up into several min-networks, all which share the same network part of the real IP address.   The network part is extended internally to include some bits from the host part. The number of bits that are interpreted as the subnet number is given by the so-called subnet mask, or netmask.   

Commands:

/sbin/service network start | stop | restart | status         Script to manipulate initiation/shutdown of the network interface on Linux.

ifconfig is used to configure, start, stop and display a network interface.

arp displays the table that shows the local physical addresses over the network interfaces.

iwconfig is used to configure and display a wireless network interface.

netstat is used to display routing tables, network connections and statistics; and status of ports.

nmap (network exploration tool and security scanner) will gather information via the network about a remote host based on its reponses to ICMP requests. It will discover whether remote machines are up and what ports are open.

    Example:    nmap -sT   -O  localhost        (will assess open ports on this system)

ping program is used to send an ICMP echo request to another IP.

route is used to display and manipulate the IP routing table of interface and gateway paths.

traceroute is used to list the series of hosts or route that data packets take to reach a network host.

host and dig translate domain names to ip addresses.

finger will give you some personal information regarding a user

ifup device-name to bring an interface up by following a script (which will contain your default networking settings). Simply type ifup and you will get help on using the script.

ifdown device-name to bring an interface down using a script (which will contain your default network settings). Simply type ifdown and you will get help on using the script.


Week 11
Internet Services and Network Servers


Definition:

A Internet Service is any service that runs on a machine that can be accessed through TCP/IP based data communications. They include both secure and non-secure services.


Some common services include:

HTTP - HyperText Transport Protocol (port 80)

FTP - File Transport Protocol (port 21-22)

TELNET - Remote terminal access (port 23)

SMTP - Simple Mail Transport Protocol (port 125)

POP3 - Post Office Protocol (port 110)

SOCKS - A protocol for traversing firewalls in a secure manner (port 1080 or specified by vendor)

DNS - Domain Name Services (port 53)

HTTPS - Secure HTTP using encrypted packets (port 443)

VNC - Virtual Network Computing (port 5900)

URL
Universal Resource Locator, a website's unique name and address.

HTTP Servers
An HTTP Server is one that serves up web pages for requesting clients.
The web client, usually a browser, first performs a DNS lookup on the server name specifien in the URL, obtains the IP address of the server and then connect to the server's port 80 at that IP address (or another port if the server is using other than the default HTTP port).  When the connection is established, the client sends an HTTP GET request for the document in the URL, which could be, among other possibilities, a specific HTML document, an image, a script, or a directory listing.  After the server receives the request, it translates the document URL into a filename on the local system.  For example, the document URL http://myhost.homelinux.com/joes/public_htmlnews.html might become a request for file /home/joes/public_html/news.html at then DNS myhost.homelinux.com through port number 80.

A virtual http server is primarily used to support multiple domains on a single system.

   

A Domain Name Server is a facility with is used for name-address resolution when attempting to locate hosts on a TCP/IP network.  It maps the given character name to the IP address. 

The Root-Level Domain Name Server searches for the owner of the root name such as    .EDU,  .COM,  .GOV,  .NET, etc., then directs the search to a lower-level domain name server.

The Local Domain Name Server resolves names on the LAN. There are 3 types of local DNS:

Master - collects names and provides information to other networks.

Slave - contains same information as Master, acts as a backup.

Caching - accumulates information to be shared only with local network.



Telnet
Telnet is a protocol and application that enables one to have login access to a virtual terminal on a remote host.  Its downside is that all telnet traffic including passwords are sent in plain clear text.

SSH
Secure Shell is a secure telnet replacement that encrypts all traffic, including passwords.  It provides the same functionality as telnet.

FTP
FTP is a well known and ubiquitous file transfer protocol.  Its used is also known by the terms uploading and downloading.  Two important commands are put to move a file from your machine to the remote machine, and get to retrieve a file from the remote server to your machine.


VNC
VNC is a widely used remote access facility that allows the client machine access the X desktop of the server machine.  It was developed by AT&T Laboratories U.K.   Another vendor TIGHTVNC provides like service but with the added compression features.

Some secure common services include:

HTTPS - HyperText Transport Protocol (port 443)

SFTP - File Transport Protocol (port 21-22)

SSH - Secure Shell Remote terminal access (port 23)

The Inetd and XinetD Server
These 2 services are Internet superservers.  They are launched at boot time and listen for connections on the network sockets. During startup they check the inetd.conf file to see what servies should be or are allowed to be running.  If there is a connection made on a service port listed in inetd.conf, inetd then launches the appropriate network service.  Once inetd launches a network service, it goes back to the listening state for more incoming connections.  If there is a connection attempt made on a port that inetd or any other network servcie is not listening to, the Linux kernel responds with a reset packet to close the connection.

Xinetd is a replacement for inetd, that adds more functionality.  Both xinetd and inetd can coexist on the same system.  Xinetd takes the extra security step of killing servers that arent in the configuration file and those that violate the configuration's access criteria.


The startup scripts for HTTPD, VSFTPD, NAMED, and SSHD can be found in /etc/init.d
 
The startup scripts for TELNET can be found in /etc/xinetd.d

/etc/services file contains a list of services and the designated ports that they should be running (listening) on.

The /var/log part of the filesystem tree contains the logging for services.

Some logging areas include:

HTTP - /var/log/httpd/access_log

HTTP - /var/log/httpd/error_log

FTP - /var/log/vsftpd.log

Telnet and SSH - /var/log/secure

Linux Boot (following boot) - /var/log/boot.log

Linux Kernel Loading - /var/log/dmesg

Linux System - /var/log/messages

The configuration files for each server are usually maintained in the /etc part of the filesystem tree.

Some configuration files:

HTTP - /etc/httpd/httpd.conf

FTP - /etc/vsftpd.conf

Telnet - /etc/issue and issue.net

DNS - /etc/named.conf and resolv.conf

Commands:

chkconfig is used to list, add, delete and set levels for services.

/sbin/service is used to start, stop, restart and get the status of servers.

/sbin/service network restart
/sbin/service httpd status
/sbin/service named stop

nslookup, host and dig are used to determine the IP Address of a domain name.

   


Week 12
Security and Firewalls


Definition:

Security Measures at a network level.
Limit network services.
Install a firewall.
Change IP address often.
Monitor traffic and user usage.
Detect intrusions.

Firewall -- A Firewall is a system which limits network access and safeguards certain relationships of trust, based upon a security policy, between two or more networks. Normally, a firewall is deployed between a trusted, protected private network and an untrusted public network, like the Internet.   The Firewall mechanism can be implemented in both hardware and software, or a combination of both.  Firewalls are frequently used to prevent unauthorized Internet users from accessing private networks connected to the Internet, especially intranets.  All messages entering or leaving the intranet pass through the gateway firewall, which examines each message and blocks or redirects those that do not meet the specified security criteria.   

A Firewall Policy defines what gets in, what gets out and what face is presented to the world.

Who can you trust?

What sources?

What protocols may access?

What ports may be accessed?

What destinations may be sought?

What Time of Day?

Reject or quietly Drop?

A Bastion Host is a machine, providing only firewall services, that sits between an unprotected external network and a protected internal LAN network.

A DMZ Host is a machine that executes in the Demilitarized Zone of the LAN. This is usually just off of the Internet router and before the Bastion Host. The DMZ Host provide publicly accessible services that run unprotected from the internal LAN network.  Security for hosts in the DMZ are more likely to be compromised and therefore require special considerations given their relatively unprotected status.  Particular attention should be made to outbound traffic in the event that an intruder is using the host as a remote plaform for launching attacks on others.

Network Address Translation (NAT) is a method that enables multiple machines within a LAN to connect to the outside Internet using a single server and a single IP address. Internal addresses and virtual connections are mapped to real external Internet addresses.

SNAT is source network address translation.
DNAT is destination network address translation.


IP Masquerading is a method that enables multiple machines within a LAN to connect to the outside Internet using a single server and a single IP address; and performing Network Address Translation (NAT).

Spoofing is   A technique used to gain unauthorized access to computers, whereby the intruder sends messages to a computer using a fake IP address, and possibly a fake port, in an attempt to gain access to a system by posing as an authorized user.
The intruder sends messages to a computer with an IP address indicating that the message is coming from a trusted. To engage in IP spoofing, a cracker must first use a variety of techniques to find an address of a trusted host and then modify the data packet headers so that it appears that the packets are coming from that host.   

Denial of Service Attack -- Using one or more computers to hammer a website with requests for service to such a degree that the server can perform no useful function. 

Commands:

netstat --inet  -l  will display only listening sockets.

The file /etc/sysconfig/iptables contains the firewall definition rules.

/sbin/chkconfig --level 234 iptables on ensures that iptables is started at boot time. to manage the firewall.

/sbin/service iptables restart|start|stop|status  is used to manage the firewall.

/sbin/iptables -L is used to display current firewall rules.

cp /etc/sysconfig/iptables /etc/sysconfig/iptables.old -p will save a backup of the firewall rules.

/sbin/service iptables save is used to implement a new set of firewall rules.

users prints a simple list of username of all how are currently logged on.

who shows more data about currently logged on users.

last displays data about current and recent logins.

last reboot to view information about the last system reboots that have occured.

lastlog displays data from /var/log/lastlog about past and current logins.


Week 13
System Generation


SYSGEN Definitions:

The System Generation Process consists of configuration, compilation, linking of the kernel and supporting load modules.

Quick Steps:

cd /usr/src/linux..... ensure that sym links appear in /usr/src/linux...

make mrproper    This will clean out old gen files. 

make menuconfig or make xconfig (xconfig requires uptodate QT) use as input your last known good config, save the output config for later input, do not overwrite the input config. 

make dep > dep.log 2>&1 (no longer needed for 2.6.10 and above) 

make clean make bzImage > bzimage.log 2>&1

make modules 

make modules_install

make install

Check your /boot/initrd, log files and /boot/grub/grub.conf files.

Now reboot.

Select new nucleus from GRUB menu. DONE...



File member /boot/grub/grub.conf will contain the pointers for the particular Linux nucleus or kernel that will be loaded at IPL time.


Week 14
The Network File System, SAMBA and CUPS


NFS Definitions:

The Network File System is the most common method of providing file sharing services in the LINUX and UNIX networking environments. It uses a client/server architecture that that enables transparent local access to remote files.

The process of making files available to remote clients is called exporting .

NFS Advantages:
Centralized administration.
Ease of backup, recovery and maintenance.
Users have a uniform view of shared data.
Users can log in from any system and still access their home directories.
Facilitates "thin client" configurations.


NFS Disadvantages: 
Performance can suffer due to network congestion.
Performance can be impacted by the affect of the request queue load placed upon the servers.
Security. NFS assumes implementation on a trusted network.

Data:
NSF requires access to TCP ports 111, 369 and 2049 . These settings can be found in file "/etc/services".

NSF requires the following daemons to be active:

nfsd : Provides all NFS services aside from below.

portmap : Enables NFS clients to discover the NFS services available.

mountd : Processes NFS client mount requests.

lockd : This is the kernel's lock manager.

rquotad : File system quota information.

statd : Provides for NFS lock recovery after abnormal ends.

/etc/hosts.deny contains list of machines that are denied access if not overridden by /etc/hosts.allow.

Take the default of    ALL: ALL

/etc/hosts.allow contains list of machines that are permitted access.
portmap: 192.168.0.0/255.255.0.0

portmap: 255.255.255.255 0.0.0.0

lockd: 192.168.0.0/255.255.0.0

mountd: 192.168.0.0/255.255.0.0

rquotad: 192.168.0.0/255.255.0.0

statd: 192.168.0.0/255.255.0.0

ALL: 127.0.0.1


/etc/exports
contains configuration data.
/home/ydisk   192.168.0.0/255.255.0.0(ro,sync,all_squash)

NSF exported files can be mounted by remote users in one of the following ways:

Via      mount command
            fstab definition
            autofs daemon

The Host machine must set the directory and file permissions permitted by the accessing remote users.

Server Commands:

/sbin/service nfs start | stop | restart | status used for startup, shutdown and status of NFS.

/usr/sbin/exportfs -ra reloads the exported file system.

/usr/sbin/showmount -a  will show all users from server perspective with NFS mounts.

Client Commands:

Example of a manual mount.

mount myserver.abc.com:/home/ydisk   /home/myuser/misc/ydisk
Example of a STATIC mount using an fstab entry.
myserver:/home/ydisk   /home/myuser/misc/ydisk   nfs   rsize=8192,wsize=8192,timeo=14,intr
Example of a DYNAMIC mount using autofs auto.master and auto.misc entries.
/home/myuser/misc   /etc/auto.misc   --timeout 60
ydisk   -ro,soft,intr,rsize=8192,wsize=8192   myserver.abc.com:/home/ydisk
common  -ro,soft,intr    myserver.abc.com:/home/usr/local/common

NOTE: Directory "misc" must exist on the client system and have no local subdirectories defined.  The autofs daemon will define the remote subdirectories under the directory (in this case "misc").

NOTE: If you want R/W access to the remote server files the permissions must be set appropriately.

/sbin/service autofs start | stop | restart | status | reload is used for startup, shutdown and status of the auto file system.

/sbin/service autofs restart

/sbin/service autofs status

/sbin/service autofs reload

SAMBA Definitions:

SAMBA is another acronym that stands for Server Message Block (SMB). SMB is the protocol used by Windows computers to communication with each other. SAMBA emulates SMB on Unix machines and lets them communicate with computers running Windows and share services such as file and printer access. (See References page)

SWAT is an acronym that stands for SAMBA Web Administration Tool. It provides a browser interface over port 901 that allows you to modify the SAMBA configuration and to start/stop the SAMBA tasks.

The SWAT interface running on the Unix server allows you to perform the following:

Set base, security and logging options.

Adjust performance and tuning values.

Set WINS options.

Define user file access.

Define printer access.

The SAMBA Client to be run on the Windows client should be configured the same as though it were communicating with another Windows machine. This includes:

Set File and Print Sharing for Microsoft Networks.

Set Client for Microsoft Networks.

Matching WorkGroup Name.

Use Network Neighborhood to define a connection to the SAMBA server.

SAMBA Data:

/etc/smb.conf is the configuration file.

/sbin/service smb start | stop | status | restart is used to manipulate the tasks.

/etc/services file requires "Swat 901/tcp" to be defined.

SAMBA Commands:

rpm -qa | egrep samba will check to see if SAMBA is installed on your system.

/sbin/service smb start | stop | status | restart is used to manipulate the SAMBA tasks.

http://mysambaserver:901 to access SWAT running on machine "mysambaserver"

CUPS Definitions:

CUPS is an acronym that stands for Common UNIX Printing System. 

CUPS provides a portable printing layer for UNIX®-based operating systems. It is developed and maintained by Apple Inc. to promote a standard printing solution. CUPS is the standard printing system used on MacOS® X and most Linux® distributions.

CUPS provides a browser interface over port 631 that allows you to maintain the CUPS configuration and to start/stop the printer tasks.

The CUPS http interface running on the Unix server allows you to perform the following:

Set authorization options.

Adjust printer default values.

Define user file access.

Start and Stop printers.

Set network accessability


CUPS Data:

/etc/cups.conf is the configuration file.

/sbin/service smb start | stop | status | restart is used to manipulate the tasks.

/etc/services file requires "CUPS 631/tcp" to be defined.

CUPS Commands:

rpm -qa | egrep cups will check to see if CUPS is installed on your system.

/sbin/service cups start | stop | status | restart is used to manipulate the SAMBA tasks.

http://localhost:901 to access http interface running on your local machine. 


[Return to Professor Page]