\documentclass {article}
\begin {document}
\title {An Introduction to Linux and UNIX for Newbies\\ \large The
Opensource Club}
\author {Isaac Jones}
\date {10/7/2001}

\maketitle
\section  {Introduction}
\subsection {The Opensource Club}
\begin {itemize}
\item The Opensource Club is a group of Opensource and Free Software
advocates. We are here to encourage the use of software which improves
your freedom. 
\item The Opensource Club Web page:\\
http://www.cis.ohio-state.edu/opensource
\item schedule of events:\\
http://www.cis.ohio-state.edu/opensource/events.html
\item this talk: http://www.cis.ohio-state.edu/opensource/lectures/newbies/
\end {itemize}
\subsection  {The Philosophy of Free Software}
\begin {itemize}
\item From the GNU web page:
 Free software is a matter of freedom: people should be free to use
 software in all the ways that are socially useful. Software differs
 from material objects--such as chairs, sandwiches, and gasoline--in
 that it can be copied and changed much more easily. These
 possibilities make software as useful as it is; we believe software
 users should be able to make use of them.

\item Further Reference: http://www.gnu.org/philosophy
\item While there is a practical difference between Open Source and
Free Software, we will not talk about that here \& now.  The opensource
club supports both Free Software and Opensource Software.
\end {itemize}

\subsection  {Technical Aspects of free software:}

 Since you have access to the source code, you can alter it in order
 to improve the software and to customize it.  You can verify for
 yourself that the software is secure, that it contains no viruses or
 backdoors, that its not spying on you and sending information to the
 government (if you live in a country where you can't trust the
 government) or to anyone else.

\begin {itemize}
\item Linux and UNIX are very similar.  From a user's perspective there
is hardly any difference, so virtually everything you learn in this
talk can be applied to both Linux, UNIX, and any of the BSD systems.
This talk will focus mainly on Linux, and the UNIX environment we use
at the CIS department.
\end {itemize}

\subsection {Configuration for this tutorial} We're going to create a
remote X session on a machine that I run.  You may also use the CIS
Department's UNIX machines if you want to work there (you'll have to
change your shell, but thats explained below.)\\

So log into your CIS account if you want to use that instead of Linux,
or get to the Login point on the Xterm in front of you.  Please share
your terminal with the person sitting next to you, as we'll go through
lots of examples which you will probably want to try on your own.

\section  {bash shell navigation}

\subsection {What is a shell} "The shell's job is to translate the user's
command lines into operating system instructions."
\begin {itemize}
\item Run some commands (xchat, xemacs, mozilla, ls, xclock)
\item whoami
\end {itemize}

\subsection {Other shells} Other shells include tcsh (default at CIS) but since bash is the
default in Linux, we will talk about bash.

\subsection  {how to get bash at cis} run: /usr/contrib/bin/bash

\begin{verbatim}
echo $SHELL \# tells you which shell you're using now
passwd -r nis -e #then input:
/usr/contrib/bin/bash
\end{verbatim}

\subsection {Directory Structure}
\begin {itemize}
\item Files and Directories (``Folders'') are organized in a tree
hierarchy.  This should be familiar from MacOS or Windows.
\item ``pwd'' tells you what directory you're in now.
\item / is the root of everything.  ``cd /''
\item \begin{verbatim}~/ means "your" home directory \end{verbatim}
\end {itemize}

\subsection {Command history and realted topics}
\begin {itemize}
\item After running some commands
\item use arrow keys or C-p \& C-n to go back \& forth in the history
\item find . -print | xargs grep "mail" \#like rgrep
\item If you know what command in the history you're looking for, after
running a few more commands, I can use C-r to search backwards for
"mail" without having to scroll up, this is part of emacs editing
mode.
\end {itemize}

\subsection {shell vars}
\begin {itemize}
\item echo \$SHELL \#we did this before
\item echo \$TERM
\item echo \$PAGER
\item echo \$PRINTER 
\item echo \$TAB TAB
\item \begin{verbatim}
export TEMP=$PS1 #save it for later
export PS1="hi my name is hal: "
export PS1="\t \u@\h: \w\n% "
#if you want to change it back to what it was 
#before:
export PS1=\$TEMP 
 # otherwise, it'll reset next time we run bash,
 # we'll learn later how to save settings like
 # this.
