#!/bin/bash
PATH=$PATH:/usr/local/lib/inx
. inx_essentials
maybe_switch

#grab the functions

function f-tutorial ()
{
white # temporary clock colour fix
clear
fig-col
figlet "  inx      Tutorial"
head-col
echo "  Preferably, follow the order below... "
 
info-col

cat << EOTUTORIAL

  0: To Begin at the Beginning... 
  1: Basic Commands - Tell the Machine to Pay Attention
  2: Paging the Man
  3: Getting Useful
  4: Surreal Searches
  5: Declaration of Independence
  6: Who's Who and What's What
  7: Power Trips
  8: Package Deals


EOTUTORIAL

head-col
echo "  m: to return to the main menu"
echo "  f: Flip colours."
echo "  x: for a command prompt"

printf "\n\n"
f-ttynum
read -s -n 1 CHOICE

case "$CHOICE" in

	0)
	f-tutorial.0
	;;
	1)
	f-tutorial.1
	;;
	2)
	f-tutorial.2
	;;
	3)
	f-tutorial.3
	;;
	4)
	f-tutorial.4
	;;
	5)
	f-tutorial.5
	;;
	6)
	f-tutorial.6
	;;
	7)
	f-tutorial.7
	;;
	8)
	f-tutorial.8
	;;
	m)
	exec menu
	;;
	x)
	clear
	f-prompt	
	;;
	f)
	switch
	f-tutorial
	;;
	*)
	f-tutorial
	;;

esac


}

function f-tutorial.0 ()
{
clear
cyan ; bold
printf "\n\n"
echo "Tutorial - A Command Line Introduction"
printf "\n\n"
white
echo "Hit < m > to return to the tutorial menu at any pause - "
echo "Hit < x > to get a command prompt."
echo
echo "In this tutorial, you can move on at your own pace"
echo "simply by hitting any other key, unless otherwise prompted."
yellow
echo
echo "If in doubt, I suggest the space bar... most apps use it to page down."
echo
echo "We'll start now to get you in the habit..."
echo "Hit the <space> bar to continue"
f-tutescape
white
echo " "
echo "Command tutorials usually start with simple commands."
echo " "
echo "This one starts with an explanation of directories, because"
echo "without understanding how that works, you will be lost - you"
echo "need to know where you are in the system before you can usefully"
echo "do things. You then learn how to move around in that system."
echo " "
printf "\n\n"
echo "Directories ( also known as \"folders\" ), are shown by a path"
echo "written in the form"
echo " "
echo "/path/to/the/destination/directory"
echo " "
f-tutescape

echo
echo "Everything starts from \"/\""
echo " "
echo "That needs explaining... "
echo " "
echo "From \"/\" the contents of the whole inx system is something like.."
printf "\n\n"
ls -a --color=auto /
white ; bold 
printf "\n\n"
echo "this of course tells you nothing if you don't know what you are looking at :-) "
echo "Mostly those are directories - subdirectories of / "
echo 
echo 
echo "Normally when you log in, you land in your \"home\" directory."
echo
echo "The path from \"/\" to where you currently are looks like:"
echo
pwd
echo
echo "So for example /home is directly below \"/\" , and "
echo "$HOME is \"inside\" or \"below\" /home "
echo
echo 
echo "You can think of this as a root system branching out beneath a tree"
echo "... or as a series of boxes within boxes, with \"/\" as the outermost box."
echo 
echo "Hit <space> to see a simple example using the /usr directory"
echo " ( Give it a moment to start up - q to quit from the graphic)"
f-tutescape
fbi /usr/share/graphics/directory-boxes.png
clear
echo 
echo "Before moving on to other commands, you find out how to see"
echo "what is in the places defined by the directory structure."
echo " "
echo "In this tutorial, each exercise gives you a command prompt and a new \"shell\"."
echo "The command prompt looks something like this ..."
echo " "
echo "$USER@$HOSTNAME:$PWD $"
echo
echo
echo " ... your home directory has the symbol \" ~ \" (tilde) as a shorthand, so when "
echo "in that directory you will not see the full path as shown above."
echo
echo "Each time you are asked to do an exercise, you exit the shell to come back to this"
echo "tutorial. To do that, you can type "
echo
yellow
echo "exit"
white
echo
echo "... followed by the <enter> key"
echo
echo "Commands will be shown here in yellow, as above."
printf "\n\n"
f-tutescape

echo "The command program you will be using is called \"bash\" -"
echo "which stands for \"Bourne Again SHell\" because it is based on the earlier"
echo "\"Bourne\" shell... you'll see a lot of these kinds of \"jokes\"... don't blame me!"
echo
echo "Here is a shell (/bin/bash)- try typing"
yellow
echo
echo "pwd"
echo
white 
echo "The \"pwd\" command means \"print working directory\""
echo " ... then type "
echo
yellow
echo "exit"
white ; unbold
echo
/bin/bash
bold 
clear
echo
echo "Welcome back..."
echo
echo "Let's have a closer look at the directory idea"
echo
echo "As an example, we could show /home/ like this..."
printf "\n\n"

yellow
cat << EOD

			/home
	       ___________|_________
	      |                     |
	/home/$USER             (/home/someone-else)
	  ___|____________________________________________________
         |         |             |          |         |           |		
   about-inx  example-content  intro-text  plait  screen-notes  video

EOD
	 			
white
f-tutescape
echo
echo "Suppose we want to see what is in the \"plait\" directory."
echo "To return from anywhere to $HOME, a shortcut is simply to type"
echo
yellow
echo "cd"
echo
white
echo "If we are in our home directory, we can type "
echo
yellow
echo "cd plait"
echo
white
echo "then"
echo
yellow
echo "ls"
echo
white
printf "to see the contents. Try that now, then "
yellow
printf "exit "
white
echo "again to return to the tutorial"
echo
unbold
/bin/bash
bold 
echo
echo "\"ls\" only gives you the short version - there are many options to ls."

f-tutescape


echo
echo "For example, to see all files in a directory, including \"dot\" files,"
echo
echo "(Dot files are \"hidden\" files by default, starting with a dot -" 
echo "full stop or period, if you prefer) "
echo
echo "you can type"
echo
yellow
echo
echo "ls -a"
echo
white
printf "Try that now, then "
yellow
printf "exit "
white
echo "as usual..."
echo
echo "Tip: a shortcut for \"exit\" is ctrl+d"
unbold
echo
/bin/bash
white
bold
echo
echo "As you saw, different files have colour codes."
echo "For example, links to other files are cyan, and directories are blue"
f-tutescape
echo
echo "Let's get a little more adventurous."
echo "This time, type "
yellow
echo
echo "cd /usr/local/bin"
echo
echo "ls"
echo
printf "exit "
white
echo "(or control+d , as suggested in the previous tip)"
echo
white
unbold
/bin/bash
echo
bold 
echo "What you saw in the /usr/local/bin directory was the collection"
echo "of scripts and shell functions used to run \"INX\" menus etc."
echo
echo "Of course, you don't actually need to change to a directory "
echo "to see it - for instance you could simply have typed"
yellow
echo
echo "ls /usr/local/bin"

f-tutescape

white 
echo
echo "Now, typing long paths like /usr/lib/foo/bar/flurble gets old fast."
echo
echo "Fortunately the programmers of the shell agreed, so we have a short cut."
echo
echo "To complete a path we can hit the tab key. Thus for example"
echo
yellow
echo "cd /us <tab> loc <tab> bi <tab> expands to"
white
echo
echo "cd /usr/local/bin"
echo
echo "Armed with this knowledge, try navigating to /var/cache/apt/archives,"
echo "then return to your home directory ( $HOME) by just typing \"cd\""
echo "as explained earlier."
echo
unbold
/bin/bash
bold
echo
echo "OK. Using tab like this is a habit to be encouraged, obviously ;-)"
echo
echo "Think of moving from one directory to another as if you were"
echo "actually moving from place to place. At any time, you are in "
echo "whatever directory is returned by the \"pwd\" command - or, more simply,"
echo "the path shown by the default prompt."

f-tutescape

echo
echo "The more observant user will have noticed something extra in the inx prompt..."
echo
echo "Because this is a \"console only\" system, it is nice to know which virtual"
echo "terminal you are currently using. ( tty1, tty2 and so on )."

f-tutescape


echo
echo "Now, because at any given moment you can only see the terminal"
echo "that you are looking at, you might not be aware that there are"
echo "six altogether - and you can easily move from one to another..."
echo
echo "I will now show you your six vt virtual terminals ( tty1-tty6 )"
echo 
echo
echo "This will only take a few seconds and it doesn't "
echo "hurt a bit...  Hit <space> to see ... "

read -s -n 1

for tty in $(seq 1 6) ; do chvt $tty && sleep 2 ; done ; chvt $(tty | cut -c 9)

clear
cyan
echo
echo "So - I have set up some menus and stuff on each tty for you."
echo "You can always customise to your taste, of course - each menu has an escape key..."
echo
echo
white
echo "Try navigating through the tty numbers - "
echo
yellow
echo "alt + arrow keys   or  alt + F1-6"
echo
white
echo 
echo
green
echo "It might be an idea to end up here on $(tty) when you have finished..."
white
f-tutescape

echo

printf "\n\n\n"
cat << EOC
So now you have an idea of how to navigate the file system structure, and
how to switch between "workspaces" by using virtual terminals.

That's already more than a lot of users know !

A few commands coming up, in tutorial 1 - choose it from the menu.
EOC
echo
echo
f-tutescape 

f-tutorial

}
function f-tutorial.1 ()
{
clear
cyan ; bold 
echo
echo "In Which We Learn to Boss the Computer Around"
echo
echo
white

cat << EO0
In the Beginning, you learnt a bit about navigation.

You saw some directories, and how to access them.

You had a look at them...

... and you also saw that you have up to six virtual terminals
to play with ...

EO0

echo
yellow
echo "As before, hit < m > to return to the tutorial menu, < space > to continue." 
white

cat << EON

Just being able to navigate and look is not much use, of course.
We need to issue commands as well...
EON

cat << EO1

It would be nice if this were magic, but despite the appearance
fostered by pretty point-and-click interfaces, all operating systems
have underlying commands that tell the machine what to do next.

Fortunately for you, you are using an operating system that does not hide this !

EO1

f-tutescape



echo
cat << EO2

So, let's begin with being "creative" ...

We can create files and directories with nothing in them...

To create a file named "foo" ,

EO2

echo
yellow
echo "touch foo"
echo
white
echo "[ It is a venerable tradition to use \"foo\" for such purposes ;-) ]"
echo
echo "Let's see how to make a directory -"
yellow
echo
echo "mkdir bar"
echo
white
echo "[ Another traditional name... ]"
echo
echo "Note that the UNIX greybeards who came up with this stuff"
echo "were lazy typists...  mkdir ? "
echo
echo "Suppose we want to \"move\" the \"foo\" file into the \"bar\" directory..."
echo
yellow
echo "mv foo bar "
echo
white
echo "More lazy typing!"
echo

f-tutescape

cyan
echo
echo "So, use your typing skills to try some \"creative\" stuff."
echo
white
printf "The usual instructions apply - "
yellow
printf "exit"
white
printf " or "
yellow
printf "ctrl+d"
white
echo " to return to the tutorial."
echo
echo "Check that you are in $HOME first, or you might not have permission"
echo "to get \"creative\" :-) "
echo
echo "Remember, from the first tutorial, that typing \"cd\""
echo "will return you to $HOME"
echo
cyan
echo "Cheatsheet: "
yellow
echo
echo "touch foo"
echo
echo "mkdir bar"
echo
echo "mv foo bar"
white
echo
echo "Then have a look at the \"bar\" directory:"
yellow
echo
echo "ls -l bar"
white
echo
echo "The geeky stuff produced by that final command will be explained in due course ..."
echo
unbold
/bin/bash
bold 
echo
echo "What you saw from ls -l was a \"long\" listing for the file."
echo
echo "It tells you the permissions, when it was created, and other stuff..."
echo "We will cover that in more detail later, but the \"rwx\" stuff at the left is"
echo
echo "\"read\" , \"write\" , \"execute\". Those tell you the permissions."
echo
echo "But hang on, there is no \"x\", there is a \"-\" instead."
echo "That's because foo is not an executable file."
echo "Rest assured, if it was executable 'ls -l' would show \"rwx\"."

f-tutescape

cyan
echo
echo "People get confused by permissions." 
echo
white
cat << EO3
The simplest way to explain this, at this stage, is to say that anything 
you try to write ( create) outside your personal "home" directory, 
(in this case, $HOME ) is likely to be forbidden by the system. 

There are exceptions, but that is a reasonable first approximation.
EO3

echo
echo
cyan
echo "So, we now have a totally useless directory \"bar\" "
echo "containing an equally useless file \"foo\""
white
echo
echo "let's put something in \"foo\""
echo
f-tutescape
echo
echo "There are quite a few ways to do this. We'll start with a way"
echo "that hardly anyone uses, but which is very quick for making a simple"
echo "text file."
f-tutescape
green
echo
printf "\n\n\n\n\n\t\t\t"
for joke in Please don\'t mail me saying that you \"use it all the time\" 
do printf "$joke "
sleep .2
done
printf "\n\n\t\t\t\t"
echo " :-)"
white
echo

f-tutescape


cyan
echo
echo "The Cat Ate My File"
echo
white
echo
echo "Here we use the command \"cat\""
echo
echo "(Who came up with this stuff?)"
echo
echo "In the grand lazy tradition, this is short for"
echo
echo "catenate"
echo

echo "..yeah, don't worry, you didn't need to know that :)"
echo
f-tutescape
echo ; echo
echo "\"cat\" lets you string stuff together - in this case, we tell"
echo "it to shove whatever we write into the file \"foo\" in directory \"bar\""
echo
f-tutescape

echo
yellow
echo "cat > bar/foo"
white
echo
echo "So what is that supposed to mean?"
echo
echo
echo "Well, the \" > \" is telling the machine to redirect anything we type to"
echo "the file named \"foo\" in the directory \"bar\". The cat strings it together..."
echo
echo
echo "When we type that command, \"bash\" ( the shell that interprets your commands )"
echo "will just sit there patiently blinking, and waiting for your input." 
echo
echo
echo "You type some text, "
echo "then you tell bash that you have reached the EOF ( \"end of file\" ) by"
echo "hitting ctrl+d."
echo
echo "You recall that you can exit bash by typing ctrl+d instead of \"exit\""
echo
echo "Same deal here, sort of."
echo
yellow
echo "Don't freak out - you get a cheat sheet :)"
echo
green
echo "So, prepare to become one of the true cognoscenti who use \"cat\" to "
echo "edit files ;-)"

f-tutescape

cyan
echo
echo "Cheatsheet for Beginning Geeks"
yellow
echo
echo
echo "cat > bar/foo"
echo
echo "Type some stuff "
white
echo
echo "( I suggest:  \"This tutorial is too hard, and the jokes are cheesy\" ;-) )"
yellow
echo
echo "Hit enter to get a new line"
echo
echo "Hit ctrl+d  "
white
echo
echo "(Nothing appears to happen, but you are back at a prompt)"
yellow
echo 
echo "cat bar/foo"
echo
printf "exit"
white
printf " or "
yellow
printf "ctrl+d"
white
echo " as usual from the subshell to return to the tutorial"
echo
unbold 
/bin/bash
yellow ; bold ; bred
echo
echo "Wait! What was that at the end with \"cat bar/foo\" ?"
white ; bblack
echo
echo "This feline is unusually obedient - we told it to string our text together"
echo "and give it back again on the terminal, where we could read it."
echo
echo "Who said cats do whatever they feel like doing?"

f-tutescape

cyan
echo
echo "OOPS! The cat really *did* eat my file"
echo 
echo
white
echo "UNIX and GNU/Linux expect us to know what we are doing."
echo
echo "Unfortunately, this is sometimes a forlorn expectation."
echo
echo "Here we introduce a highly technical term:"
echo
f-tutescape

printf "\n\n"
yellow ; bred
echo "clobber"
white ; bblack
echo
echo "Seriously, that's the term..."
echo
echo "If we misuse commands, the system will happily clobber our files."
echo
echo
yellow ; bred
echo "No questions asked"
white ; bblack
sleep 1
echo
echo "Let's take a simple example."
echo
sleep .5
echo "We will now clobber our \"foo\" file."
echo
sleep .5
echo "First make sure something is in there..."
echo
yellow
echo "cat bar/foo "
white
echo
echo "then...  type exactly as below"
yellow
echo
echo "> bar/foo"
echo
white 
echo "OK - do it..."
unbold
echo
/bin/bash
echo
bold 
echo "Now try to read it again..."
echo
yellow
echo "cat bar/foo"
white ; unbold
/bin/bash
white ; bold 
echo 
echo "Where did it go?"

f-tutescape

echo
echo
cyan
echo "We clobbered it."
echo
yellow
echo " > /bar/foo   redirects \"nothing, null, emptiness\" to the bar/foo file."
echo
white
echo "When we try to look, nothing is there. "
echo
echo
echo "So the system did *exactly* what we told it to do."
echo
sleep 1
echo "Computers are high-tech morons :-)"
echo
echo "Any intelligence must be supplied by a human."
echo
echo
echo "There *are* a few ways of protecting yourself against the clobber demon."
echo
echo "It is better, for learning purposes. that you find out those ways later ;-)"
echo
f-tutescape
cyan
printf "\v\v\t\t\t\n\n\n\n\n"
echo "We have ways of making you learn... heheheh..."

f-tutescape

cyan
echo
echo "OK, OK ... I'll tell you, but forget I told you, immediately..."
white
echo
echo " - you can do \" set -o noclobber \" "
echo
echo "... and you can set up protective \"aliases\" for dangerous commands."
echo
echo
echo "... but these methods can become *very* annoying when you"
echo "actually"
green 
echo "          *deliberately want* "
white
echo "                               to clobber something - "
echo
echo "clobbering can be very useful."
echo 
f-tutescape
echo
echo
echo "So, I suggest that you develop the right paranoid habits."
echo
echo "Right from the start."
yellow
echo
echo "Hint:"
echo
white
echo "Unless you *want* to clobber a file, you should normally"
yellow ; echo
echo "use >> instead of > "
echo
white
echo ">>  will append to the file, whereas > will just overwrite it."
echo "You can try this later - it can be very useful for adding a few"
echo "lines to an existing file."

f-tutescape

printf "\n\n\n\t\t"
cyan
echo "Usually, most people use an editor to clobber... "
sleep 1
white
echo
echo "                                umm... "
sleep 1
echo
green
echo "    edit"
sleep 1
white
printf "\n\n"
echo "       their files."
echo
echo
echo "Editor preference disputes are yet another traditional Holy War"
echo "in UNIX and Linux circles... you have a choice of several in \"inx\"."
echo
f-tutescape
green
printf "\n\n\n\n\t\t"
echo "*cough* ...   editors...      not wars..."
echo

f-tutescape

white ; bblue
printf "\n\n\n\n\n\n\n\n"
printf "\t\t"
echo "Note to Richard: "

printf "\n\n"
printf "\t\t"
for word in No, you can\'t have a pony.
do printf "$word " && sleep .3
done
sleep .5
printf "\n\n"
printf "\t\t"
for word in You can, however, have ...
do printf "$word " && sleep .3
done
sleep 1
bblack ; white ; clear 
for blink in $(seq 1 2) ; do
yellow ; bred
VI="$(figlet "vi " "vi " "vi " "vi " "vi " "vi " )"
for each in $(seq 1 6) ; do echo "$VI" ; done
sleep 1.5
bblack && clear
sleep .5
done
white ; bblue          
printf "\n\n\n"
printf "\t\t"
echo "Hit <space> to escape as if nothing had happened"

f-tutescape

cyan ; bblack ; echo ; echo
clear
echo "Oops, I could have sworn I'd edited that out  ..."
sleep 3

clear
echo

for each in The Story So Far... ; do printf " $each" && sleep .5 ; done ; sleep .5
white
printf "\n\n"
cat << EOS
So now you have learnt about touch, mkdir, mv and a bit about cat.

You might want to know how to copy files, too.
The command is
EOS

echo
yellow
echo "cp"
white
echo
echo "and it works in a similar fashion to \" mv \". "
echo
echo "so, for example, we could have copied foo to the bar directory with"
yellow
echo
echo "cp foo bar"
echo
white
echo "The difference of course is that then we would have had two copies"
echo "of \"foo\" - one in  the "$HOME"/bar directory and one in $HOME"
echo
echo "You can try it in the shell below - for instance use touch to make some files,"
echo "then copy them into bar/ "
echo
echo "cp will happily copy multiple files into a different directory,"
echo "and mv will do the same."
echo 
echo "Example: "
echo
yellow
echo "touch one two three"
echo
echo "cp one two three bar/"
echo
echo "ls bar"
echo
white ; unbold
/bin/bash
clear
bold 
echo
echo "Both mv and cp will also happily clobber any files of the same name"
echo "that exist in the destination. ;-)"
echo
echo "This is one of the advantages of a live CD like \"inx\" - "
echo "you can clobber things in $HOME , and it won't matter, since on next boot"
echo "everything is back to normal ;-) Just don't \"experiment\" on your hard drive,"
echo "or any attached usb devices, floppies and so on."
echo
echo "To reverse the procedures and remove files, you use the"
echo
yellow
echo "rm"
white
echo
echo "command"
echo 
echo "To remove directories, use"
yellow
echo 
echo "rmdir" 
echo
white
echo "The directory needs to be empty first."
echo
echo "There *are* more dangerous ways to remove directories,"
echo "but that can wait for later... "
echo
echo "Move on to the next tutorial section at your leisure, from the menu."
echo "It will go into more depth about commands and programs."
echo
echo "If you want to practise a bit, you can find a prompt on tty6 , (Alt-F6) ,"
echo "or just ask for a command prompt from the menu."
echo
echo "That's it for this tutorial (1) - hit <space> to return to the tutorial menu"
f-tutescape

f-tutorial
}

