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 echo "The usual instructions apply - exit or ctrl+d 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." 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 "concatenate" 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 the 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 echo "exit or ctrl+d as usual from the subshell to return to the tutorial" echo white ; 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 to escape as if nothing had happened" white ; clear 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 to return to the tutorial menu" f-tutescape f-tutorial }