% text/plain

 
  % -------------------------------------------
  %  latex generated by: booktolatex.cgi   
  %   from source file : ../htdocs/books/linux-config/linux-config-book.txt       
  %                  on: 01 March 2024,  9:29pm         
  %         querystring: books/linux-config/linux-config-book.txt  
  %       document-root: /var/www/html
  %         script-name: /cgi-bin/booktopdf.cgi
  %         Server-name: bumble.sourceforge.net
  %          Sed-script: booktolatex.sed
  % ------------------------------------------- 

  \documentclass[a4paper,12pt]{article} 
  \usepackage[margin=0.4cm,noheadfoot]{geometry} 
  \usepackage{color}                   %% to use colours, use "xcolor" for more
  \usepackage{multicol}                %% for multiple columns 
  \usepackage{keystroke}               %% for keyboard key images 
  \usepackage[toc]{multitoc}           %% for multi column table of contents
  \usepackage{tocloft}                 %% to customize the table of contents
  \setcounter{tocdepth}{2}             %% only display 2 levels in the contents
  \setlength{\cftbeforesecskip}{0cm}   %% make the toc more compact
  \usepackage{listings}                %% for nice code listings
  %\lstset{language={},
  \lstset{language=,                 
    %% define special comment delimiters '##(' and ')' 
    moredelim=[s][\color{grey}\itshape\footnotesize\ttfamily]{~(}{)},
    basicstyle=\ttfamily,           %% fixed pitch font
    xleftmargin=1cm,                %% margin on the left outside the frames
    breaklines=true,                %% break long code lines
    breakatwhitespace=false,        %% break long code lines anywhere
    breakindent=10pt,               %% reduce the indent from 20pt to 10
    postbreak=\mbox{{\color{blue}\small$\Rightarrow$\space}},  %% mark with arrow
    showstringspaces=false,            %% dont show spaces within strings 
    framerule=5pt,                     %% thickness of the frames
    rulecolor=\color{lightgrey}, frame=l}   %% source code settings
  \usepackage{graphicx}                %% to include images
  \usepackage{fancybox}                %% boxes with rounded corners 
  \usepackage{wrapfig}                 %% flow text around tables, images 
  \usepackage{tabularx}                %% change width of tables 
  \usepackage[table]{xcolor}           %% alternate row colour tables
  \usepackage{booktabs}                %% for heavier rules in tables 
  \usepackage[small,compact]{titlesec} %% sections more compact, less space
  \usepackage{enumitem}                %% more compact and better lists 
  \setlist{noitemsep}                  %% reduce list item spacing 
  \usepackage{hyperref}     %% make urls into hyperlinks
  \hypersetup{              %% add "pdftex," if only pdf output is required
     colorlinks=true,       %% set up the colours for the hyperlinks 
     linkcolor=black,       %% internal document links black 
     urlcolor=black,        %% url links black 
     filecolor=red,       
     citecolor=red, 
     bookmarks=true, pdfpagemode=UseOutlines} 

  % define some colours to use
  \definecolor{lightgrey}{gray}{0.70}
  \definecolor{grey}{gray}{0.30}

  \titleformat{\section}[frame]    %% titlesec: create framed section headings
     {\normalfont} 
     {\filleft \footnotesize \enspace Section \thesection\enspace\enspace} 
     {3pt} {\bfseries\itshape\filright} 
     
  \title{Installing and Configuring The Linux Operating System } 
  \author{}
  \date{27 October 2011,  6:33pm} 
  \setlength{\parindent}{0pt}
  % \setlength{\parskip}{1ex}

  % label lists with stars
  \renewcommand{\labelitemi}{$\star$}

  \begin{document} 

  \centerline{\Large \bf Installing and Configuring The Linux Operating System } \medskip
  \begin{center}
    {\huge ``}\textit{}{\huge ''}
    \textsc{}
  \end{center}
  % -----------------------------------
  % the toc should be 2 columns because of the \multitoc package 
  \tableofcontents



    \begin{lstlisting}

This book will provide some hints on how to install and configure the Linux
operating system. This will largely concentrate on how to configure 
various devices when these devices are not automatically detected. This
can often be the most difficult part of installing a Linux OS.

SMALL DISTRIBUTIONS

  == small distros
  .. slitaz - the most popular, 16meg
  .. puppy - ok
  .. tinycore -
  ..

DOWNLOADING THE LINUX VERSION 

  * download an iso file for the version of linux

  * check a file against its md5 checksum. (download the file filename.md5.txt)
  >> md5sum -c filename.iso.md5.txt

  * or check the downloaded file with
  >> md5sum file  
  ##(compare the displayed value with the 'md5' value on the download site)
  
BURNING THE DOWNLOADED FILE TO DISK

  * burn at a slow speed??
  * dont use the computer for other tasks??

  * burn the iso to a compact disk, using the 'burn image' or
    'burn iso' mode of the cd recording software.

  * to check if the iso on the cd is good
  >> dd if=/dev/cdrom | md5sum 
  >> dd if=/dev/cdrom of=/dev/stdout | md5sum /dev/stdin 
  
  >> dd if=/dev/cdrom of=image.iso  ##(dumps the cd data to 'image.iso')
  >> md5sum

LIVE CD AND USB DISTRIBUTIONS
  
  'live cds' or usb stick are compact disks or usb memory sticks which can
  run a version (or distribution) of Linux without installing it to the
  computer hard disk and which can be 'booted' directly from the cd
  or the usb memory stick. This is very convenient for trying out new  
  distributions without in anyway affecting the current operating system
  (Windows or Linux) installed on the computer.

  >> http://www.livecdlist.com/ a list of linux live cds

LIVE USB ....

  @@ pendrivelinux.org
     good simple instructions for getting a variety of distributions on a 
     usb 'pendrive'

  == jargon
  @@ iso image
     Despite the name, this is not an image (picture) file which you
     can view, but a compressed file containing an entire operating
     system (or something else)
  @@ 

  Some distributions include their own specific tools to create 
  a 'live usb' on a memory stick. But you should still be able to 
  use unetbootin if you want to.

  == steps to create a live usb  
  .. download an 'iso' of the linux distribution.
  .. use 'md5' to check that the file downloaded properly
  .. use 'unetbootin' to install that iso file to a usb memory stick
  .. change the bios boot settings to usb, if possible
  .. multiple distributions on one stick is possible but harder 
  ..

  == tools 
  .. unetbootin - useful tool for installing to a usb
  ..

  * start unetbootin to install a distro to a usb
  >> sudo unetbootin

  Unetbootin can download a distribution from the net or use a
  local iso file. Currently (2010) it seems possible to only have one
  active distribution on the usb. 

  * use the file 'sum.txt' to check that the file downloaded well
  >> md5 -c sum.txt

BOOTING FROM USB ....

  On many computers, change the boot settings in the bios
  by pressing <f1> or <f2> or <f12> or something similar while the 
  computer is booting.

  On an eeepc press 'esc' as the machine is booting in order to 
  boot from a usb stick (changing the boot settings in the bios
  doesnt work)
  
KERNEL MESSAGES

  The kernel writes messages about its operation to /var/log/...

  * view the kernel messages
  >> tail -f /var/log/...

KERNEL VERSION 

  * display the version number of the linux kernel you are running
  >> uname -r

  * display the Linux kernel version as well as other compilation info.
  >> cat /proc/version
  
LINUX MODULES

  In linux 'device drivers' (as they are known in the PC world) are 
  refered to as modules or kernel modules. Modules in the 2.6 series of 
  linux kernels have an extension '.ko' (kernel object). In the 2.4 
  series of kernels the extension is just '.o'. Each 'device' on a 
  computer (such as a wifi 802.11 wireless card) needs one or more 
  modules to be loaded in order for it to work. 

  When Linux is installed on a computer, it normally tries to identify
  all the devices which form part of the computer and automatically
  use the correct modules for those devices. However this is not 
  always successful and you may need to configure the loading of 
  modules yourself.

  If hardware doesnt work a module needs to be installed.

   * see all modules which are currently loaded (being used)
   >> lsmod

   * search for a loaded module with 'rt' in its name
   >> lsmod | grep rt

   * load a particular module
   >> modprobe ...

   * show information for the given module 
   >> modinfo rt3090sta

BLACKLISTING MODULES ....

 If the kernel loads incorrect modules (or device drivers) it
 may be necessary to 'blacklist' them, that is, prevent these 
 erroneous modules from loading.

 * black list a module
 >> sudo vim /etc/modprobe.d/blacklist.conf
 >> type ... blacklist modulename

COMPILE A MODULE ....
 
   Each module needs to be compiled for a particular kernel. If a
   particular periferal is not working then a module may need to be
   compiled and installed. In order to compile a module the kernel
   headers must be available.

   * install the gnu 'c' compiler (gcc) to compile the module 
   >> sudo apt-get install build-essential 

   * install the linux kernel source headers (needed for compiling modules) 
   >> sudo apt-get install linux-headers-generic

   * find out the exact name of the device you need a module for
   >> sudo lshw

   Then search the manufacturers site for a linux driver for this site,
   or search other sources for a linux module.

   * download the source code for the module for the device
   >> wget ...

   * unpack the module sources (for gzipped files)
   >> tar xvzf xxx.tar.gz 

   * unpack the module sources (for bzipped files)
   >> tar xvjf xxx.tar.bz 

   * change directory to the module source folder (just unpacked)
   >> cd ...

   * read the compilation instructions for the module
   >> less README*

   * compile and install the module
   >> sudo make; sudo make install

   * build dependencies between modules 
   >> depmod -a

   * load the module 
   >> modprobe modulename

   * unload a module
   >> modprobe -r modulename
   
LOADING MODULES ....

  The process of loading a module (or 'driver') refers to telling the 
  kernel that you wish to use that module

  == tools 
  .. insmod - loads a single module, with no dependencies
  .. modprobe - loads a module and all its dependent modules
  ..

  * view the manual page for modules loaded at start-up
  >> man modules

  == manual pages
  .. modprobe.conf - configuring modprobe
  ..

  * load a module which is in the current folder.
  >> insmod hello.ko

MODULE ALIASES ...

  When using 'modprobe' a generic name for a module can be
  used instead of the 

  * view modules aliases already defined
  >> less /etc/modules.conf ??
  
UNLOADING MODULES ....

   * remove the ralink wireless card driver
   >> modprobe -r rt2860sta
   >> rmmod rt2860sta     ##(the same)

DEBUGGING MODULES ....

  Viewing and modifying linux modules requires you to be 
  the 'super-user' root. 

  * run a series of commands as to super user 
  >> sudo bash

  * search for available modules for a Realtex RTL8139 ethernet card
  >> sudo modprobe -l | grep 8139
  >> modprobe -l | grep 8139

  * search for available modules for a Boradcom wireless card
  >> modprobe -l | grep b43

  These commands search for what modules (called 'drivers' in the 
  microsoft world) are available to install, not what modules
  are currently being used.

  * list all loaded modules which have '8139' in their name 
  >> lsmod | grep 8139

  * see if the Broadcom wireless module is currently installed (loaded) 
  >> lsmod | grep b43
  
  * load the 'b43' module
  >> modprobe -v b43

  * list all modules currentlly installed
  >> lsmod

WRITE A MODULE ....

  * write a simple module
  \begin{lstlisting}

  #include <linux/module.h>       /* Needed by all modules */
  #include <linux/kernel.h>       /* Needed for KERN_INFO */
  #include <linux/init.h>         /* Needed for the macros */

  static int __init hello_start(void)
  {
  printk(KERN_INFO "Loading hello module...\n");
  printk(KERN_INFO "Hello world\n");
  return 0;
  }

  static void __exit hello_end(void)
  {
  printk(KERN_INFO "Goodbye Mr.\n");
  }

  module_init(hello_start);
  module_exit(hello_end);
  \end{lstlisting}

\section{Wireless Cards Configuration}

\emph{ Display lots of information about all network devices including wifi }
\begin{lstlisting}
  lshw -C network
\end{lstlisting}
 
  This also displays the driver which the card is using under the 
  'configuration' heading.

\emph{ Load and configure a ralink wireless module with linux kernel 2.4 series }
\begin{lstlisting}
  /sbin/insmod rt2860sta.o
\end{lstlisting}
\begin{lstlisting}
  /sbin/ifconfig ra0 inet YOUR_IP up
\end{lstlisting}

\emph{ Load and configure a ralink wireless module with linux kernel 2.6 series }
\begin{lstlisting}
  /sbin/insmod rt2860sta.ko
\end{lstlisting}
\begin{lstlisting}
  /sbin/ifconfig ra0 inet YOUR_IP up
\end{lstlisting}

\emph{ Check what network (and wireless) interfaces are available }
\begin{lstlisting}
  ifconfig -a
\end{lstlisting}

\section{Audio Devices Configuration}

\emph{ Display information about the audio devices available }
\begin{lstlisting}
  sudo lshw -C multimedia | less
\end{lstlisting}

\section{Debugging Usb Devices}
  
\begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline]
 \item[\url{http://www.basicconfig.com/linux/mount}]
\end{description}

\emph{ Check if a usb device has been recognised }
\begin{lstlisting}
  lsusb
\end{lstlisting}

\emph{ Plug in the usb device and look in /proc/scsi }
\begin{lstlisting}
  cat /proc/scsi/scsi  
\end{lstlisting}
  (the make and model of the device should be displayed)
  
\emph{ See what drive the usb device is attached to }
\begin{lstlisting}
  dmesg | grep sd
\end{lstlisting}

\emph{ Check PCI devices }
\begin{lstlisting}
  cat /proc/pci
\end{lstlisting}
\begin{lstlisting}
  lspci
\end{lstlisting}

\emph{ Rescan the the scsi bus to (hopefully) detect a new device }
\begin{lstlisting}
  echo "- - -" > /sys/class/scsi_host/hostX/scan
\end{lstlisting}

\section{Analysing Hardware}

   One of the crucial aspects of configuring your linux system to 
   work correctly is to be able to identify each of the components
   which make up the computer system. These components are often 
   referred to as 'devices' (except in the case of ram memory, or 
   the cpu)


  \arrayrulecolor{gray}
  \begin{center}
  \begin{tabular}{ |rl| }
    \multicolumn{2}{c}{\textbf{ tools for analysing hardware components }} \\
  \hline

   \texttt{ lspci } & Information about all pci components \\ 

   \texttt{ lshw } & Queries the sysfs system \\ 

   \texttt{ lsusb } & \\ 

   \texttt{ linuxinfo  } \\ 

    \hline
    \end{tabular}
    \end{center}
\emph{ Get a full report of hardware and operating system in html format }
\begin{lstlisting}
  hardinfo
\end{lstlisting}

\emph{ Another way to get lots of hardware and operating system info }
 \begin{lstlisting}
   uname -a > eg.txt
   lspci >> eg.txt
   lspci -vv >> system.txt
 \end{lstlisting}

\emph{ See the linux start-up messages  }
\begin{lstlisting}
  dmesg | less
\end{lstlisting}

\emph{ Use lspci to get the names of chipsets of hardware }
\begin{lstlisting}
  lspci
\end{lstlisting}
\begin{lstlisting}
  lspci -vv    ~(provides a more detailed listing)
\end{lstlisting}

\emph{ See lots of hardware info }
\begin{lstlisting}
  lshw
\end{lstlisting}

\emph{ Display information, such as type, manufacture for network devices }
\begin{lstlisting}
  lshw -C network
\end{lstlisting}

\subsection{Cpu Information}

  The cpu or 'central processing unit' is the core component of the 
  computer which carries out the majority of actual computations
  performed by the computer.

\emph{ Get information about the cpu }
\begin{lstlisting}
  cat /proc/cpuinfo
\end{lstlisting}

\subsection{Ram Memory}

\emph{ Getinformation about Ram memory }
\begin{lstlisting}
  cat /proc/meminfo
\end{lstlisting}

\section{Use An Ms Windows Driver On Linux}

 first find the .INF file for the hardware

\emph{ Install a windows driver }
\begin{lstlisting}
  ndiswrapper -i /path/to/.inf
\end{lstlisting}

\emph{ View the ms windows drivers being used current }
\begin{lstlisting}
  ndiswrapper -l
\end{lstlisting}

\emph{ Stop linux from loading linux driver 'b43' (broadcom wireless card) }
\begin{lstlisting}
  echo "blacklist b43" >> /etc/modprobe.conf
\end{lstlisting}
  
\section{Services}

\emph{ Install or uninstall a service to run at computer start-up }
\begin{lstlisting}
  chkconfig
\end{lstlisting}

\emph{ Show all services which will automatically start at boot-time }
\begin{lstlisting}
  chkconfig
\end{lstlisting}

\emph{ Display if the 'apache2' web-server service will start at boot-time }
\begin{lstlisting}
  chkconfig apache2
\end{lstlisting}

\emph{ Stop the 'apache2' web-server from starting at boot-time }
\begin{lstlisting}
  sudo chkconfig apache2 off
\end{lstlisting}

NOTES:

  Unclassified notes

\emph{ Get info on RAM Slots and Max RAM. }
\begin{lstlisting}
  dmidecode 2.9 | grep "Maximum Capacity"; dmidecode -t 17 | grep Size
\end{lstlisting}
 
\emph{ Quickly (soft-)reboot skipping hardware checks }
\begin{lstlisting}
  /sbin/kexec -l /boot/$KERNEL --append="$KERNELPARAMTERS" --initrd=/boot/$INITRD; sync; /sbin/kexec -e
\end{lstlisting}
 
\emph{ Lists the supported memory types and how much your board can }
\begin{lstlisting}
  sudo dmidecode -t 5,16
\end{lstlisting}
 
\emph{ Backup your OpenWRT config (only the config) }
\begin{lstlisting}
  curl -d 'username=root&password=your-good-password' "http://router/cgi-bin/luci/admin/system/backup?backup=kthxbye" > `date +%Y%d%m`_config_backup.tgz
\end{lstlisting}

   \end{document}