function f-tutorial.2 ()
{
clear
bold
cyan ; echo
echo "In Which Indoctrination Continues..."
white
echo
cat << EOI
The first two tutorials ( zero and 1 ) were really just warm-ups.

Let's start by going over what we've learnt so far, in summary.

* A basic explanation of the way the file and directory system looks.
* Navigating from one place to another within it, and knowing where we are.
  ( pwd, cd )
* Creating files and directories ( touch, mkdir )
* Seeing what files are there ( ls )
* One way to put text in a file, and read files ( cat )
* Moving files, and copying them. ( mv, cp )
* Removing files, and removing empty directories. ( rm, rmdir )
* Ending input, or exiting the shell ( CTRL+D, exit )

These are fundamental tools of the command line. We can do quite a lot
using only these. Under the surface of the bare Bash command line, though, 
lurk literally thousands of possibilities. In fact, "bash" is a programming 
language in itself. (Strictly speaking, it is a "scripting" language.)

Thus, Bash has at least two functions - interacting with the user to let the user
issue commands, and glueing commands together into "scripts", which are programs in 
their own right.

The code that runs "INX", including the menus and tutorials, is written in "bash".
INX forms a kind of layer above the command line - it is an "easier" interactive
layer that gives you a few choices, by implementing underlying commands.

You had a glimpse of the files containing the INX-specific code when you ran

EOI
yellow
echo "ls /usr/local/bin/"
echo
cyan
echo "As before, hit <space> to continue, < m > to return to the menu, < x > for a prompt."
f-tutescape
echo ; cyan
echo "Some more control shortcuts."
echo
white
echo "If you read \"Why INX?\" ( you did read it, didn't you?)," 
echo "you learnt at least two \"Help! Get me out of here!\" shortcuts - CTRL+D and CTRL+C"
echo
echo "There are other bash shortcuts that can make life easier. Here are some:"
echo
yellow
echo "Shortcuts"
white
echo
echo "CTRL+H : Erase the previous character."
echo "CTRL+W : Erase the previous word."
echo "CTRL+L : Clear the screen and place the prompt at the top."
echo "ALT+F  : Move forwards one word."
echo "ALT+B  : Move back one word."
echo "CTRL+F : Move forwards one character."
echo "CTRL+B : Move back one character."
echo "CTRL+E : Move to the end of the current line."
echo "CTRL+A : Move to the beginning of the current line."
echo
echo "There are quite a few others, but these are a useful set."
echo "Read $HOME/shortcuts to review these and other helpful hints."
echo
cyan
echo "Which brings us to our next topic..."

f-tutescape

echo ; cyan
echo "Reading Useful things."
echo
white
cat << EOU

One thing that many do not know is that the system contains a lot of documentation.

Some of it is rather technical, but knowing where to look is often helpful.
The most common source is the manual... the command is "man".

(Sadly, there is no "woman" command)

To see the manual for a command, we simply type
EOU
echo
yellow
echo "man <command here>"
white
echo
echo "I can hear the sound of hollow laughter, from those who have tried this, and come"
echo "away more confused than enlightened... "
echo
echo "It is important to realise that \"man\" is more intended as a reference than a tutorial."
echo
echo "We introduce it here both to make you aware of it, and to demonstrate the use of the \"pager\""
cat << EOP

The "pager" is a way around the limitations of "cat". It is used to read what is rather grandly
termed "copious output" ;-)