\end{verbatim}
\item shell variables can affect things besides the shell.
\begin{verbatim}
    export TEMP2=$TERM
    export TERM=dumb
    emacs -nw -q
    export TERM=$TEMP2
    emacs -nw -q
\end{verbatim}
\end {itemize}
\subsection {The path}
\begin {itemize}
\item in CIS department, controlled w/ 'subscribe' program, but this
will not work for bash
\item a list colon-separated of directories to search to find which
program to run when you enter a command
\item what does the path look like?  echo \$PATH
\item \begin{verbatim}type emacs
    export TEMP=$PATH
    export PATH=
    type emacs
    ls
    type ls
    type cd
    export PATH=/usr/bin
    type emacs #its been found
    type ls #still not found
    for FILE in /bin/* ; do  echo "$FILE"; done 
     #emulate ls
    export PATH=/bin/:$PATH
    type ls #now we found it
    export PATH=$TEMP #get our old path back
    export PATH=${HOME}/usr/bin:$PATH 
    #for your own executables
\end{verbatim}
\item why do echo and cd work?  They are built in shell commands, as
type tells us: type cd; type echo; type type
\item type is similar to 'which', but which should not be used in bash
because it won't always return the correct answer: on cis dept
computers, in bash "type time; which time;"
\item The current directory '.'   
\begin {itemize}
\item Sometimes, if you want to run a program in the current 'working'
directory, you have to run it like this: ./myprogram 
\item echo \$PATH \#do we see :.:?  this can be bad, but it makes some
things easier.
\item why it might be bad: If someone keeps a program called 'ls' in
their home directory, and if you have '.' in your path, cd ~evilMan;ls
might execute THEIR version of ls.  If they are evil, this can be bad!
\item on the other hand, it makes people who are ignorant of the PATH
variable happy, because they can run their programs without saying
'./myGoodProgram'.
\item \begin{verbatim}
#BUT it still might not help, you should always
#run programs in the current directory with the
# "./" notation
export $PATH=$PATH:.
mkdir temp
cd temp;ls
emacs -nw -q helloWorld.c
  #C program:
  #include <stdio.h>
  int main() {
   printf ("Hello, World.\n");
   return 0;
  }
  C-x C-c ;to exit emacs
gcc helloWorld.c -otest
test #why doesn't my program do anything!?
echo $PATH #dot is in my path
type test 
#oops, test is built in!, it'll get run first
./test 
which test
\end{verbatim}
\item one thing to note here is not to name your program 'test', or
on some systems, you shouldn't name your program a.out this is a
common mistake. 
\item The big lesson: don't put '.' in your path, use the "./" notation
instead. 
\end {itemize}
\item (also works on tcsh)
\end {itemize}
\subsection {aliases}
\begin {itemize}
\item \begin{verbatim}
ls -l
alias ll='ls -l'
type ll
ll
alias emacs-quick='emacs -nw -q'
emacs-quick
#also can be used for long path names:
mkdir -p ~/tmp/i/really/like/long/path/\
 names/because/im/anal
alias cdFast='cd ~/tmp/i/really/like/long\
 /path/names/because/im/anal'
cdFast
alias emasc=emacs
emasc
\end{verbatim}
\item similar on tcsh
\end {itemize}
\subsection {shell input files}
\begin{verbatim}
\${HOME}/.bashrc, 
.bash_profile, 
.profile 
(ls -a /etc/skel) 
\end{verbatim}
\begin {itemize}
\item \begin{verbatim}more /etc/skel/{.bash_profile, .bashrc}\end{verbatim}
\item .basrhc:
    add to this file any shell settings that you want to keep:
aliases, path settings, shell variables (CVSROOT, PS1), or programs
that you want executed whenever you login.
\item \begin{verbatim}
    more ~ijones/.bashrc
    source ~ijones/.bashrc 
    #notice how the prompt changes, since I
    #have a prompt set PS1 in my .bashrc.
\end{verbatim}
\item \begin{verbatim}
.bash\_profile:
for login shells, should probably ``source ~/.bashrc''.
I don't really use this file, except to run my .bashrc. 
\end{verbatim}


\item from the man page 'man bash': 
\begin{verbatim}
FILES
/bin/bash
    The bash executable #may be elsewhere
/etc/profile
    The  systemwide  initialization  file, executed for
    login shells
~/.bash_profile
    The  personal  initialization  file,  executed  for
    login shells
~/.bashrc
    The individual per-interactive-shell startup file
~/.bash_logout
    The  individual  login shell cleanup file, executed
    when a login shell exits
~/.inputrc
    Individual readline initialization file
\end{verbatim}
\item bash also uses .profile
\end {itemize}
\subsection {IO redirection} redirection is very good for writing test scripts
\begin {itemize}
\item \begin{verbatim}use `<' to redirect `stdin' (standard input) from a file\end{verbatim}
\begin {itemize}
\item \begin{verbatim}cat < ~/.bashrc #just like 'cat ~/.bashrc'\end{verbatim}
\item mail newbie < ~/.bashrc
\end {itemize}
\item \begin{verbatim}use `>' to redirect `stdout' (standard output) to a file\end{verbatim}
\begin {itemize}
\item in case you want to save the output, or look at it later, or if
the output is too much to fit on your screen.
\item \begin{verbatim}
ls /etc ; ls /etc > ectOutput
more etcOutput\end{verbatim}
\end {itemize}
\item (redirection also works similarly on tcsh)
\item we'll talk about pipes after we talk about basic unix utilities,
even though they are really part of the shell.  Using a pipe is
redirection of the output from one program to the input to another.
\end {itemize}
\subsection {Misc}
\begin {itemize}
\item editing modes set -o emacs ||  set -o vi
\begin {itemize}
\item emacs: back: M-b, forward: M-f, beginLine: C-a, endLine: C-e
\end {itemize}
\item Further Reference published by O'Reilly:\\
``Learning the bash shell'' 
http://www.oreilly.com/catalog/bash2/ \\
``Using CSH and TCSH'': http://www.oreilly.com/catalog/tcsh/
\end {itemize}

\section  {Basic Unix Utilities}
\begin{itemize}
\item man, xman, info, apropos
\begin{itemize}
\item UNIX built-in help, use these to get information on almost any
Unix program.
\item man ls; man man; man info; man xman; 
\item apropos "X windows": shows you commands with the word X Windows in
the title.
\end{itemize}
\item file browsers are similar to such things on windows, they give you
a graphical view of your file hierarchy.
\begin{itemize}
\item konqueror (KDE)
\item gmc (gnome)
\item nautilus (gnome)
\item /usr/dt/bin/dtfile (CDEvil)
\end{itemize}

\item ls, mkdir, cp, cd, etc: 
\item more, less, cat: to view files, cat to concatinate files

\begin{itemize}
\item more ~/.bashrc
\item less \$MAIL
\item \begin{verbatim}cat file1 file2>file3\end{verbatim}
\end{itemize}

\item find stuff
\begin{itemize}
\item find
\item find . -name *substring*

\item locate: uses a database which it rebuilds periodically, so it
   doesnt have to search the entire hard drive.
\item whereis: will find binaries, source, and man pages for a command
\end{itemize}

\item tar, gtar, zip: are used for compression 
\begin{itemize}
\item gzip myfile; gunzip myfile
\item tar -zcvf mydir.tgz mydir\#zip, create, verbose, filename
\item zip \& unzip are similar
\end{itemize}


\item secure stuff:
\begin{itemize}
\item ssh replaces telnet (also sets DISPLAY)
\item stdsun script on CIS: helps manage ssh keys and use the stdsun
    alias at the same time, since the IP address is always different
    when using stdsun.

\item scp: securely copy from one computer to another, uses ssh \\
scp ijones@monk.syntaxpolice.org:/home/ijones/tmp/myfile ./myfile
\end{itemize}
\item script FIXME

\item grep: search through a file w/ regular expressions.  REs are too
    complex to talk about here, but for simple text searching, grep is
    also useful.  It searches a file for a string.
          grep bash .*
          egrep b.sh .*
          egrep b*sh
          grep -r "love affair" ~/Mail 

\section {pipes (and programs that like pipes)}
\begin{itemize}
\item piping is redirection of stdout, instead of redirecting it to a
file, you can redirect it to the input of a program, like connecting
two pipes together.  Use the $|$ character.
\item you can redirect to any old program
\item more, less
\begin{verbatim}
ls /etc | less
#whenever output is too big, you can use | less
#use q to quit less, :n for next file, / to search
\end{verbatim}
\item tee: records stdout in a file, but also displays it to stdout (the
screen)
\begin{verbatim}
      ls * |tee teeFile
      ls /etc/|tee teeFile2|less
\end{verbatim}
\item grep
\begin{verbatim}
 who | grep ijones
 ls /etc|grep net #see all files containing net
\end{verbatim}      
\item xargs: run a command using stdin as the arguments to the command
\begin{verbatim}
find . -print | xargs grep "mail" #like rgrep
find . -name *.cpp |xargs less
 #as opposed to:
find . -name *.cpp |less
\end{verbatim}
\end{itemize}
\item bash (shell) builtins
\begin{itemize}
\item source: execute a shell script within this environment
\item pushd, popd: change directories
\begin{verbatim}
 pushd . 
 cd 
 pwd
 popd
\end{verbatim}
\end{itemize}
\end{itemize}


\section  {File Permissions (in brief)}
\begin{itemize}
\item ls -l \#see groups and file permissions
\item chmod
\begin{itemize}
\item info chmod to learn more
\item \begin{verbatim}
chmod (u | g | o | a) (+ | -) (r | w | x) are the basics
chmod u+x myProgram
#to make a script or program executable perl
 #example
chmod a+rx ${HOME}/WWW                  
chmod -R a+rX ${HOME}/WWW 
#will make all your WWW files world readable
\end{verbatim}  
\end{itemize}

\item umask: sets the default file permissions (man umask)
\item groups: the 'g' flag above stands for group. (use ls -l to see
the group that owns a file, use 'groups' to see what group your in,
use chgrp to change the group of a file you own)
\end{itemize}
\section {The X Windows System (in brief)}
\begin{itemize}
\item What is it: The X Windows System is a portable,
network-transparent window system.  It is what makes Unix look like
the MacOS or Windows with dialog boxes, menus, etc.  
\item X remote w/ ssh:  ssh can configure your remote x session for
you.  How to do this depends on which version of ssh you have.
\begin{verbatim}
ssh -X theta.cis.ohio-state.edu
 #with the version on debian
man ssh 
 #for how to do it with your version
\end{verbatim}
\item vnc (eXceed): Remote access to a full X Session, as if you were
on the computer.  You are doing this now, the terminals you're using
are talking to a machine which may be anywhere on the internet.  I
recommend using vnc as it is generally faster on low bandwidth
networks. 
 \begin{verbatim}see http://www.cis.ohio-state.edu/~rowland/vnc\end{verbatim}

\item DISPLAY, xhost.  If you don't use ssh, then you may have to
configure the DISPLAY variable and the xhost permissions by hand.  Its
best to use ssh!
\item window managers and windowing environments
\begin{itemize}
\item gnome
\item KDE
\item fvwm
\item sawfish
\item which to choose?  Everyone likes a different one!  Try using
gnome and KDE if you like fancy stuff.
\end{itemize}
\end{itemize}

\section {More Resources}
\begin{itemize}
\item The Opensource Club Web page:\\
http://www.cis.ohio-state.edu/opensource
\item ``Learning the bash shell'', published by
\begin{verbatim}O'Reilly: http://www.oreilly.com/catalog/bash2/\end{verbatim}
\item ``Beginning Linux Programming'', published by Wrox Press
\item http://www.linuxdoc.org/
\item http://www.linuxdoc.org/HOWTO/
\end{itemize}

\section {Important stuff thats outside the scope of this talk, these
things will be covered in later talks}
\begin{itemize}
\item Configuring The X Windows System
\item basic emacs (the extensable text editor)
\item word processing (abbyword, staroffice, latex)
\item printing, -p -oduplex, -onobanner
\item root Access
\item installation
\item programming utilities (future talk)
\item distinction between different Linux distros \& different bsd versions
\item basic program installation (tar, zip, make;make install)

\end{itemize}

\end {document}
