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 < | 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 | 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 comtains 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 " 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 " 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 " 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 " 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 " echo echo "aptitude show " 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 " ; white ; printf "installs " echo ; yellow printf "sudo dpkg -r " ; white ; printf "removes " 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 " 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 " echo ; white echo "The lower-case version does something quite different - it lists packages." echo ; yellow echo "dpkg -l ..." 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 -g http://www.debian.org/doc/manuals/apt-howto/ ref ;; 3) links2 -g https://help.ubuntu.com/community/AptGetHowto ref ;; 4) links2 -g 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 }