EOP
cyan
echo "What we now do is to see in action the reason that this exists..."

f-tutescape
echo ; cyan
echo "Less is more."
white
echo
echo "This was first said by the famous architect Ludwig Mies van der Rohe as a summary of his"
echo "philosophy of architecture. You will see it applied by UNIX and Linux authors to pagers..."
echo
echo "First, let's see the \"why\" behind this."
echo "I will now run the command"
echo
yellow
echo "cat /usr/local/lib/inx/f-mailfunctions"
echo
white
echo "then exit back to this tutorial."
echo
cyan
echo "Hit < space > to watch. Do not be alarmed by the result :-)"
white
echo
unbold
f-tutescape
f-sup ; white ; unbold
cat /usr/local/lib/inx/f-mailfunctions
echo
bold
echo "Not very useful if you actually wanted to read the code... ;-)"
echo "This time, I will run "
echo
yellow
echo "less /usr/local/lib/inx/f-mailfunctions"
white
echo
echo "Use the spacebar to page down in the \"less\" pager, and hit < q > to quit"
echo "Don't worry about what the code means ;-) "
echo
f-tutescape

f-sup ; white ; unbold
less /usr/local/lib/inx/f-mailfunctions
echo
bold
echo 
echo "\"More\" was the pager that inspired \"less\". Use \"less\" - it is far more useful."
echo
f-tutescape

cyan
echo
echo "Consulting the Man."
white
echo
cat << EOM

All that preamble was to familiarise you with the pager. The "man" command uses "less".

This makes "man" easier than it otherwise might be. The "less" pager allows us to do a lot 
of useful tasks. For example, to search for text in the pager we can type
EOM
yellow
echo
echo "/searchterm"
white
echo
echo "Try searching for \"information\" (without the quotes) in \"man intro\"."
echo "I'll run man intro for you."
echo
echo
echo "Remember, < q > to quit."
f-tutescape
f-sup ; white ; unbold
man intro
bold
clear
echo
echo "That is just one of the many tricks of the \"less\" pager."
echo
echo "By the way, /usr/share/doc/howto does not exist on this system,"
echo "but there is a lot in /usr/share/doc . "
echo
echo "cd /usr/share/doc , then use \"ls\" to see. Within the directories you will"
echo "quite often find files that look like \"some-name.gz\". You can read these"
echo "with the program \"zless\" , which is a variant of \"less\" for compressed"
echo "text files."
echo
echo "Of course, \"man less\" and \"man zless\" will tell you more... much more..."
echo
echo "Good habit to get into: to read a text file, type"
yellow
echo
echo "less /path/to/file"
echo
white
echo "Don't forget tab completion - if it beeps at you, hit tab again to see the options."
echo
cyan
echo "That's it for tutorial 2. Tutorial 3 goes on to a few useful commands, including some"
echo "shortcut commands that are only in INX, more for convenience than power."

f-tutescape
f-tutorial
}

function f-tutorial.3 ()
{
clear
bold
cyan
echo
echo "In Which We Start to do Useful Things."
white
echo
cat << EOU

If you have followed the tutorial sequence so far, you are possibly wondering when we start
issuing real, useful commands that actually do something...

This series of tutorials is aimed at people who might be confused and surprised by the command
line, so it is deliberately a bit slow to get going. If you are more advanced you might want to
skip forward to later tutorials.

You might find this one useful though... 

We start with a few "INX-specific" commands that call various functions.

EOU
cyan
echo "Some commands to start INX menus, and a Mutt wrapper to avoid disasters..."
echo
yellow
printf "inx      " ; white ; printf " starts the main INX menu, with a splash."
echo ; yellow
printf "menu     " ; white ; printf " starts the main INX menu."
echo ; yellow
printf "stream   " ; white ; printf " starts the internet stream radio menu."
echo ; yellow
printf "random   " ; white ; printf " starts the Shoutcast search-and-play menu."
echo ; yellow
printf "netinx   " ; white ; printf " starts the Internet and Web menu."
echo ; yellow
printf "mailinx  " ; white ; printf " starts the mail menu, unsurprisingly..."
echo ; yellow
printf "mutt     " ; white ; printf " starts mutt mail, with dire warnings if not configured."
echo ; yellow
printf "fun      " ; white ; printf " what it says on the tin, I hope."
echo ; yellow
printf "usb      " ; white ; printf " starts the usb access menu."
echo ; yellow
printf "gmail    " ; white ; printf " starts elinks at the gmail log-in page"
echo ; yellow
printf "tutorial " ; white ; printf " you can probably guess..."

printf "\n\n"
cyan
echo "Other INX commands."
white
echo
printf "Type" ; yellow ; printf " ls /usr/local/bin" ; white ; printf " to see the entries"
printf "\n\n"
echo "Some of them might do something useful for you ;-). "
echo ; unbold
/bin/bash
cyan ; bold ; echo
echo "As before, hit <space> to continue, < m > to return to the menu, < x > for a prompt."

f-tutescape
echo ; cyan
echo "Commands for GNU Screen."
echo
white
echo "These are jumping ahead a bit. You probably noticed the entry for the GNU Screen \"tour\""
echo "in the main INX menu. This refers to a very useful program that allows you to create extra"
echo "\"windows\" within a terminal. (I like to think of them as \"tabs\"). If you are already "
echo "comfortable on the command line, you might try these \"demonstrations\"."
echo 
echo " Otherwise, I recommend that you continue with this series of tutorials."
echo "If you jump ahead to using \"Screen\", try reading the introduction from its menu first."
echo
echo
yellow
printf "monitor   " ; white ; printf " a collection of monitoring applications (htop,iptraf.iftop)"
echo ; yellow
printf "filemanage" ; white ; printf " three file managers in \"tabs\"- quite superfluous :-)"
echo ; yellow
printf "mailscreen" ; white ; printf " Gmail in Elinks, and Mutt"
echo ; yellow
printf "music	  " ; white ; printf " The MOC music player, Magnatunes, Shoutcast, and a mixer."
echo ; yellow
printf "office	  " ; white ; printf " A calendar (calcurse), editor, calculator, spreadsheet."
echo
echo
cyan
echo "Hit <space> to continue, as always in these tutorials..."
f-tutescape
echo ; cyan
echo "Commands for the lazy..."
echo
white
echo "Well, not really. You will remember that paths to directories and files can be tab-completed."
echo "You might have discovered that commands can also be tab-completed."
echo
echo "For example, if you type \"mail\" and then hit tab twice, you will see something like"
echo
unbold
echo "tty4:inx@inx:~$ mail"
echo "mailinx         mail-lock       mailscreen      mail-touchlock  mail-unlock"
bold
echo 
echo "You choose the one you want, when there are several matches. Tab completion cleverly"
echo "stops complaining as soon as you type enough letters to avoid ambiguity."
echo
echo "On the subject of annoying beep complaints - you can turn beeps off with"
yellow
echo
echo "setterm -blength 0"
echo
white
echo "( Zero, of course, not capital \"O\".)"
echo
echo "If you want your beep to always be a concert-pitch-tuning \"A\" you can type"
echo
yellow
echo "setterm -bfreq 440"
white
echo
echo "The note can hardly be described as \"musical\", though ;-)"

f-tutescape
echo
cyan
echo "The text! The text!"
echo
white
echo "I had a tutor once who was fond of using that exclamation..."
echo
echo "Here we are in a Linux/UNIX context though - and text is still one of the fundamentals."
echo 
echo "Even if we do no coding or scripting, we all need an editor - if only for Email."
echo "Most Email applications these days, of course, include an editor in the application."
echo
echo "The UNIX philosophy, though, has always been to have small applications that do one job,"
echo "and do it well. The idea is that you can string applications together in creative ways,"
echo "rather than lumping all the functionality together in enormous complex bundles."
echo
echo "This is great when you know what the applications are, how to use them, and how to"
echo "string them together - but rather daunting when you don't."
echo
echo "So, let's start with a simple editor: nano. It is the default editor in"
echo "Debian and Ubuntu. INX now has \"jed\" as default, but nano has its uses."
echo
echo "Jed can be used with the mouse, (except in GNU screen), which makes it easy to explore."
echo "Of course, if you prefer a different editor, that can be easily done, as you will later"
echo "discover. In nano, the first key combinations to know are CTRL+O to save, and CTRL+X"
echo "to exit. If you look at the bottom of the nano screen you will see helpful reminders."
echo "In each case, ^ means \"CTRL\" - so saving (WriteOut) is shown as ^O , and Exit as ^X"
echo
echo "I will start nano for you - type a bit, then hit those combinations to save and exit."
echo "Name your file anything you like. This is just a familiarising exercise."
echo
cyan
echo "Hit <space> to continue, x for a prompt, m to return to the main INX menu."
f-tutescape
nano 
clear
echo
bold
echo "Of course, the command to start nano is... "
echo
yellow
echo "nano"
echo
white
echo "How surprising !"
echo
echo "Suggestion: get a command prompt and play around with nano a bit. Later you might want"
echo "to learn a more powerful editor like jed or vim, but nano is fine for most text editing tasks."
echo
echo "In the next tutorial we will introduce some useful searching commands, and a thing known"
echo "as a \"pipe\". This pipe relates directly to the little lecture about stringing "
echo "applications together."
echo
cyan
echo "That's it for tutorial 3. The usual key escapes apply - you should know them by now :-)"


f-tutescape
f-tutorial
}
function f-tutorial.4 ()
{
clear
bold
cyan
echo "In Which we Search for Magritte's Pipe"
echo
white
cat << EOI

So far we have made a few files, ordered a cat around, clobbered some information, and discovered 
one of many editors.

Now, any GNU/Linux system has a mind-boggling number of files, containing an extraordinary 
amount of information. This is both good and bad.

Finding what you are looking for can be a challenge. Several tools have been devised to make this
easier. Some search directly in real time, and others use a database, updated at regular intervals.

We'll start with the most sensibly named command, which uses the database approach. The command is

EOI
yellow
echo "locate"
echo
white

cat << EOL
Now "locate" is less immediately useful on a live CD, because it does nothing without having
a database to work with. On an installed system, updatedb is usually run automatically at some
early morning hour, daily. Thus the database is always slightly "out of date".

If you try, for example, "locate .ogg" for the first time on this CD, locate will complain.

You will see something like:
  
locate: can not open '/var/lib/mlocate/mlocate.db': No such file or directory

which is locate's way of telling you that it has absolutely no idea how to find anything...

EOL
echo "If you haven't already run \"sudo updatedb\" try typing:"
yellow
echo
printf "locate .ogg"
white
echo "  (then exit or CTRL+D, of course)"
echo
unbold
/bin/bash
bold
echo
echo "We can fix that by running:"
yellow
echo
echo "sudo updatedb"
echo
cyan
echo "As usual in these tutorials, hit <space> to continue, m for the menu, x for a prompt..."

f-tutescape
echo
cyan
echo "Give me back my command prompt!"
echo

white

cat << EOB
This brings up at least three interesting points worth knowing about.

First:

* combing the whole filesystem from "/" down to build a database can take quite a while.
If we issue the command "sudo updatedb", we will be watching a blinking prompt until it finishes.

Second:  

* updatedb needs to be run with "administrative" privileges, because it needs to access all
files, and your user does not have permission to do this. That is why we put "sudo" in front of 
the command, to gain administrative privileges.

Third: 

* having a "long" job running in the "foreground" like this is usually impractical, or just 
plain annoying. It takes over our current terminal - until it finishes, and gives us back
our command prompt.

Rather than pursue the use of "locate" now, let's see how the Unix gurus got around this issue.

EOB
f-tutescape

echo
cyan
echo "Get out of my way!"
white
echo
cat << EOJ
They came up with a clever dodge called "job control". By using a few tricks, we can shove our
long job out of the way, while we continue to issue other commands at the prompt.

We won't go into a lot of detail about this - just give a few useful methods.

The first and most common form of job control is to start a "takes a while" command
with "&" appended, to "background" it immediately.

So you would think, in the case of "updatedb" that we would type:

EOJ
yellow
echo "sudo updatedb &"
white
echo

cat << EOX
Actually, because "sudo" is a special command that gives us administrative powers, this is not
the right way for this case. It will work on this live CD, because sudo does not prompt for a 
password. On a more usual system, the problem with this command is that it immediately goes to 
the background, without being able to give us a password prompt. This confuses matters. 

To avoid this we instead type:

EOX
yellow
echo "sudo -b updatedb"
white
echo
echo "So as a practical exercise, type that last command in the shell below, then exit to return"
echo "to the tutorial. If you do it right, you will get your prompt back, and can let updatedb"
echo "do its job while continuing with this tutorial."
echo
echo "Throughout this tutorial, remember to \"exit\" or \"CTRL+D\" after each exercise, as usual."

unbold
echo
/bin/bash
bold
echo

cat << EOC
This is rather a special case, of course.

More often, we find ourselves in the situation where we have started a command that is taking
longer than expected. The cursor is blinking at us malevolently, as if to say "You can't have
your command prompt back!".

We can fix that...
EOC
f-tutescape
echo
cyan
echo "The trick here is to type:"
echo
yellow
echo "CTRL+Z"
echo
white
echo "... which stops the process in its tracks, without killing it." 
echo "    That is not much use until we follow with:"
echo
yellow
echo "bg"
white
echo
echo "... which puts the process in the "background" to continue, and gives us our prompt back."
echo
echo "We can bring the job back to the foreground by typing:"
echo
yellow
echo "fg"
white
echo
echo "While the job is running in the foreground, we can either kill it with:"
yellow
echo
echo "CTRL+C"
white
echo
printf "Or repeat the sequence by putting it back in the \"background\" with"
yellow
printf " CTRL+Z" ; white ; printf ", followed by" ; yellow ; printf " bg" 
echo
white
echo "We'll try this with the ubuntu_sax.ogg file that happens to be in /usr/share/example-content."
echo
echo "You can access this directly, or via a link in your $HOME directory." 
echo
echo "The one in $HOME is linked to /usr/share/example-content -"
echo "so using "example-content/ubuntu_sax.ogg" from $HOME is the same as using the path above."
echo
echo "Cheat sheet on the next page..."

f-tutescape

echo
cyan
bold
echo "Cheat sheet for job control experiments"
white
echo
echo "At the subshell prompt below, type these commands in order, with a few seconds in between:"
echo "Remember tab completion!"
yellow
echo
echo "ogg123 -q /usr/share/example-content/ubuntu_sax.ogg"
echo
echo "CTRL+Z"
echo
echo "bg"
echo
echo "fg"
echo
echo "CTRL+C"
echo
cyan
echo "Don't leave out the -q (for \"quiet\"),"
echo "or ogg123 will continue to print information to your screen while in the background :)" 
echo
white
echo "That gets confusing..."
echo
unbold
/bin/bash
bold
echo
echo "OK - you will have seen some output like [1]... and the command shown, and probably also a"
echo "message from ALSA - the Advanced Linux Sound Architecture. These messages are harmless :)"
echo
echo "I suggest trying the exercise again, this time alternating CTRL+Z with the"
yellow ; printf "bg" ; white ; printf " and" ; yellow ; printf " fg" ; white ; printf " commands."
echo
echo "Don't forget that you can stop the playing with CTRL+C while it is in the foreground."
cyan
echo
echo "Here's another prompt:"
echo
white
unbold
/bin/bash
bold
echo
echo "You might be wondering at this point where \"locate\" went, and why we are digressing..."

f-tutescape

echo
cyan
echo "What can locate do now?"
echo
white
echo "If you ran updatedb as suggested earlier, it should have overcome its amnesia by now ;-)"
echo "If it still can't find its database, give it a while longer to finish updating, and try again."
echo
echo "Let's see what "
echo
yellow
echo "locate .ogg"
white
echo
echo "gives us this time..."
echo
unbold
/bin/bash
bold
echo
echo "That should be a bit more useful than before..."
echo
echo "On most systems, \"locate .ogg\" would return a lot of output - much"
echo "more than one screen."
echo
echo "So how do we handle such output?"
echo
echo "You will remember that we used the \"less\" pager to read long files..."
echo
echo "This is a different case though - we are dealing with actual output from a command."
echo
echo "Well, that can be fixed too..."

f-tutescape

echo
cyan
echo "Connecting Programs."
printf "\n\n"
white
echo "You recall that the Unix philosophy is to use programs that do one thing well, and"
echo "connect them together to make more complex tasks possible. One of the methods is"
echo "symbolised by:"
yellow
echo
echo "			|"
echo
white
echo "This is known as a pipe. We can feed output from one program through this \"pipe\""
echo "to another program that handles the output for us."
echo
echo "Try typing:"
echo
yellow
echo "locate apt | less"
echo
white
echo "at the prompt below. Remember that the \"less\" pager can be navigated with the space bar"
echo "or arrow keys, and that you can use \"/searchterm\" to look for things in it. q for quit..."
echo
echo "Reminder: When you exit \"less\" you are at a prompt. Type exit or CTRL+D to return to the"
echo "tutorial."
echo
unbold
/bin/bash
bold
echo
echo "As you see, the output of the locate command is fed to \"less\", which makes it readable."
echo "Another tool makes an appearance on our next page ( well, our next screen I suppose...)"

f-tutescape
echo
cyan
echo "Grab Really Exceptional Patterns"
echo
white
echo "The above line will make geeks' blood boil... The acronym we are introducing here is"
echo
yellow
echo "grep"
white
cat << EOG

No-one seems to be quite sure what it actually stands for, but you will see
"Global Regular Expression Parser" , "Global Regular Expression Print" , and of course
the most likely one, "GREen Parakeet".

grep is really useful, whatever you decide it stands for - and you really don't need
to know what a "Regular Expression" is to use it.

In the simplest case, we can use grep to find words in a file. The output will show the
line in which each instance of the word appears.

In the shell below, check that you are in $HOME then type:

EOG
yellow
echo "grep INX about-inx"
echo
white
unbold
/bin/bash
bold
echo
cat << EOE
Grep returns each line on which the "pattern" INX occurs in the file "about-inx"

Big deal, you say...

Well, let's do some more Unixish "grepping"...

Suppose we want to find out information about the "apt" software installation
and removal tool. We can combine the locate command with grep and less like
this, for example:
EOE
echo
yellow
echo "locate apt | grep -v aptitude | less"
echo
white
echo "What does the -v do? It is one of the useful options for grep, and means"
echo "\"Don't include this pattern in the search\" - so we are eliminating \"aptitude\""
echo "in this case."
echo
echo "Try it below:"
echo 
unbold
/bin/bash
bold
echo
echo "Of course, as you see, we still get some irrelevant results, but they are easy to spot."
echo
echo "Another useful option is -i , which makes our search \"case insensitive\". "
echo
echo "You are probably aware by now that GNU/Linux is picky about case :) A file named INX"
echo "is not the same as a file named inx, or inX, and so on."
echo
echo "grep can also rather cleverly search through a directory \"recursively\" that is, "
echo "including its sub-directories. For example:"
echo

yellow
echo "grep -ir INX /usr/local/* | less"
white
echo
echo "Try that to see - notice that grep tells you which files contain the strings it finds."
echo "The \"-r\" in grep -ir of course means \"recursive\" . As it happens, most INX and inx"
echo "references are in /usr/local/lib/inx and /usr/local/bin"
echo
unbold
/bin/bash
bold
echo
white
echo "You might have noticed that last command introduced an extra character at the end of"
echo "the file path."
echo
echo "This is known as a \"wild card\" or \"metacharacter\"."
echo
echo "If you are curious about this, try a google search on the terms"
echo
echo "linux bash globbing"
echo
echo "To keep things slightly less mind-boggling, we will just note two useful wildcards"
echo "here:"
echo
echo " *   means \"match any number of characters\""
echo " ?   means \"match just one character\""
echo 
echo "For example, suppose you are looking for file names in the current directory ending with" 
echo "the string \"dm\" and only one leading character before the \"dm\""
echo
echo "You can type"
echo 
yellow
echo "ls ?dm "
white
echo
echo "More generally useful is the * wildcard - for instance you can match all .ogg files in"
echo "a directory with:"
echo
yellow
echo "ls *.ogg"
white
echo
echo "So, as an example, to play all the Ogg Vorbis tracks in a directory you could type:"
echo
yellow
echo "ogg123 -q *.ogg"
white
echo
echo "... then use CTRL+Z, bg ,fg and CTRL+C to put them in the background, start and stop them,"
echo "and so on. A quick and dirty music list player. There are better ways in this instance, of course."

f-tutescape
echo
cyan
echo "Special Characters."
white
cat << EOS0

Bash has certain characters that can cause issues, because they have a special meaning.
This is both useful and occasionally frustrating.

The most obvious case is the "space" character. As far as bash is concerned, a space
means either that the next string is a command, ( that could include seemingly unlikely things 
like "[" ), or an option, if preceded by " - ", or another file name, and so on.

This actually  makes sense, but drives former users of other operating systems nuts, 
because they are usually in the habit of using multi-word file names with spaces. 

Tip: in Unix and GNU/Linux, make a habit of naming files that have multiple words as 

this-file , or this_next_file or this.other.file

Tip: you can tab-complete file names with spaces. 

So, for example, to play your innocent new video named 
"Blood Violence and Gratuitous Sex.avi", with mplayer, try

EOS0
yellow
echo "mplayer Bloo <tab>"
white
echo
echo "You will notice that what bash shows is Blood\\ Violence\\ and\\ Gratuitous\\ Sex.avi"
echo
echo "Bash has \"escaped\" the spaces with backslashes for you."
echo "You can do this laboriously yourself, of course, but it would be a bit pointless"
echo "if tab completion does it for you."
echo
echo "Another way to make spaced file names understood in bash is to quote them."

f-tutescape
echo
echo
echo "Other characters that are \"special\" to Bash include:"
yellow
cat << EOSP

	!
	#
	;
	.
	\\
EOSP
white
cat << EOSP1

Because their meaning is dependent on context, there is too much here to cover in this
tutorial. A google search on

linux bash special characters	

will turn up some further explanation - for example

http://tldp.org/LDP/abs/html/special-chars.html

EOSP1

f-tutescape
echo
cat << EOCH

Some are very useful on the command line. For example we can use the bash "history" with "!" .

! is one of those context-dependent special characters. It can also mean "not" and is often
so used in bash script constructs. Using it with the Bash history is more useful from the 
command line...
EOCH
yellow
cat << EOOGG

!ogg

EOOGG
white

echo "will execute the last command we used starting \"ogg\" ( ogg123 for instance)."
yellow
cat << EODOLL

!$

EODOLL
white
cat <<EOAPP
will append the last "argument" we used (on the previous line) to the command we are typing. 
So if we want to replay the same .ogg file we just played, but without the -q option to ogg123, 
we can type

EOAPP

yellow
echo "ogg123 "\!""\$""
white
echo
echo "The dot character can mean a \"hidden\" file like, say, .screenrc . It can also mean"
echo "\"this\" or \"this right here\" or \"this directory\". So we often do something like:"
echo
yellow
echo "cp /some/path/to/file-we-want-a-copy-of . "
white
echo
echo "Which will copy the file to our current working directory. That is what the dot means here."
echo

 
f-tutescape
echo ; cyan
echo "Remember Magritte?"
white
echo
echo "Well, we have been dealing with symbols... so see what you make of this:"
cat << EOMAGRITTE

" . ! 1 | "  --  Magritte's Computer"

That was seen as a "signature" on a mailing list. See if you can decode it :)

EOMAGRITTE
cyan
echo "That's it for tutorial 4. The usual key escapes apply..."
f-tutescape
f-tutorial
}

f-tutorial.5 ()
{
clear ; cyan ; bold ; echo
echo "In Which We Rebel Against INX"
white ; echo
cat << EOINTHEWAY

One comment from an experienced user:

"The menus in INX just get in the way!"

Actually, he's right - but only if you already know a good set of commands, and what their
options are. The target audience for INX emphatically does not know such things...

Nevertheless, at some point you will tire of choosing numbers and letters, and want to do
things yourself. This is exactly the aim of INX, in fact - and you can of course turn off
all the pretty colour menus to get a command prompt, simply by hitting X, from most menus..

EOINTHEWAY
cyan
printf "(Traitor! Splitter!)  *grin*"
bblack ; echo

white
cat << EOBEGINNING

The problem, if it *is* a problem, is that virtually all GNU/Linux programs (commands)
have a bewildering number of options - and most programs do things in ways that are
"Almost, but not quite, entirely unlike..." 

The reason for questioning whether it is a problem harks back to a comment in an earlier
tutorial, regarding the issue of who supplies the intelligence when using a computer.
Operating systems and applications these days try very hard to make you believe that you
don't need to learn anything to use them. This is a fraud, albeit (in some cases) 
a generous-spirited one.

If you have followed these tutorials in order, you already know more than most computer
users, about what is actually happening under the surface.

EOBEGINNING

printf "Let's get on with it..." ; yellow ; printf " The Declaration of Independence begins..."

byellow ; cyan
printf "\t" ; printf "NOW!"
bblack
printf "\n\n\n"
cyan
echo "Hit the usual key to fearlessly continue boldly splitting infinitives..."

f-tutescape
cyan ; echo
echo "INX Stops Holding Your Hand"
white ; echo
cat << EOHANDHOLDING
O.K. - so what does INX do when you choose a number? It runs commands, of course. So let's look
at some more, and do it ourselves.

If you tried the Radio menu, you saw the actual addresses from which the stream came. Mplayer
was told to shut up and just play - and mplayer likes to be verbose. Try this - you might remember
that the controls for the basic radio menu included "/" "*" "space" "p" and "q" for quit...

Those happen to be mplayer control keys. By now I expect you to know how to return to the tutorial,
so I won't repeat it yet again ;-)

So type
EOHANDHOLDING
echo ; yellow
echo "mplayer mms://abs.egihosting.com/southjz32"
echo ; white ; unbold
/bin/bash
bold
cat <<EOMPLAYER

Different, isn't it? Most of that stuff mplayer spits out is irrelevant - unless you 
happen to have some of the things to which it refers, or need to track down a problem. 
In those cases, the verbosity is very useful. The mplayer man page, by the way, 
is very thorough, but pretty intimidating!

EOMPLAYER
f-tutescape
printf "\n\n"
echo "I know you've been dying to find out how those calendars in the "intro" are done
with colours.	 Well, O.K., maybe not..."
echo
echo "Try typing"
echo ; yellow
echo "grep -A 10 cal /usr/local/lib/inx/intro"
echo ; white ; unbold
/bin/bash
bold ; echo
echo "You are now perhaps none the wiser, but much better informed. Cruel, aren't I?"
echo
echo "All right, we shall translate... after all, if you type the colours as shown, bash
will complain, because they are functions that call parts of \"inx_essentials\", of which your shell
knows nothing."
echo
echo "The next command won't work if you are in GNU Screen, by the way - the colours I am about to
give you use the \"setterm\" command, whereas the ones in inx_essentials use escape codes."
echo
echo "Type:"
echo ; yellow
echo "setterm -background red -foreground yellow -bold on ; clear ; cal $(date +%Y)"
echo ; white ; unbold
/bin/bash
echo ; bold ; white
clear
echo
echo "OK, it isn't the same, but you get the idea... The setterm command is quite cool,
but it requires an actual virtual terminal (like $(tty)). Screen has its own ways :)"
echo
echo "If you are interested in the functions, look at /usr/local/lib/inx/inx_essentials"
echo
echo "You can also do this, for example: (in order)"
echo ; yellow
echo "source /usr/local/lib/inx/inx_essentials"
echo
echo "bblue ; white ; bold ; clear ; cal $(date +%Y)"
white ; unbold ; echo
/bin/bash
white ; bold ; clear
echo
echo "A bit easier on the eye, perhaps. The command difference was that you let the shell
know where to find the colour codes. That one would also work in GNU Screen, because screen
understands escape codes."
echo
cyan ; printf "Moving right along..."
echo ; white ; echo
echo "If you looked at the \"Fun\" menu, you might want to know how to make \"fbi\" run
its little slideshow, or what the command is for the cmatrix screensaver."
echo
echo "cmatrix is easy enough - just type "
echo ; yellow
echo "cmatrix -s"
echo ; white
echo "...and it will run in screensaver mode, meaning any key will stop it."
echo ; unbold
/bin/bash
clear
echo ; yellow ; bold
echo "fbi -noverbose -a -t 2 /usr/share/example-content/pictures/*"
echo ; white
cat << EOEXPLAIN
Will run the slideshow, with automatic size adjustment, and a time interval of 2 seconds.
The -noverbose option turns off the file information at the bottom. 

Of course, you can do this with any directory containing, for 
example, .png and .jpg images. Instead of * you could use for example *.png to show only
.png files, and so on. 

For more info, type "fbi -help" or "cmatrix -help"
EOEXPLAIN
echo
echo "Here's another prompt. Have fun. You will probably see some \"verbose output\" ...
Don't worry, it's just information about fonts."
echo ; unbold
/bin/bash
bold ; clear
cat << EOELINKS


Here's a trick for the elinks browser. If you type a series of URLs, they will open in
tabs. You can shift from one tab to another with < and > . To scroll horizontally use [ and ]

Try typing this, and using the search function ( / ) to navigate. You might want to read the 
tips in the "Net & Web" menu about using elinks with Internet radio streams, if you haven't 
already. Quick tip: on magnatune.com , use search to look for "m3u".

EOELINKS
yellow
echo "elinks http://classic.shoutcast.com http://magnatune.com http://google.com"
echo ; unbold
/bin/bash
clear ; bold ; echo ; cyan
echo "On the subject of music..."
white

cat <<EOMUSIC

The "MOC" ( Music On Console ) player is rather nice. You might have used it already.
The USB access menu is set up so that if you have music on a USB device, you can access
it directly with mocp after it is mounted. See the USB menu. ( mocp is the command to start
MOC - notice that you can quit MOC with q and it will continue to play. If you restart the 
interface, the existing state will be shown. You can stop it with "s").

The above USB hint kind of contradicts the Declaration of Independence, doesn't it?

OK. When you plug in your USB, run the following commands, with appropriate substitution...

EOMUSIC
yellow
echo "dmesg | tail"
echo
echo "mount"
echo
echo "ls  /path/to/the/mountpoint/of-the-device-dmesg-shows"
echo
echo "mocp /the/same/path/if/it/contains/ogg-or-mp3"
echo ; white
echo "The rest, as document writers love to say, is left as an exercise for the reader ;)"
echo
echo "If you feel like trying it, do so in this shell... Otherwise just exit to continue."
echo ; unbold
/bin/bash
bold ; clear ; echo
echo "I think that is a case where the menu is actually useful ;) Oh, the command to fire
up the usb menu is \"usb\" , as you have probably noticed - unimaginative, I know."

f-tutescape

cyan ; echo ; echo
echo "I Got a Set of Mental Blocks for Christmas."
white
cat <<EOAPOLOGY

If you were expecting hints about the "sc" spreadsheet... sorry, I have a serious mental
block about spreadsheets. I really do. I don't even understand the help.

The "calcurse" calendar looks pretty - but I prefer to make lists and use cal and grep. People
got by rather well with diaries, quills, and similar technology for centuries, too...

You know what a food processor does to food, right? Well, there are these things called
"word processors"... You won't find one in INX.

"wcalc", on the other hand, seems like a nice command line calculator without pretensions,
but with plenty of options.

EOAPOLOGY

f-tutescape

cyan
echo "Some Little Extras"
echo
white
echo "You can search google from the command line on INX like this:"
echo ; yellow
echo "google keyword another key word"
echo ; white
echo "There are two Wikipedia search commands:"
echo ; yellow
echo "wikig keyword second-keyword ..."
echo ; white
echo "That's for the pretty version with graphics and pictures, in links2 -g"
echo ; yellow
echo "wiki some more keywords"
echo ; white
echo "That's the text version in elinks, for people who can read ;-)"

f-tutescape

clear ; bold ; echo ; cyan
echo "More Than You Ever Wanted to Know About Linux"
echo ; white
echo "This tutorial has been a contradiction in a way - I mean this constitutes 
hand-holding to help you let go... ;-)"
echo
echo "Well, here's some more hand-holding on a much bigger scale - and it's right here
on the disc."
echo
echo "I will now run the command:"
echo ; yellow
echo "xlinks2 file:///usr/share/example-content/intro-linux/index.html"
echo ; white
echo "...and leave you to it for a while."
echo 
echo "More in the next episode... but you might not need it after reading this :-)"

f-tutescape
f-sup
links2-watch file:///usr/share/example-content/intro-linux/index.html

f-tutorial
}
function f-tutorial.6 ()
{
bold ; cyan
clear
echo
echo "In Which We Spy and Dig" 
white
cat << EORECAP

We now have some idea how to find information in the system with "locate" and "grep".

We also saw how useful it can be to string commands together with a pipe.

Here we look at what is going on behind the scenes, and learn some simple ways to find
information. We also touch on the beginnings of scripting, without becoming too advanced on
the subject.

EORECAP
cyan
echo "Who is Who"
white

cat << EOWHO

GNU/Linux is designed as a multi-user system. A lot of the time, if you are using the system
as an individual, for example on a home system, this will not be obvious - and might even 
seem irrelevant.

The concept of a "user" is not quite what you might expect, though. Users may or may not be 
actual humans!

You are likely to be the only "user" currently running INX. How does the operating system see
things, though?

At the prompt below, type

EOWHO
yellow
echo "who"
white 
echo
echo "As usual, exit or CTRL+D to return..."
unbold
echo
/bin/bash
echo
bold
cat << EOEXPLAIN

The system thinks there are several of you!
From its viewpoint, this is of course perfectly correct.

The user $USER is logged in on several tty devices.

If, for example, this was a remotely accessible system, or a server for a number of users,
you would see the various user names in the output of "who". This is handy if you feel
nasty and want to kick someone off the system ...

Funnily enough, you can get more useful information with a one letter command. At the
prompt below, type

EOEXPLAIN

yellow
echo "w"
white ; unbold ; echo

/bin/bash
bold
echo
echo "Now you know what those miscreants are up to."
echo "The \"what\" column on the right tells you the latest silly thing each user has"
echo "tried to tell the machine to do!"

f-tutescape

bold ; cyan ; echo
echo "Processes" 
white

cat << EOPROCESS

The machine keeps track of what is happening using process numbers. These are known as
"Process ID" or "PID" for short. Knowing this is often useful. If something is not quite
right, we can often identify the culprit using commands that show us the PID, and more.

The simplest commands of this kind are

EOPROCESS

yellow ; bold
echo "pidof"
echo
echo "pgrep"
white
echo
echo "The second one should look vaguely familiar..."
echo
echo "We can use these to find out the pid for particular running processes."
echo "For example here is the current output of \"pgrep menu\""
echo "(if it's blank then \"menu\" is not running)"
echo
pgrep menu
echo
echo "If we needed to stop that process, we could type \"kill <number here>\""
echo
echo "A quicker way, using a bit of Bash magic, would be"
echo ; yellow 
echo "kill \$(pgrep menu)"
white
echo
echo "Here we are using Bash to substitute the result of the command."
echo "The same result can be achieved by using \"backticks\" instead of the \$( ) syntax:"
yellow ; echo
echo "kill \`pgrep menu\`"
white ; echo
echo "But of course, there's yet another way... as so often in UNIX and GNU/Linux."
yellow ; echo
echo "pkill menu"
white ; echo

f-tutescape
echo
bold ; cyan ; echo
echo "More Spying Methods."
white
cat << EOSPY

While we are on the subject of cloak-and-dagger commands like "kill"...
It's not quite as bad as it sounds - actually the "kill" command is a way to send
"signals" to processes. Not all of these signals actually terminate processes. To know
more have a look at

EOSPY
yellow
echo "man signal"
white

echo
echo "To find manual pages related to a particular command, you can type"
yellow ; echo
echo "apropos <command>"
white ; echo
echo "or"
echo ; yellow
echo "man -k <command>"
white ; echo
echo "I prefer \"apropos\" - it has a ring to it!
Either will identify relevant man pages."
echo
echo "In the shell below, try typing "
yellow ; echo
echo "apropos kill"
white ; echo ; unbold
/bin/bash
bold ; echo
echo "The point here is not that you should immediately read and understand the manual,
but that this is a useful way to find a manual..."
echo
echo "The most important command for spying on what the machine is up to is probably"
echo ; yellow
echo "ps"
white ; echo
echo "Now this little two-letter command looks innocuous enough, but its options are many."
echo
echo "We'll look at a few of them, because \"ps\" is so often useful."

f-tutescape
echo
cyan ; bold ; echo
echo "Forests and Trees."
white ; echo
cat << EOPSBASIC

The command "ps" tells us what processes are running on the current tty ( virtual terminal ).

Digression: Virtual terminals are designated "tty" because originally they were actual "TeleTYpes"

So here is the current output of "ps" on this "tty"...

EOPSBASIC
unbold
ps
bold
cat << EOPSBASIC1

As you can see, not much appears to be happening... but this is an illusion, because there are
potentially five other tty devices also running...

So, we add the option "a" ...

Now we can see rather more - all the other ttys, and users.

EOPSBASIC1
yellow
echo "ps a" ; echo
white ; echo
echo "Hit <space> to see the output."

f-tutescape

unbold
echo
ps a
bold ; echo
echo "Now we add x, so the command becomes"
yellow ; echo
echo "ps ax"
white 
echo
echo "We are going to need to pipe this one through \"less\" - as you will see"
yellow ; echo
echo "ps ax | less"
echo ; white
echo "Hit <space> to see the new output (q to quit from \"less\", of course..."

f-tutescape
unbold
ps ax | less
echo ; bold
echo "Rather a lot of information here..."
echo
echo "So what does the \"x\" do?

It includes all the processes that are running as other \"users\", and those that have
no associated tty. So now we see all the stuff that is propping the system up and
letting us run our programs."
echo
echo "We probably would like to know which user is running which process. So we add \"u\" .
Notice that ps is unlike most commands in that these options do not have a leading \" - \".
The command *can* use such options, but that is something you might want to explore by typing"
echo ; yellow ; bold
echo "ps -help"
white ; bold ; echo

f-tutescape 
bold ; cyan ; echo
echo "Not Seeing the Forest for the Trees."
white ; echo
echo "The output of "ps aux" is too long to be useful, most of the time. Usually we want
to know about a particular program or user. We can apply what we have learnt about grep and
pipes to the problem. So let's say we are only interested in the program \"init\"..."
echo
echo "We can type"
yellow ; echo
echo "ps aux | egrep \"(init|USER)\" | grep -v grep"
white ; echo
echo "Ah, you haven't seen egrep before! egrep rather usefully lets us look for several things 
at once, as above. Notice the quotes around \"(init|USER)\" - remember special bash characters?"
echo
echo "We add in \"USER\" only to get the headings - we could use any pattern from the heading."
echo
echo "Here is the output..."
echo
ps aux | egrep "(USER|init)" | grep -v grep
echo
echo "Most of the time we won't bother with the headings, and we don't really need to get
rid of the \"grep\" since we know we are running it, so we just run"
echo ; yellow ; echo
echo "ps aux | grep init"
white ; echo
echo "You notice that \"init\" has a PID of 1. It is the process from which all others spring."
echo
echo "Rather than singling out one process, we can look at the way this forest of information
branches from one process to another. There is a --forest option to \"ps\" ! 
	Let's have a look... This is the output of"
echo ; yellow 
echo "ps ax --forest | less"
white ; echo
echo "Hit <space> to see..."

f-tutescape

unbold
ps ax --forest | less 
white ; bold ; echo
echo "The output is a bit difficult to read - you can use a simpler command"
echo ; yellow 
echo "pstree"
echo ; white
echo "Again, if we pipe through \"less\" we can page up and down if needed."
echo
echo "So, try typing below:"
echo ; yellow ; echo
echo "pstree | less"
echo ; white ; unbold
/bin/bash
echo ; bold
echo "Perhaps all this text is starting to bore you... well, here's a colourful alternative
to explore... it updates in real time. In the shell below, type "
yellow ; echo
echo "htop"
white ; echo
echo "q to quit... CTRL+D to return. Have a look at the F-key options in this program..."
unbold ; echo
/bin/bash
clear ; bold ; cyan ; echo
echo "Finding Where Things Live."
white ; echo
echo "A common question asked by beginning users is \"Where does the program go when installed?"
echo
echo "The glib answer is \"Where it's supposed to.\""
echo
echo "The reason for the glib answer is that, at least in Debian-based distributions of GNU/Linux
like Debian, Ubuntu, and of course INX, (which is really Ubuntu underneath), the installation system
sees to this. Unlike some operating systems, Linux-based systems put files for a program in a
number of places. The configuration files tend to go in /etc, and most \"user\" programs have 
their executable binaries in /usr/bin . "
echo
echo "If you need to know where the executable command is, you can find it using these commands:"
echo
yellow 
echo "type"
echo
echo "which"
white ; echo
echo "An example would be"
yellow ; echo
echo "which htop"
echo ; white
echo "Try it here:"
echo ; unbold
/bin/bash
echo ; bold
echo "Now try"
yellow ; bold ; echo
echo "which cd"
white ; echo ; unbold
/bin/bash
echo ; bold
echo "What happened?"
echo
echo "\"cd\" is a shell built-in. The \"which\" command searches your PATH, which is a list of
directories from which you are permitted to run executable programs. So it doesn't find \"cd\" ."
echo 
echo "Now try"
yellow ; echo
echo "type cd"
white ; unbold ; echo
/bin/bash
echo ; bold
echo "The \"type\" command is more general - it will find shell built-ins and commands in 
your PATH as well."
echo "These tricks can be useful as shorthand - for example rather then typing"
echo ; yellow
echo "ls -l /usr/local/bin/playinx"
echo ; white
echo "We can type "
echo ; yellow
echo "ls -l \`which playinx\` "
echo ; white
echo "You will recall that backticks make bash substitute the result of the command within them."
echo "Give it a try:"
unbold ; echo
/bin/bash
echo ; bold
echo "Final screens coming up... aliases and very basic scripting..."

f-tutescape

bold ; cyan ; echo
echo "Also Known As..."
echo ; white 
cat <<EOALIAS
Long commands can be a bore - we want to take advantage of long commands without needing 
to re-type them. There are several ways around this. One is to make an "alias".

This is quite straightforward. Let's take the example of piping "ps aux" through grep.

Let's say you want regular information on all processes being run from /usr/local/bin
(In INX the list is likely to be short enough not to need "less", but this is just an
example).

Rather than constantly typing "ps aux | grep /usr/local/bin | grep -v grep | less" 
we can do this:
EOALIAS

echo ; yellow
echo "alias psl='ps aux | grep /usr/local/bin | grep -v grep | less'"
echo ; white
echo "It's a good idea to check if our alias conflicts with a command first:"
echo ; yellow
echo "type psl"
echo ; white

echo "It doesn't, so we are OK."
echo
echo "Now, each time we type \"psl\", we get the output of the command that
we specified in the \"alias\""
echo
echo "This will only work for one virtual terminal, and until we log out, though. "
echo "On an installed system we could place this alias in our ~/.bashrc file,
so that it would work at all times, since that file is read for every shell, login or not. "
echo
echo "Read ~/.profile , and you will see that it \"sources\" ~/.bashrc"
echo

f-tutescape

echo ; cyan ; bold
echo "Baby Scripts."
echo ; white
echo "An alternative is to fire up an editor like nano, and put our command there as a \"script\"."
echo "We can put it in our PATH - the usual place for locally written scripts is /usr/local/bin ."
echo
echo "You can see your full PATH by typing"
echo ; yellow
echo "echo \$PATH"
echo ; white
echo "Which in INX looks like this (each directory separated by : )"
echo
echo $PATH
echo
echo "So we do:"
echo ; yellow
echo "sudo nano /usr/local/bin/psl"
echo ; white
echo "and write in that file:"
unbold
cat << EOBABYSCRIPT

#!/bin/bash
ps aux | grep /usr/local/bin | grep -v grep | less

EOBABYSCRIPT
bold
echo "then save it, and make it executable with"
echo ; yellow
cat << EOCHMOD
sudo chmod +x /usr/local/bin/psl


EOCHMOD
echo ; white
echo "Now we can use \"psl\" as a shortcut command."
printf "\n\n\n"

bold ; cyan ; echo
echo "That's all for tutorial 6!  Chmod and friends will be explained in tutorial 7."

f-tutescape
f-tutorial
}
function f-tutorial.7 ()
{
bold ; cyan
clear
echo ; echo
echo "In Which We Become Powerful and Dangerous."
white

cat << EOPOWERSTART


This tutorial gets a bit schoolmasterly - only because I've seen people get burnt.
We have briefly met the "sudo" command already. A bit of background is in order...

There is a certain amount of controversy about this command - most of it ill informed.
Traditionally, GNU/Linux has by default used "su" as the command to gain administrative
rights. The administrative user is known as "root", since that user has control over 
all files in the system from "/" down. Originally "/" was the root user's "home"
by default - the whole filesystem was effectively "home" for the Godlike "root" user. 

The waters have been muddied, because most systems now have a dedicated
/root directory, which is a sensible idea, since even root needs some privacy and
somewhere to put files without spraying them all over the system ;-)

Actually, the "su" command does not, contrary to what some people believe, stand for
"Super User" ;-)

"su" actually means "switch user". It simply defaults to switching to the root user, unless
another user is specified.

Now, "sudo" can do similar things, but it was originally used to give fine-grained
control over which users were authorised to run what commands, or access which parts
of the system.

As you have probably guessed by now, we are about to tell you how to become a sorcerer's
apprentice. Do, please, remember what happened to the apprentice in the story...

The lecture is not quite over. We do move on to some useful information eventually ;-)

EOPOWERSTART


f-tutescape

echo
echo ; bold ; cyan
echo "Using sudo without tears."
white ; echo
cat << EOSUDOINTRO


INX is based on Ubuntu, which has removed the scary lectures that were standard fare 
for new users. One of the traditional ones popped up when "sudo" was first invoked:

"We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:
   
      #1) Respect the privacy of others.
      #2) Think before you type."
      
... seemingly irrelevant for users on home systems, or single-user systems - but the point is
still worth making.


EOSUDOINTRO

bold ; cyan ; echo
echo "\"Thou Art Mortal.\""
white
cat << EOLECTURE


In Rome, a slave was assigned to stand behind the hero of conquest in his chariot, as he
passed through the streets in triumphal parade, acknowledging the plaudits of the crowd.

The slave was told to whisper in the conqueror's ear: "Thou art mortal."

I suggest that you whisper the same thing to yourself each time you become a sudo (pseudo?)
deity on your system. ;-)

If you don't, your mortality will become only too clear soon enough!

EOLECTURE

f-tutescape
echo
echo ; cyan ; bold
echo "\"Permission denied...\""
white
cat << EOPERMISSION

This sort of thing is unfamiliar to users of certain operating systems that shall remain
nameless.

"It's my system! What do you mean, 'permission denied'? I'll do as I like!" 

...and so on.

Get used to it. Permissions are your friends. There are excellent reasons for them, and changing
them should be done only with careful thought.

There are several commands used for permission setting. The common ones are:
EOPERMISSION
echo ; bold ; yellow
echo "chmod"
echo
echo "chown"
white ; echo
echo "The first one changes the \"mode\" of files and directories. The \"mode\" is a set"
echo "of symbols or numbers. For example if we type"
echo ; yellow
echo "ls -l /usr/bin/mplayer"
echo ; white
echo "we see"
echo 
ls -l /usr/bin/mplayer
cat <<EORWX

This is not too difficult to decode. For the moment we are only looking at the left.

"r" means "read"
"w" means "write"
"x" means "execute

Since mplayer is an "executable" (a program), we see some "x" symbols here.
EORWX
f-tutescape
echo
echo ; bold ; cyan
echo "Shooting Yourself in the Foot."
white ; echo
cat <<EODEMO

OK, lets see why changing permissions is to be approached carefully.
At the prompt below, type the following:

EODEMO
yellow ; bold
echo "sudo chmod -x /usr/bin/mplayer"
echo ; white
echo "Straight after that, type"
echo ; yellow
echo "mplayer"
echo ; white ; unbold
/bin/bash
echo ; bold
echo "Oops! Reverse it with"
echo ; yellow
echo "sudo chmod +x /usr/bin/mplayer"
white ; unbold ; echo
/bin/bash
bold ; echo
echo "That is a fairly unlikely error, but it illustrates the point. You can do much worse."
echo "If you find that it's awkward not having access to write in /usr/ you might"
echo "decide to just open it right up, for example. You read somewhere that mode 777 gives"
echo "all rights to everyone, and -R is recursive for sub-directories and files, so you type:"
echo ; yellow
echo "sudo chmod -R 777 /usr/"
echo ; white ; bred
echo "You just blasted a large hole in your foot ;-) In fact it would be very difficult to heal."
bblack ; echo
echo "I've seen this done on the / directory. That isn't just removing a foot - it's murdering"
echo "the system. As I said, permissions are there for excellent reasons, worked out over more"
echo "than thirty-five years of UNIX... and people wonder why chmod -R 777 breaks things?"

f-tutescape
echo
echo ; bold ; cyan
echo "So when do we get some positive stuff?"
echo ; white
echo "Patience, Grasshopper ;-)"

cat <<EOEXPLAIN

Obviously, changing permissions is extremely useful at times.

The most common use of the chmod command is to make a script executable. If we have the script
in our home directory, no "sudo" is required - "chmod +x script-name" will do fine, assuming
we don't mind the script being executable by other users.

There are three ( actually more but we are keeping it simple for now) possible positions for 
permissions - user, group, and others. The easy way to manipulate this stuff is to use
letters. If we want only the owner (user) to have, say, execution permission ( sounds horrible,
doesn't it?), we can do this:
EOEXPLAIN
echo ; bold ; yellow
echo "chmod u+x script-name"
echo ; white
cat << EOMNEMONIC

The letters are mnemonic: - u=user, g=group, o=others
Now let's look at the output of our ls -l /usr/bin/mplayer command again.

EOMNEMONIC
ls -l /usr/bin/mplayer
echo
echo "What we see is that all three positions have an \"x\" - user, group and others, left to right"
echo
echo "The owner/user and group are often the same on Ubuntu, Debian and thus INX."
echo
echo "You will have noticed that the file size and creation time are also in the output."

f-tutescape
echo ; cyan ; bold
echo
echo "Groups and Owners."
white ; echo
cat << EOG

In general, you can't write (save) to another user's directory or file. It's fairly obvious
why. After all, on a multi-user system you don't want people clobbering or altering your files.

On some systems (Ubuntu and Debian for example), permissions for users are set so that they can 
read each other's files by default, but not change them. Other "distributions" may be more strict,
allowing no read permissions either.

You can see your groups by typing the command "groups" - amazing, a command that makes sense!
As user "inx" you are by default in group "inx". Normally you would be the only user in that 
group. Have a look at the groups you are in:

EOG
unbold
groups
echo ; bold
cat << EODISCUSS

Notice how the system assigns you to groups like "video", "audio" and "fuse"...
This gives the administrator (you in this case) power to stop or allow others using various
programs. For example, if you were nasty you could exclude a user from the audio group,
and that user would not be able to hear sound. ;-) More sensibly, you might want to restrict
who is allowed to use the sshfs remote file sharing protocol - if so you would exclude users
from the "fuse" group, because sshfs uses fuse to do its magic.

A more significant group is the "admin" group - on Ubuntu and INX, only users in the "admin"
group are authorised to use sudo to gain root powers. 

To add a user to a group, you can type

EODISCUSS
bold ; yellow
echo "sudo adduser frida audio"
white ; echo
echo "...for example."

f-tutescape
echo ; echo
echo "The adduser command is also used to add new users like this:"
echo ; yellow
echo "sudo adduser frida"
echo ; white
echo "Which adds an account for \"frida\", including a home directory."
echo
echo "The reverse is"
echo ; yellow
echo "sudo deluser frida"
echo ; white
echo "which removes the user frida from the system, of course. It does not delete the home directory"
echo "though. That's up to you as administrator!"
echo 
echo "As with "adduser", deluser can also be used with group membership - for instance"
echo ; yellow
echo "sudo deluser frida audio"
echo ; white
echo "removes frida's audio rights. (Poor Frida!)"
echo 
echo "As you can see, all this can become quite complicated - but it also gives GNU/Linux"
echo "systems potential for great security. If some unpleasant person invaded the system,"
echo "that person would not be able to do a great deal of harm without admin permissions,"
echo "and even a \"local\" user with an account would only be able to do what the system"
echo "administrator allowed. That's the theory, anyway. People always find loopholes, but"
echo "on GNU/Linux the loopholes are usually hard to find."

f-tutescape
printf "\n\n\n"
echo "There are nicer uses for all this of course! Let's say a user wants to make a copy of a file"
echo "available to another user to alter at will." 
echo
echo "This particular file is read-write for the user, no-one else - exclusive - permissions 600 " 
echo "(rw-------). The user, however, owns the file, so he can temporarily do, say:"
echo ; yellow

echo "chmod o+r coolfile-for-frida"
echo ; white
echo "Frida can read from his home directory, so from /home/frida she can now do:"
echo ; yellow
echo "cp /home/niceguy/coolfile-for-frida . "
echo
echo "(notice the dot)"

echo ; white
echo "Frida now has a copy she can edit herself - on copying it, she gains ownership of the copy."
echo
echo "By combining group and individual permissions, various \"work groups\" can be set up."
echo "You could have an \"elite\" group that shared Truly Important Marketing Buzzwords!"
echo ; unbold
echo
echo "(Yes, I seem to have forgotten the <sarcasm> tags.)"

f-tutescape
echo ; bold ; cyan
echo "By the Numbers."
echo ; white
echo "You'll recall I ranted about \"777\" permissions. In simplified form, the numbers"
echo "look like this:"
echo ; cyan
echo "		User		Group		Others"
echo
echo "Read		 4		 4		 4		"
echo 
echo "Write		 2		 2		 2		"
echo
echo "Execute	 	 1		 1		 1		"
echo "	________________________________________________________		"
echo 
echo "		 7		 7		 7		"
echo ; white
echo
echo "Thus, adding or subtracting numbers, we see for instance that \"644\""
echo "means \"User/Owner can read and write, Group can read, Others can read\""
echo
echo "755 means Owner/User can do anything, group can read and execute, and so can others."
echo
echo "And so on... So you can see how 777 permissions undermine security - in fact, a lot"
echo "of things will simply stop working, completely, if such permissions are applied."
echo
echo "So, suppose we add the smart user \"Roid\" to the \"elite\" group..."
echo
echo "Read on..."

f-tutescape
echo ; cyan ; bold
echo "User Roid's Rise and Fall."
echo ; white

echo "Roid has been admitted to the Holy of Holies - the \"elite\" group!"
echo "/home/inx/elite has permissions 070 and ownership inx:elite. That looks like this:"
echo ; yellow ; bold
echo "$ ls -ld elite"
echo "d---rwx--- 2 inx elite 60 2007-10-31 07:14 elite"
echo ; white
echo "Remember this is an example... Hey, the elite directory is EXCLUSIVE!"
echo "Let's see what happens to Roid..."

echo ; unbold
echo "tty6:roid@inx:/home/inx$ cd elite"
echo "tty6:roid@inx:/home/inx/elite$ "

echo ; green ; bold
printf "Woohoo!" ; magenta ; printf " Roid is so..." ; green ; printf " IN!"
echo ; white
echo
echo "Sadly though, it turns out Roid doesn't quite measure up to the Elite profile..."
echo ; yellow ; bold
echo "tty1:inx@inx:~$ sudo deluser roid elite"
echo "Removing user 'roid' from group 'elite' ..."
echo "Done."
echo
echo ; white ; unbold
echo "tty6:roid@inx:/home/inx$ cd elite"
echo "bash: cd: elite: Permission denied"
echo "tty6:roid@inx:/home/inx$"
echo ; magenta ; bold
echo " :'("
echo ; white
echo "So long, Roid. Thanks for your interest... Have a nice day..." 
echo
echo "Don't slam the door on the way out."
echo ; cyan
echo "On that note, we end tutorial 7... :-) "

f-tutescape
f-tutorial
}

function f-tutorial.8 ()
{
white
clear
bold ; cyan
printf "\n\n\n"
echo "In Which We Get Everything We Want"
white ; echo
cat << EOWOOHOO

It's not obvious, but there are all kinds of goodies out there just
waiting to be installed...

One of the greatest strengths of Debian-based distributions of GNU/Linux
is the packaging system, and the policy that makes it work so well.

Here we begin to explore what can be done with the tools of this system.
It is an error to think that these are only about installing and removing
software. 

We can do all kinds of things with apt, aptitude and dpkg... dpkg in 
particular is useful for various configuration tasks, for example.

If you haven't used these tools before, you are in for some serious fun.
Installing is so automatic almost nothing needs to be done...

Ah, but you have to know the commands! The simplest ones are easy enough.

Read on!


EOWOOHOO

f-tutescape
echo ; cyan
printf "\n\n\n\n"
echo "The ADVANCED Package Tool."
white
cat <<EOAPT1

"apt" is an automatic (dare we say automagic?) tool for installing and removing
software. In GNU/Linux, binary software comes in "packages". This does not mean that 
everything required to install or remove an application is in one package, though.

In the grand UNIX tradition, the bits are often separate, but depend on each other
to work. If we had to figure out all the dependencies for installing things, we
would spend a *lot* of time searching for the bits needed. Indeed, until a few years 
ago that is essentially what we had to do. 

Packaging tools make the computer do the work for us.

Before apt there was dpkg - dpkg is still important: it is the system of packaging
and configuration tools at the lower level that apt and aptitude use. It is probably 
easier, though, to start with a general explanation of apt.

Rather than making the user search the Web for programs, most Linux distributions 
these days use collections of "packages" known as "repositories", stored on server
machines. This way, we can point our installation tools at the location of these
repositories and let the system do the searching and downloading, and the installation,
for us.

Let's take a look at how this works in practical terms...

First, let's see what the repository idea looks like.

EOAPT1
f-tutescape

clear
cyan ; echo ; echo ; bold
echo "Repositories"
white ; bold
cat << EOREPO1

The system has to know where to look to find repositories. In Debian-based distributions
of GNU/Linux, this is done through a configuration file:

EOREPO1
green ; bold
echo "/etc/apt/sources.list"
white ; echo
echo "This file on $(lsb_release -sd), and on INX since it is $(lsb_release -sd) without the bells and whistles,"
echo "has lines in it something like this:"
echo ; unbold
echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -sc) main"
echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -sc) universe"
echo
echo ; bold
echo "It can also have lines ending $(lsb_release -sc)-security main , or $(lsb_release -sc)-security universe"
echo "and so on, with another category being \"$(lsb_release -sc)-updates\", and another repository"
echo "being \"multiverse\""
echo
echo "For example, \"Hardy\" is just the nickname for the 8.04 version of Ubuntu. 8.04 means \"2008, April\""
echo
echo "The three repositories for Ubuntu are main, universe and multiverse. Security and updates"
echo "are pretty self-explanatory. In Debian the terminology is different, but the idea is the"
echo "same. In fact that's backwards, since all this comes from Debian, of course. In Ubuntu we"
echo "also have a \"restricted\" repository, which contains things that are not "
echo "\"Free as in Freedom\", like proprietary kernel modules (drivers) for graphics cards, and"
echo "other hardware."
echo
echo "The important thing to grasp is that we are pointing to a location on the Internet for"
echo "these repositories, and that /etc/apt/sources.list is where the tools \"look\" to see"
echo "where to find software. (There are actually duplicate repositories in many countries.)" 
echo
echo "Once this file is correctly set up, we tell the system to retrieve the data it needs in"
echo "order to find the software packages and download them..."

f-tutescape
printf "\n\n\n\n"
echo "The command to update this data is:"
echo ; yellow
echo "sudo apt-get update"
echo ; white
echo "if we are using the apt tool. (We will talk about \"aptitude\" later)."
echo "You can have a look for yourself what this looks like - type the command above."
echo "If you are not connected, or on a slow connection like dial-up, just ctrl+d or exit."
echo ; unbold
/bin/bash
echo ; bold
echo "When the update command is run, you see the data files downloading - not the programs."
echo "We are just informing our high-tech machine how to find things for us..."
echo
echo "Now we can install things. Usually the first thing we do is to run a complete system"
echo "upgrade with:"
echo ; yellow
echo "sudo apt-get upgrade"
white ; echo
echo "On a live CD like INX this is a bit pointless, since it will evaporate on reboot."
echo "Instead, as an example, if you have not done this before, or don't know about this"
echo "command line browser, try this:"
echo ; yellow
echo "sudo apt-get install lynx"
white ; echo
echo "Lynx is a lightning quick text browser - it predates links and elinks. Well worth a"
echo "look. Many prefer it. It is a small download. Look at the information apt gives you"
echo "as it downloads and installs."
echo ; unbold
/bin/bash
echo ; bold
echo "You might want to play around a bit with lynx. It is excellent for quick searches"
echo "when you just need to read some text on a subject, without distractions. You might"
echo "also be surprised to see how many \"cookies\" some sites want to give you ;-)"
echo

f-tutescape
echo ; cyan ; echo
echo "Other apt tools"
echo ; white
echo "It's hard to do justice to the sophistication and brilliance of apt. Here we are just"
echo "scratching the surface. Some useful tools to know about follow, as an introduction."
echo "I will give a few references at the end of this tutorial. Since apt is a Debian invention,"
echo "the most comprehensive information is of course from Debian itself, but the principles"
echo "are the same."
echo ; cyan
echo "Searching for Programs."
echo ; white
cat <<EOAPTCACHE1
There are thousands of packages available. This can be overwhelming, especially since many
of the packages have cryptic names like "lib-what-on-earth1.65"... well, for most people
the name might as well be that!

We can narrow things down, though. The sequence is usually like this:

EOAPTCACHE1
yellow
echo "apt-cache search something we need"
echo
echo "apt-cache show one-that-looks-interesting"
echo ; white
echo "Let's take an example. Making something like INX is a learning and discovery process"
echo "just as much as learning to use the command line or Linux itself. In the process, I"
echo "looked for a music player that would both be easy to use and pleasant to look at."
echo "I already knew and liked the cplay player (which incidentally is included in INX),"
echo "but I wanted something a bit more sophisticated that could deal with streams better,"
echo "... and have some colour :-)"
echo
echo "So, I used apt-cache search  ..."

f-tutescape
printf "\n\n\n\n"
echo "The command I typed was something like:"
echo ; yellow
echo "apt-cache search console music player"
echo ; white
echo "The output was like this. I'm running the command here - I hope you did \"apt-get update\" ... "
echo ; unbold
apt-cache search console music player	
echo ; bold
echo "I thought \"moc\" looked like a possibility, so I followed up with:"
echo ; yellow
echo "apt-cache show moc | less"
echo ; white
echo "The output from which looks like this..."
unbold
f-tutescape
echo ; echo
apt-cache show moc | less
echo ; bold
echo "As you see, there's quite a bit of information here, some or most of which is "
echo "probably incomprehensible - but the gold is in the Description section!"
echo
echo "As you should know by now, moc is included in INX. I even wrote a green and gold theme"
echo "for it, since that was the default colour scheme I ended up choosing for INX."
echo
echo "If you really don't care about the details of an apt-cache show , you can use grep"
echo "something like this:"
echo ; yellow
echo "apt-cache show moc | grep -A 10 Description"
echo ; white
echo "Which gives you the first 10 lines of the Description section."
echo

f-tutescape
clear ; cyan ; printf "\n\n\n\n\n"
echo "I can't find the command to run my shiny new program!"
white ; echo
echo "This is less obvious - and introduces the underlying packaging system \"dpkg\""
echo "to the discussion. The easiest way to find the command name, when the obvious fails,"
echo "is to do this:"
echo ; yellow
echo "dpkg -L <packagename> | grep bin"
echo ; white
echo "For example, the command for moc is not \"moc\"..."
echo "Hit space to see the output of"
echo ; yellow
echo "dpkg -L moc | grep bin"
white ; unbold ; echo
read -s -n 1
dpkg -L moc | grep bin
echo ; bold
echo "dpkg -L lists all the files in a package - grep winnows out irrelevant lines."
echo 
echo "Traps for young players: if the program is a game, it is probably in /usr/games -"
echo "so we try \"dpkg -L <packagename> | grep games\" instead."
echo
echo "More about dpkg later..."

f-tutescape
echo ; cyan ; printf "\n\n\n\n"
echo "More apt stuff..."
echo ; white
echo "Sometimes we want to find out which package contains a particular file. There is"
echo "an apt tool for that as well - but it is not installed by default. In a nice twist,"
echo "we can install it using apt!"
echo ; yellow
echo "sudo apt-get install apt-file && sudo apt-file update"
white ; echo
echo "The \"&&\" makes sure that the first command completes without error before"
echo "proceeding to the second command, by the way. This construct can be quite useful."
echo
echo "In this case we are installing the tool, then updating apt-file's data base so it can find"
echo "what we are looking for. To do a simple search for the package containing a file"
echo "we can then do:"
echo ; yellow
echo "apt-file search <filename>"
echo ; white
echo "apt-file tends to take a while to search - after all, it is dealing with up to"
echo "twenty thousand packages containing a huge number of files."
echo 
echo "Its advantage is that you don't need to have a package installed on your machine for this tool"
echo "to find its contents."

f-tutescape
printf "\n\n\n\n"
echo "For installed files, a far quicker tool is \"dlocate\""
echo
echo "Yes, you guessed - the command to install it is:"
echo ; yellow
echo "sudo apt-get install dlocate"
white ; echo ; echo
printf "Of course, sometimes we want to" ; yellow ; printf " remove" ; white ; printf " packages."
echo "To do that, we can use:"
echo ; yellow
echo "sudo apt-get remove <packagename>"
white ; echo
echo "This removes the package, but not its configuration files - to completely obliterate"
echo "a package, we need:"
echo ; yellow
echo "sudo apt-get --purge remove <packagename>"
printf "\n\n"
white
echo "apt now includes a tool for removal of packages that are no longer used by the system."
echo ; yellow
echo "sudo apt-get autoremove"

f-tutescape

cyan ; echo ; echo
echo "Dependencies"
white ; echo
echo "To install programs that depend on a number of packages, apt has to know about"
echo "dependencies. There are tools to show us these, as well. For instance, here is"
echo "the result of"
echo ; yellow
echo "apt-cache depends lynx"
white ; echo ; unbold
apt-cache depends lynx
echo ; bold
echo "lynx is a relatively simple package, of course. Some packages are themselves"
echo "tiny, containing only listings of dependencies, but depending on many others."
printf "Such packages are known as "
yellow ; printf " metapackages " ; white ; echo ; echo
echo "For instance, here is the result of"
echo ; yellow
echo "apt-cache depends xorg | less"

f-tutescape
white ; unbold
apt-cache depends xorg | less
echo ; bold
echo "And here is the result of:"
echo ; yellow
echo "apt-cache show xorg | grep -A 9 Description"
white ; unbold ; echo
apt-cache show xorg | grep -A 9 Description
echo ; bold
echo "Which shows that \"xorg\" is a metapackage - a way to tell apt which things to install."

f-tutescape
echo ; echo ; cyan
echo "Aptitude"
white 
cat << EOAPTITUDE1

Aptitude is, if you like, a more clever version of apt. That isn't quite right, but it will
do for now :-)

Unlike apt, which is a pure command-line front end to dpkg, aptitude can also be used as a
full screen console application. Some people prefer to use it that way - you can explore the
interface a bit...

I will run it without administrative privileges here - which means that you can't use it to
install or remove anything. Of course, normally you would run it with sudo, for root powers!

EOAPTITUDE1
f-tutescape
aptitude
clear
echo
echo ; bold ; white
echo "So that interface is one obvious difference..."
echo "Many people, though, use aptitude in the same way as apt - from the command line."
echo
echo "The commands are very similar, but in many cases simpler. For instance, to purge a"
echo "package we can simply type:"
echo ; yellow
echo "sudo aptitude purge <packagename>"
white ; echo
echo "Most of the commands are interchangeable with apt's options. For example:"
echo ; yellow
echo "sudo aptitude install foo"
echo
echo "sudo aptitude remove foo"
echo
echo "sudo aptitude update"
echo
echo "sudo aptitude upgrade"
white ; echo
echo "The output format of commands like"
echo ; yellow
echo "aptitude search <keywords>"
echo
echo "aptitude show <packagename>"
echo ; white
echo "is better and more readable, too."
echo
echo "So is aptitude just plain better than apt?"


f-tutescape

printf "\n\n\n\n" ; cyan
echo "Well, it depends." 
echo ; white
echo "Umm... that wasn't meant to be a pun, but I guess it is appropriate..."
echo
echo "Aptitude handles dependencies in a \"smarter\" manner - for some value of \"smarter.\""
echo "Apt just grabs what is needed - aptitude also grabs what is \"recommended\"."
echo
echo "In addition, when removing packages, aptitude will also remove any packages that it"
echo "automatically installed as dependencies. This can be very convenient, or absolutely"
echo "annoying, depending on what you are wanting to achieve."
echo
echo "An example would be a metapackage installed with aptitude. Apt will just remove the"
echo "metapackage (tiny), but aptitude will remove all its dependencies as well."
echo
echo "Briefly then: aptitude is great, as long as you want this behaviour. It is also more"
echo "easily learnt, because all the commands use \"aptitude\" - whereas with apt you need"
echo "to remember to use apt-cache where relevant, and know which options apply to each tool."
echo
echo "Of course, aptitude is smart enough so that you can unset unwanted options. I will run"
echo ; yellow
echo "aptitude help | less"
echo ; white
echo "so you can look. (Actually the \"help\" option doesn't exist as such - it should be -h"
echo "The result is the same - you get the help text) ;-) "

f-tutescape
unbold
aptitude help | less

printf "\n\n\n"
bold
echo "Another front end to the packaging system is \"dselect\". Some people swear by it -"
echo "others swear at it :-)"
printf "\n\n\n"
echo "Here is the help for apt-get - notice that apt-get has a few tricks that aptitude lacks."
echo "Most of the time, aptitude is a better choice, but apt has its uses too."
f-tutescape
unbold
apt-get -h | less
bold ; echo
echo "You probably remember this from the inx intro:"
echo ; unbold
apt-get moo
echo ; bold
echo "That's"
echo ; yellow
echo "apt-get moo"
echo ; white
echo "apt-get has Super Cow Powers ..."
echo
f-tutescape
printf "\n\n\n\n\n\n\t"
echo "Aptitude lacks Super Cow Powers... and claims not to contain any \"Easter Eggs\""
echo
sleep 2
echo ; yellow
echo "But..."
sleep 3
green
echo "       ...no     .... *cough*  ...that would be telling... ;-)"

f-tutescape
printf "\n\n\n\n\n\t"
echo "OK - hint: the -v option means \"verbose\". -v -vv ...  Heard any verbose moos lately?"
f-tutescape
printf "\n\n\n"
cyan
echo "I promised more about dpkg..."
white ; echo
echo "dpkg is the tool that lurks under the surface of apt and aptitude - but it also has"
echo "important functions in the configuration of Debian-based systems. A lot of them."
echo
echo "Rather too many options for this tutorial - so again, we are skimming the surface."
echo ; echo
echo "Some of the more common and useful options for dpkg are:"
echo ; yellow ; echo
printf "sudo dpkg -i <package>		" ; white ; printf "installs <package>"
echo ; yellow
printf "sudo dpkg -r <package>          " ; white ; printf "removes  <package>"
echo ; echo
echo "dpkg is the actual installation and configuration tool - it does no dependency checks."
echo "That is aptitude's or apt's job."
echo
echo "dpkg has many other uses though. For example, if we have issues with a program, we"
echo "can often fix the configuration with:"
echo ; yellow
echo "sudo dpkg-reconfigure <packagename>"
white ; echo
echo "The underlying package system is also tied to tools like the \"alternatives\" system."
echo "the command:"
echo ; yellow
echo "sudo update-alternatives --all"
echo ; white
echo "Will show you *all* the alternatives..."
echo
echo "Hint: Only change them if you know why you are doing so."

f-tutescape
echo ; cyan
echo "Other useful dpkg commands"
echo ; white
echo "We have already seen the uses of"
echo ; yellow
echo "dpkg -L <packagename>"
echo ; white
echo "The lower-case version does something quite different - it lists packages."
echo ; yellow
echo "dpkg -l <packagename1> <packagename2> ..."
echo ; white
echo "You can use wildcards with dpkg -l if you wish - for example:"
echo ; yellow
echo "dpkg -l *linux*"
echo ; white
echo "The dpkg help is rather cryptic in places - but have a look anyway. \"man dpkg\""
echo "is even more so - but a very useful reference."
echo
echo "Here is the short help for dpkg:"

f-tutescape
unbold
dpkg --help | less
echo ; bold

f-tutescape

ref ()
{
clear
printf "\n\n\n\n"
echo ; yellow
echo "References"
echo ; green
echo "If you got this far, congratulations... further reading on apt. aptitude and dpkg:"
white 
echo
echo "1: Take me to the Debian Apt-Howto with the elinks text browser."
echo "2: Take me to the Debian Apt-Howto with the links2 -g graphical browser."
echo "3: Take me to the Ubuntu AptHowto Wiki Page in the graphical browser."
echo "4: Take me to the Ubuntu AptitudeSurvivalGuide in the graphical browser"
echo "5: Open all three pages in tabs, in elinks."
green
echo
echo "Any non-number key to return to the tutorial menu."
white
read -s -n 1 APT
case $APT in
	1)
	f-sup
	elinks http://www.debian.org/doc/manuals/apt-howto/
	ref
	;;
	2)
	links2-watch http://www.debian.org/doc/manuals/apt-howto/
	ref
	;;
	3)
	links2-watch https://help.ubuntu.com/community/AptGetHowto
	ref
	;;
	4)
	links2-watch https://help.ubuntu.com/community/AptitudeSurvivalGuide
	ref
	;;
	5)
	elinks http://www.debian.org/doc/manuals/apt-howto/ https://help.ubuntu.com/community/AptGetHowto https://help.ubuntu.com/community/AptitudeSurvivalGuide
	ref
	;;
	
	*)
	f-tutorial
	;;
esac

}	
ref
f-tutorial
}

function f-tutescape ()
{

echo -e ' \033[48;80H Continue...'

# Help, get me out of here!

read -s -n 1 TUTESCAPE
case "$TUTESCAPE" in

	m)
	f-tutorial
	;;
	x)
	f-prompt
	;;
	*)
	white
	clear
	;;
esac
}

f-tutorial