Ubuntu Workshop Kit - Study Material


Published on

Along with our knowledge intensive Linux/Fedora/Ubuntu seminars and workshops, we provide workshop kits to all the participants.

This PDF is a part of the workshop kit. Using this study material, students can jump into the world of Ubuntu.

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ubuntu Workshop Kit - Study Material

  1. 1. DEBIAN GNU/LINUXDebian is a computer operating system composed of software packages released as free and open source softwareunder primarily the GNU General Public License along with other free software licenses. Debian GNU/Linux, whichincludes the GNU OS tools and Linux kernel, is a popular and influential Linux distribution. It is distributed withaccess to repositories containing thousands of software packages ready for installation and use. Debian is known forrelatively strict adherence to the Unix and free software philosophies as well as using collaborative softwaredevelopment and testing processes. Debian can be used as a desktop as well as server operating system. It focuseson stability and security and is used as a base for many other distributions.Debian OrganizationThe Debian Project is governed by the Debian Constitution and the Social Contract which set out the governancestructure of the project as well as explicitly stating that the goal of the project is the development of a free operatingsystem. Debian is developed by over three thousand volunteers from around the world and supported by donationsthrough several non-profit organizations around the world. Most important of these is Software in the PublicInterest, the owner of the Debian trademark and umbrella organization for various other community free softwareprojects.UBUNTUUbuntu is a computer operating system based on the Debian GNU/Linux distribution and distributed as free andopen source software. It is named after the Southern African philosophy of Ubuntu ("humanity towards others").Ubuntu is designed primarily for use on personal computers, although a server edition also exists. Ubuntu holds anestimated global usage of more than 12 million desktop users, making it the most popular desktop Linux distributionwith about 50% of Linux desktop marketshare. It is fourth most popular on web servers,[12] and its popularity isincreasing rapidly.Ubuntu is sponsored by the UK-based company Canonical Ltd., owned by South African entrepreneur MarkShuttleworth. Canonical generates revenue by selling technical support and services related to Ubuntu, while theoperating system itself is entirely free of charge.Ubuntu Workshop – iWillStudy.com Page 1
  2. 2. The Ubuntu project is entirely committed to the principles of free software development; people are encouraged touse free software, improve it, and pass it on.To Install UbuntuUbuntu can be installed with the graphical CD. Make sure that your computer is set to boot from a CD before ahard drive. 1. Insert the Ubuntu disc into your CD drive. 2. Start or restart your computer. The Language screen appears. 3. Select your desired language and click Install Ubuntu 10.04 LTS. The Where are you? window appears. 4. Select the location closest to your location and click Forward. The Keyboard layout window appears. 5. If the Suggested option is not correct, select the correct keyboard layout. Click Forward. The Allocate drive spacewindow appears. 6. If you want to install Ubuntu over your entire hard drive, then Select Erase disk and install Ubuntu and select the hard drive that you want to install Ubuntu.Ubuntu Workshop – iWillStudy.com Page 2
  3. 3. Click Forward.WARNING: Installing Ubuntu on your entire hard disk will erase all data that is currently on the drive.OR 6. If you want to install Ubuntu on a single partition Dual Booting, Select Guided – resize. In the New partition size area, drag the area between the two partitions to create your desired partition sizes. Click Forward. 7. The Who are you? window appears. 8. Enter the requested information, and click Forward. The Ready to install window appears. 9. Verify that the language, layout, location, and personal information are correct and click Install. The installation wizard begins. 10. When the installation wizard finishes, the Installation complete window appears. 11. Click Restart now to restart your computer. Ubuntu is now installed.Installation IntroductionInstalling software in Ubuntu is easy, and this guide will show you how to do it.By default, many useful programs are already installed when you put Ubuntu onto your computer. However, youmay need a particular piece of software that serves a purpose not served by the default applications. You mightjust want to try an alternative program to one which is already installed. In other words, you need new software.Packages and Package ManagementThis section covers the basic concepts of packages and package management. You will learn about what apackage is, the differences between different types of package and also how package management works onUbuntu.Ubuntu Workshop – iWillStudy.com Page 3
  4. 4. What is a package?Software is a very broad term, and is generally taken to mean a program which you can run on your computer.However, such programs often need other resources to work. When you install software, thousands of files maybe required just to let the program start! When you think that they all have to be put in exactly the right location,and some of those files may need to be changed depending on what type of computer you have, it can all getvery complicated. Luckily, Ubuntu can look after this complexity.Source or Binary?Normally, when someone makes a package for a program, they put all of the source code for the program intothat package. Source code is written by programmers and is essentially a list of instructions to a computer whichhumans are able to read and write. Computers can only understand this code if it is interpreted for them into aform that they can use directly. One such way of interpreting source code for a computer is by translatingor compiling it into binary, which computers can understand.Source packages are simply packages which just include source code, and can generally be used on any typeof machine if the code is compiled in the right way.Binary packages are ones which have been made specifically for one type of computer, or architecture. Ubuntusupports the x86 (i386 or i686), AMD64 and PPC architectures. The correct binary packages will be usedautomatically, so you dont have to worry about picking the right ones. To find out which one you are using,open Applications → Accessories → Terminal, typeuname -m then hit the enter key.Package DependenciesPrograms often use some of the same files as each other. Rather than putting these files into each package, aseparate package can be installed to provide them for all of the programs that need them. So, to install aprogram which needs one of these files, the package containing those files must also be installed. When apackage depends on another in this way, it is known as apackage dependency. By specifying dependencies,packages can be made smaller and simpler, and duplicates of files and programs are mostly removed.When you install a program, its dependencies must be installed at the same time. Usually, most of the requireddependencies will already be installed, but a few extras may be needed, too. So, when you install a package,dont be surprised if several other packages are installed too - these are just dependencies which are needed foryour chosen package to function properly. An example of dependenciesUbuntu Workshop – iWillStudy.com Page 4
  5. 5. Package ManagersA package manager is an application which handles the downloading and installation of packages. Ubuntuincludes a few package managers by default, and which one you use depends on how advanced the packagemanagement tasks are that you want to achieve. Most people will only need to use the most basic packagemanager, the Add/Remove tool, which is very easy to use.Software Channels/RepositoriesWhere can you get packages from?Ubuntu stores all of its packages in locations called software channels or repositories. A software channel issimply a location which holds packages of similar types, which can be downloaded and installed using apackage manager. A package manager will store an index of all of the packages available from a softwarechannel. Sometimes it will re-build this index to make sure that it is up to date and knows which packages havebeen upgraded or added into the channel since it last checked.There are four Ubuntu software channels for each architecture - Main, Restricted, Universe and Multiverse. Eachhas a different purpose. By default, only packages from Main and Restricted can be installed.Installing a PackageThis section explains how to install packages using the various tools available in Ubuntu,Xubuntu,Edubuntu andKubuntu.Via your web browserIn the Ubuntu Documentation, you will sometimes find sentences like for example:" To install this software in Ubuntu, install the following package: supertux. "Click on the name of the package ("supertux" in the example):  if the apturl protocol is enabled on your computer, you will be proposed to install the package called "supertux".Via a basic graphical methodNote that some packages cant be installed via this method, in this case please use another method.for Ubuntu: "Sofware Centre "In recent versions of Ubuntu, the "Add/Remove" option in the Applications menu has been replaced bythe Ubuntu Software Center.for Kubuntu : "Add/Remove Programs"Kubuntus new and easy method of installing packages is to use the Add/Remove Programs tool. Click K-Menu → Add/Remove Programs to start it.Ubuntu Workshop – iWillStudy.com Page 5
  6. 6. Add/Remove Programs is a simple graphical way of installing and removing applications in Kubuntu. Tolaunch Add/Remove Programs, choose K Menu → Add/Remove Programs from the desktop menu system.To install new applications select the category on the left, then check the box of the application you want toinstall. When finished click Apply, then your chosen programs will be downloaded and installed automatically, aswell as installing any additional applications that are required. The default selection is restricted to KDE suite, butGNOME applications can be installed simply by selecting from dropdown menu at the top. Alternatively, if youknow the name of the program you want, use the Search tool at the top.Software from additional repositories may be installed by enabling the Show: Unsupported and Show:proprietary softwarecheckboxes if they are enabled in your repository list.Once this has finished, click Close.Your new programs are installed, ready to use!Via an advanced graphical methodfor Ubuntu/Xubuntu/Edubuntu : SynapticThe Synaptic Package Manager offers a more advanced way of installing packages. If you have problemsfinding a suitable package with the Add/Remove tool, try using the search in Synaptic. This searches all of thepackages in the available repositories, even the ones which dont contain programs.Via a Text Based MethodsText based methods can be used across Ubuntu, Kubuntu and Xubuntu, but require familiarity with theterminal. When helping users to install packages, you should consider using an AptURL instead of apt-get oraptitude.Ubuntu Workshop – iWillStudy.com Page 6
  7. 7. Aptitude - the text-based methodAptitude is a text-based package manager, which must be run from a Terminal.apt-get - the technical methodThe apt-get program is a command-line package manager, which should be used if the Add/Remove tool andSynaptic ever run into problems. It provides an advanced interface to APT, the underlying package managementsystem which Ubuntu uses, but is reasonably easy to operate. Power users may find that apt-get is quicker touse and more powerful than the graphical options above.Installing downloaded packagesYou may wish to install a package you have downloaded from a website, rather than from a software repository.These packages are called .deb files. Because they may have been created for a different Linux distribution, youmight find that theres dependency issues with Ubuntu, meaning that they may be uninstallable.To find a package which you have previously downloaded using Synaptic, aptitude or apt-get, lookin /var/cache/apt/archivesUsing GDebi to install packagesGDebi is a graphical application used to install .deb packages. It automatically checks packages for theirdependencies and will try to download them from the Ubuntu software repositories if possible. You may firstneed to install GDebi - simply install thegdebi package using one of the package managers listed above, oropen a Terminal and type sudo apt-get install gdebi.Once you have installed GDebi, use the File Browser to find the package you wish to install. Package files willlook similar to this:Ubuntu Workshop – iWillStudy.com Page 7
  8. 8. Double-click the package to open it with GDebi. If all dependencies have been met for the selected package,simply click the Install package button to install it. GDebi will warn you if there are unmet dependencies, whichmeans that theres dependencies that arent resolved in the repositories that youre using.Using dpkg to install packagesdpkg is a command-line tool used to install packages. To install a package with dpkg, open a Terminal and typethe following:cd directorysudo dpkg -i package_name.debNote: replace directory with the directory in which the package is stored and package_name with the filenameof the package.It is recommended that you read the dpkg manual page before using dpkg, as improper use may break thepackage management database. To view the manual page for dpkg, open a Terminal and type man dpkg.Getting a list of recently installed packagesYou can also use the dpkg logs to discover recently installed packages; this is handy if you want to roll backsome recent installations to a previous system state.zcat -f /var/log/dpkg.log* | grep " install " | sortAutomatic updates: Update ManagerUbuntu will automatically notify you when security updates and software upgrades are available. The UbuntuUpdate Manager is a simple and easy to use application that helps users to keep their system software updated.Simply click the update icon (which will appear in the notification area), type in your super-user/administratorpassword and follow the instructions on-screen to download and install the updates.Keeping up to date is important, as security fixes which protect your computer from harm are delivered in thisway.Installing packages without an Internet connectionSometimes, an internet connection is unavailable to install programs. Here are the methods proposed by theofficial Ubuntu documentation: https://help.ubuntu.com/8.04/add-applications/C/offline.htmlUbuntu Workshop – iWillStudy.com Page 8
  9. 9. But it is also possible to do it without CDs or DVDs, using a simple USB key for example to transfer only thepackages you need.Here are two methods to do this:Use KeryxKeryx is a portable, cross-platform package manager for APT-based (Ubuntu, Debian) systems. It provides agraphical interface for gathering updates, packages, and dependencies for offline computers. Keryx is free andopen source. You can get Keryx here: http://keryxproject.org/Use the Synaptic package download scriptShort instructions:  Launch Synaptic on the offline computer  Mark the packages you wish to install  Select File->Generate package download script  Save the script to your USB key  Take the USB key to an online Linux computer and run the script there from the USB key. It will download only the packages required by the offline computer to the USB key.  Insert the USB key into the offline computer  Launch Synaptic and click on File->Add downloaded packages  Select the directory on your USB key containing the downloaded *.deb files and press Open. The packages will be installed.Note: If you dont have access to a PC with GNU/Linux or emulating/virtualizing GNU/Linux (Cygwin,VMware, VirtualBox, Qemu, etc), just open the script with a text editor and enter all the URLs you see in yourbrowser to download the corresponding packages.If you have all the necessary libraries and/or dependencies, the simplest way is of course to just download the.deb package you need, just as you would with a Windows installer, and double-click the package to install itwith GDebi.All Ubuntu packages are available on http://packages.ubuntu.com/ and http://www.debian.org/distrib/packages .Offline apt-get updateIf you cant even select the packages on your offline PC because you cant add the repository / update thepackage info, try this:AptGet/Offline/RepositoryBasically, it consists in creating your own local repository, except that it wont contain the packages themselves,only the dependency information.The solution is to post-process the script by replacing the URLs with the correct one.Assuming you created the local repository at "/home/username/repository" and got the different files from"http://archive.ubuntu.com/ubuntu/", this can easily be done with the following command:sed s#file:///home/username/repository#http://archive.ubuntu.com/ubuntu#download_script.sh > download_script2.shchmod +x download_script2.shor directly without creating a second script:sed -i s#file:///home/username/repository#http://archive.ubuntu.com/ubuntu#download_script.shUbuntu Workshop – iWillStudy.com Page 9
  10. 10. or simply with any text editor featuring search&replace.Use apt-offlineapt-offline allows you to easily upgrade or install new packages on your offline PC, by using another online PC.sudo apt-get install apt-offlineUpgrading 1. On the offline PC:sudo apt-offline set /tmp/apt-offline.sig 2. On the online PC:sudo apt-offline get C:apt-offline.sig --bug-reports --threads 5 3. On the offline PC:sudo apt-offline install /media/USB/apt-offline.zipInstalling 1. On the offline PC:sudo apt-offline set abuse-offline.sig --install-packages abuse --src-build-dep --install-src-packages abuse 2. On the online PC:sudo apt-offline get abuse-offline.sig --no-checksum --bundle abuse-offline.zip 3. On the offline PC:sudo apt-offline install /media/USB/abuse-offline.zipUbuntu Workshop – iWillStudy.com Page 10
  11. 11. Why use the command-line?"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefullyget work done without first reading lots of documentation. The traditional Unix environment is a CLI (commandline interface), where you type commands to tell the computer what to do. That is faster and more powerful, butrequires finding out what the commands are."-- from man intro(1)There are many varieties of Linux, but almost all of them use similar commands that can be entered from acommand-line interface terminal.There are also many graphical user interfaces (GUIs), but each of them works differently and there is littlestandardization between them. Experienced users who work with many different Linux distributions therefore findit easier to learn commands that can be used in all varieties of Ubuntu and, indeed, in other Linux distributionsas well.For the novice, commands-line interface commands can appear daunting:sudo gobbledegook blah_blah -w -t -h --long-switchaWkward/ComBinationOf/mixedCase/underscores_strokes/and.dotsHowever, it is important to note that even experienced users often cut and paste commands (from a guide ormanual) into the command-line terminal; they do not memorize them.It is important, of course, to know how to use the command-line terminal - and anyone who can manage typing,backspacing, and cutting and pasting can manage the command-line terminal (it is not more difficult than that).This page will outline a few crafty shortcuts which can make using a command-line interface easier.Using this page  All command names will be in bold.  Commands needing to be typed will be in "bold with quotes".  All of the commands on this page are to be issued from a command prompt in a terminal.  Note that the terminal is case sensitive. User, user, and USER are all different to Linux.Starting a TerminalIn UnityUnity is the default Desktop Environment used in 11.04.The easiest way to open the Terminal is to use the search function on the dash. Or you can click on the MoreApps button, click on the See more results by the installed section, and find it in that list of applications. A thirdway, available after you click on the More Apps button, is to go to the search bar, and see that the far right endof it says All Applications. You then click on that, and youll see the full list. Then you can go to Accessories >Terminal after that. So, the methods in Unity are:Dash -> Search for TerminalDash -> More Apps -> See More Results -> TerminalDash -> More Apps -> Accessories -> TerminalUbuntu Workshop – iWillStudy.com Page 11
  12. 12. Keyboard Shortcut: Ctl + Alt + TIn GnomeGnome is the Classic Desktop Environment for Ubuntu 11.04 (Natty) and is the default DE in earlier releases,such as Ubuntu 10.04 LTS (Lucid).Applications menu -> Accessories -> Terminal.In Xfce (Xubuntu)Applications menu -> System -> Terminal.In KDE (Kubuntu)KMenu -> System -> Terminal Program (Konsole).In LXDE (Lubuntu)Menu -> Accessories -> LXTerminal.Commandssudo: Executing Commands with Elevated Privileges  Most of the following commands will need to be prefaced with the sudo command. This elevates privileges to the root-user administrative level temporarily, which is necessary when working with directories or files not owned by your user account. When using sudo you will be prompted for your password. Only users with sudo (administrative) privileges will be able to use this command.File & Directory Commands  The tilde (~) symbol stands for your home directory. If you are user, then the tilde (~) stands for /home/user  pwd: The pwd command will allow you to know in which directory youre located (pwd stands for "print working directory"). Example: "pwd" in the Desktop directory will show "~/Desktop". Note that the Gnome Terminal also displays this information in the title bar of its window. A useful gnemonic is "present working directory."  ls: The ls command will show you (list) the files in your current directory. Used with certain options, you can see sizes of files, when files were made, and permissions of files. Example: "ls ~" will show you the files that are in your home directory.  cd: The cd command will allow you to change directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. Examples: o To navigate into the root directory, use "cd /" o To navigate to your home directory, use "cd" or "cd ~" o To navigate up one directory level, use "cd .." o To navigate to the previous directory (or back), use "cd -" o To navigate through multiple levels of directory at once, specify the full directory path that you want to go to. For example, use, "cd /var/www" to go directly to the /www subdirectory of /var/. As another example, "cd ~/Desktop"will move you to the Desktop subdirectory inside your home directory.  cp: The cp command will make a copy of a file for you. Example: "cp file foo" will make an exact copy of "file" and name it "foo", but the file "file" will still be there. If you are copying a directory, you must use "cp -r directory foo" (copy recursively). (To understand what "recursively" means, think of it this way: to copy the directory and all its files and subdirectories and all their files and subdirectories of the subdirectories and all their files, and on and on, "recursively")Ubuntu Workshop – iWillStudy.com Page 12
  13. 13.  mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: "mv file foo" will rename the file "file" to "foo". "mv foo ~/Desktop" will move the file "foo" to your Desktop directory but will not rename it. You must specify a new file name to rename a file. o To save on typing, you can substitute ~ in place of the home directory. o Note that if you are using mv with sudo you can use the ~ shortcut, because the terminal expands the ~ to your home directory. However, when you open a root shell with sudo - i or sudo -s, ~ will refer to the root accounts home directory, not your own.  rm: Use this command to remove or delete a file in your directory.  rmdir: The rmdir command will delete an empty directory. To delete a directory and all of its contents recursively, use rm -r instead.  mkdir: The mkdir command will allow you to create directories. Example: "mkdir music" will create a directory called "music".  man: The man command is used to show you the manual of other commands. Try "man man" to get the man page forman itself. System Information Commands  df: The df command displays filesystem disk space usage for all mounted partitions. "df -h" is probably the most useful - it uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable")  du: The du command displays the disk usage for a directory. It can either display the space used for all subdirectories or the total for the directory you run it on. Example:user@users-desktop:~$ du /media/floppy1032 /media/floppy/files1036 /media/floppy/user@users-desktop:~$ du -sh /media/floppy1.1M /media/floppy/  -s means "Summary" and -h means "Human Readable"  free: The free command displays the amount of free and used memory in the system. "free -m" will give the information using megabytes, which is probably most useful for current computers.  top: The top command displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press "q".  uname -a: The uname command with the -a option prints all system information, including machine name, kernel name & version, and a few other details. Most useful for checking which kernel youre using.  lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release youre running, for example:user@computer:~$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 6.06 LTSRelease: 6.06Codename: dapper  ip addr reports on your systems network interfaces.Adding A New User  "adduser newuser" command will create a new general user called "newuser" on your system, and to assign a password for the newuser account use "passwd newuser".OptionsUbuntu Workshop – iWillStudy.com Page 13
  14. 14. The default behaviour for a command may usually be modified by adding a --option to the command.The ls command for example has an -s option so that "ls -s" will include file sizes in the listing. There is also a -h option to get those sizes in a "human readable" format.Options can be grouped in clusters so "ls -sh" is exactly the same command as "ls -s -h". Most options have along version, prefixed with two dashes instead of one, so even "ls --size --human-readable" is the samecommand."Man" and getting help man command, info command and command --help are the most important tools at the command line.Nearly every command and application in Linux will have a man (manual) file, so finding them is as simple astyping "man "command"" to bring up a longer manual entry for the specified command. For example, "manmv" will bring up the mv (Move) manual.Move up and down the man file with the arrow keys, and quit back to the command prompt with "q"."man man" will bring up the manual entry for the man command, which is a good place to start!"man intro" is especially useful - it displays the "Introduction to user commands" which is a well-written, fairlybrief introduction to the Linux command line.There are also info pages, which are generally more in-depth than man pages. Try "info info" for theintroduction to info pages.Some software developers prefer info to man (for instance, GNU developers), so if you find a very widely usedcommand or app that doesnt have a man page, its worth checking for an info page.Virtually all commands understand the -h (or --help) option which will produce a short usage description of thecommand and its options, then exit back to the command prompt. Try "man -h" or "man --help" to see this inaction.Caveat: Its possible (but rare) that a program doesnt understand the -h option to mean help. For this reason,check for a man orinfo page first, and try the long option --help before -h.Searching for man filesIf you arent sure which command or application you need to use, you can try searching the man files.  man -k foo will search the man files for foo. Try "man -k nautilus" to see how this works. o Note that this is the same as doing apropos command.  man -f foo searches only the titles of your systems man files. Try "man -f gnome", for example. o Note that this is the same as doing whatis command.Other Useful ThingsPrettier Manual PagesUsers who have Konqueror installed will be pleased to find they can read and search man pages in a webbrowser context, prettified with their chosen desktop fonts and a little colour, by visiting man:/command inKonquerors address bar. Some people might find this lightens the load if theres lots of documentation toread/search.Ubuntu Workshop – iWillStudy.com Page 14
  15. 15. Pasting in commandsOften, you will be referred to instructions that require commands to be pasted into the terminal. You might bewondering why the text youve copied from a web page using ctrl+C wont paste in with ctrl+V. Surely you donthave to type in all those nasty commands and filenames? Relax. ctrl+shift+V pastes into a Gnome terminal; youcan also do Middle Button Click on your mouse (both buttons simultaneously on a two-button mouse) or RightClick and select Paste from the menu. However, if you want to avoid the mouse and yet paste it, use"Shift+Insert", to paste the command. If you have to copy it from another terminal / webpage, you can use"Ctrl+Insert" to copy.Save on typingUp Scrolls through the commands youve entered previously.Arroworctrl+pDown Takes you back to a more recent command.Arroworctrl+nEnter When you have the command you want. A very useful feature. It autocompletes any commands or filenames, if theres only oneTab option, or else gives you a list of options. Searches for commands youve already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing actrl+r portion of the command will search through your command history. When you find it, simply press Enter. The history command shows a very long list of commands that you have typed. Each command is displayed next to a number. You can type !x to execute a previously typedHistory command from the list (replace the X with a number). If youhistory output is too long, then use history | less for a scrollable list.Change the textThe mouse wont work. Use the Left/Right arrow keys to move around the line.When the cursor is where you want it in the line, typing inserts text - ie it doesnt overtype whats already there.ctrl+a or Home Moves the cursor to the start of a line.ctrl+e or End Moves the cursor to the end of a line.ctrl+b Moves to the beginning of the previous or current word.ctrl+k Deletes from the current cursor position to the end of the line.ctrl+u Deletes the whole of the current line.ctrl+w Deletes the word before the cursor.LinuxLogFilesSystem LogsSystem logs deal primarily with the functioning of the Ubuntu system, not necessarily with additional applicationsadded by users. Examples include authorization mechanisms, system daemons, system messages, and the all-encompassing system log itself, syslog.Ubuntu Workshop – iWillStudy.com Page 15
  16. 16. Authorization LogThe Authorization Log tracks usage of authorization systems, the mechanisms for authorizing users whichprompt for user passwords, such as the Pluggable Authentication Module (PAM) system, the sudo command,remote logins to sshd and so on. The Authorization Log file may be accessed at /var/log/auth.log. This logis useful for learning about user logins and usage of the sudo command.Use grep to cut down on the volume. For example, to see only information in the Authorization Log pertainingto sshd logins, use this:grep sshd /var/log/auth.log | lessDaemon LogA daemon is a program that runs in the background, generally without human intervention, performing someoperation important to the proper running of your system. The daemon log at /var/log/daemon.log andcontains information about running systemand application daemons such as the Gnome Display Managerdaemon gdm, the Bluetooth HCI daemon hcid, or the MySQLdatabase daemon mysqld. This can help youtrouble-shoot problems with a particular daemon.Again, use grep to find specific information, plugging in the name of the daemon youre interested in.Debug LogThe debug log at /var/log/debug and provides detailed debug messages from the Ubuntu system andapplications which log tosyslogd at the DEBUG level.Kernel LogThe kernel log at /var/log/kern.log provides a detailed log of messages from the Ubuntu Linux kernel.These messages mayprove useful for trouble-shooting a new or custom-built kernel, for example.Kernel Ring BufferThe kernel ring buffer is not really a log file per se, but rather an area in the running kernel you can query forkernel bootupmessages via the dmesg utility. To see the messages, use this:dmesg | lessOr to search for lines that mention the Plug & Play system, for example, use grep like this:dmesg | grep pnp | lessBy default, the system initialization script /etc/init.d/bootmisc.sh sends all bootup messages to thefile /var/log/dmesg as well. You can view and search this file the usual way.Messages LogThe messages log contains informational messages from applications, and system facilities, and is availableat/var/log/messages. This log is useful for examining message output from applications, and system facilitieswhich log to the syslog / sysklog daemon at the INFO level.Ubuntu Workshop – iWillStudy.com Page 16
  17. 17. System LogThe system log typically contains the greatest deal of information by default about your Ubuntu system. It islocated at/var/log/syslog, and may contain information other logs do not. Consult the System Log when youcant locate the desired log information in another log.Application LogsMany applications also create logs in /var/log. If you list the contents of your /var/log subdirectory, youwill see familiar names, such as /var/log/apache2 representing the logs for the Apache 2 web server,or /var/log/samba, which contains the logs for the Samba server. This section of the guide introduces somespecific examples of application logs, and information contained within them.Apache HTTP Server LogsThe default installation for Apache2 on Ubuntu creates a log subdirectory: /var/log/apache2. Within thissubdirectory are two log files with two distinct purposes:  /var/log/apache2/access.log - records of every page served and every file loaded by the web server.  /var/log/apache2/error.log - records of all error conditions reported by the HTTP serverBy default, every time Apache accesses a file or page, the access logs record the IP address, time and date,browseridentification string, HTTP result code and the text of the actual query, which will generally be a GET fora page view. Look at the Apache documentation for a complete rundown; quite a lot can be gleaned from thisfile, and indeed many statistical packages exist that perform analyses of these logs.Also, every time any error occurs, Apache adds a line to the error log. If you run PHP with error and warningmessages disabled, this can be your only way to identify bugs.CUPS Print System LogsThe Common Unix Printing System (CUPS) uses the default log file /var/log/cups/error_log to storeinformational and errormessages. If you need to solve a printing issue in Ubuntu, this log may be a good place tostart.Rootkit Hunter LogThe Rootkit Hunter utility (rkhunter) checks your Ubuntu system for backdoors, sniffers and rootkits, which areall signs of compromise of your system. The log rkhunter uses is located at /var/log/rkhunter.log.Samba SMB Server LogsThe Server Message Block Protocol (SMB) server, Samba is popularly used for sharing files between yourUbuntu computer and other computers which support the SMB protocol. Samba keeps three distinct types oflogs in the subdirectory /var/log/samba:  log.nmbd - messages related to Sambas NETBIOS over IP functionality (the network stuff)  log.smbd - messages related to Sambas SMB/CIFS functionality (the file and print sharing stuff)  log.[IP_ADDRESS] - messages related to requests for services from the IP address contained in the log file name, for example, log. Workshop – iWillStudy.com Page 17
  18. 18. X11 Server LogThe default X11 Windowing Server in use with Ubuntu is the Xorg X11 server, and assuming your computer hasonly one displaydefined, it stores log messages in the file /var/log/Xorg.0.log. This log is helpful fordiagnosing issues with your X11environment.GrubHowtoModifying boot options in GRUB Legacy  If you need to get into the grub menu to modify boot options or choose a different kernel, you need to press ESC just after it starts.  By default you have to press ESC within three seconds. If you want to increase this time limit, you can edit the grub configuration file /boot/grub/menu.lst, increasing the seconds in the TIMEOUT part. Alternatively you could have the menu always come up at boot time. To do this, comment out hiddenmenu by inserting a # at the beginning of the line. If the Ubuntu installer detected other operating systems on the disk during the installation, then the grub menu will be displayed by default and the timeout will be increased, so the step above will be unnecessary.  After pressing ESC you will be presented with a list of kernels and operating systems that you can boot. You can press an up or down arrow key to highlight a different kernel or operating system to boot. For example, you might need to boot into recovery mode to fix some problem with your operating system. To modify the boot options within the grub menu, highlight the operating system you want to edit and press e. There you will be presented with lines starting with root, kernel, initrd, quiet and savedefault. You may wish to make changes to any of these lines before booting. Boot options can be appended to the end of the kernel line, Boot Parameters. To receive a more verbose boot process you can remove the quiet line by highlighting it and pressing d to remove that line. You may also want to highlight the kernel line press e to edit and remove the word splash from the end of the line. After making any necessary modifications you can press b to boot that operating system. These modifications will not persist across reboots.Automagic Kernels List  Ubuntu uses a script called update-grub to modify menu.lst. Whenever you install kernel updates from the repositories,update-grub is run to update the grub settings. It automatically detects all of the kernels you have in the /boot directory, and applies various global settings to each one. The relevant parts of menu.lst that update-grub looks at are the ones in between the "### BEGIN AUTOMAGIC KERNELS LIST" and "### END DEBIAN AUTOMAGIC KERNELS LIST" lines. In this section of the menu.lst file, comments are preceded by at least two #, e.g. ## this is a comment. Global options are after single #, e.g. # groot=(hd0,4). The most common one to change is probably the groot option. Change this if /boot resides on a different partition than /(root). See the appropriate section on this page for more information about different /boot partitions. Another common option is kopt=, which are kernel options applied to all kernels in the menu.lst, read the next section below.Setting kernel parametersUbuntu Workshop – iWillStudy.com Page 18
  19. 19.  In /boot/grub/menu.lst, you will find a line like this: # kopt=root=/dev/sda1 ro This looks like a comment, but do not remove the # at the beginning. THIS IS IMPORTANT: grub sees this line as a comment and ignores it, but it is used as a configuration parameter by update-grub to generate the contents of the file thatgrub will read at boot. If you require additional kernel parameters (for example, if someone has asked you to test booting with certain parameters in order to troubleshoot a problem), add them to the end of the line, for example to add noapic:# kopt=root=/dev/sda1 ro noapic After editing the file, run: sudo update-grub  Note that you can temporarily add kernel parameters at the grub boot menu also, by pressing e and editing the kernel line.If /boot is on another partition  If /boot is mounted on another partition, it will mean that your Linux kernel will be restricted to the area of your hard disk where the /boot partition is located. That is a good way to overcome GRUB Error 18 in older computers. A Separate /boot partition is also needed when the root file system will be encrypted.  If your operating system was installed that way by the Ubuntu installer then it should work perfectly without the user needing to do anything. If for some reason you need to create your own separate /boot partition at some later time after the installation of your Ubuntu operating system, you must create an entry in your /etc/fstab file for it. You will also need to edit your /boot/grub/menu.lst file with the correct partition number in the groot line, see Automagic Kernels List further up in this page. If you do those two things correctly then when you use update-grub, you should never run into any problems. A Separate /boot partition is not very good for people who want to boot more than one Linux operating system because iit is tricky to get more than one Linux to share the same Separate /boot partition peacefully. For that, you need a Dedicated GRUB Partition, which contains only GRUB files and not necessarily any Linux kernels, and is operating system independant.Changing the Disk that Grub Legacy is installed to  Consider the following problem: You have two hard drives, one SATA (/dev/sda), the other PATA (/dev/hda). Your BIOS seems to think that PATA drives should always be booted in preference of SATA drives, but you want to boot from the SATA drive. Grub can work around this problem.Finding groot  First, figure out what Grub names the drives. This is listed in /boot/grub/device.map. There you will find a table of Grub-style names (e.g. (hd0)) and Linux-style names (e.g. /dev/hda/). You need to know what drive and partition /boot is on. To find where /boot is, use df: df /boot This should tell you the Linux-style partition name where /boot is. Then simply match it with the Grub- style name indevice.map. This is what groot should be.Example:  $ df /boot  Filesystem Size Used Avail Use% Mounted on  /dev/sda5 46M 15M 30M 33% /bootUbuntu Workshop – iWillStudy.com Page 19
  20. 20.   $ cat /boot/grub/device.map  (hd0) /dev/hda  (hd1) /dev/sda So groot should be (hd1,4) (note that Grub partition numbers are always one less than Linux numbers). Thus in/boot/grub/menu.lst, ## default grub root device ## e.g. groot=(hd0,0) # groot=(hd1,4)Finding kernel root  The other piece of the puzzle is telling the kernel where / is. Simply find out where / is mounted. df / This is what root should be in kopt.Example:  $ df /  Filesystem Size Used Avail Use% Mounted on  /dev/sda3 14G 8.3G 5.0G 63% / / is on /dev/sda3. Because this is going to be passed to the kernel, theres no need to translate to Grub notation. The ro causes the kernel to mount the drive read-only initially; later the drive will be remounted read/write. This is generally done so fsck can run on / at bootup. ## default kernel options ## default kernel options for automagic boot options ## If you want special options for specifiv kernels use kopt_x_y_z ## where x.y.z is kernel version. Minor versions can be omitted. ## e.g. kopt=root=/dev/hda1 ro # kopt=root=/dev/sda3 ro In summary, groot is where /boot is, and is what Grub sees that drive as. kopt=root is where / is, and is what the kernel sees that drive as.Boot splash images  Grub allows an image to be displayed behind the menu. You can obtain a set of images with the package "grub-splashimages", or you can make your own. The images must be 640x480 pixels, contain no more than 16 colors (but a smaller number like 12 works better to allow some different colors for the menu text), and be in gzipped xpm format. The GIMP can be used to resize (Image -> Scale Image...), reduce colors (Image -> Mode -> Indexed...), and can save to .xpm.gz files.Manual configuration  After creating a splash image, add a line like splashimage=(hd0,4)/boot/grub/splash.xpm.gz to your menu.lst file. A useful trick is to make a symlink to the actual image named splash.xpm.gz. cd /boot/grub sudo ln -s my_image.xpm.gz splash.xpm.gzUbuntu Workshop – iWillStudy.com Page 20
  21. 21. Grub loads the image from the disk upon boot; it is not stored in the MBR. If you use a symlink, you will not have toedit menu.lst and reinstall grub to change the image, you just have to change the symlink. Make sure any symlinkdoes not point to a file on another partition, for instance if you have /boot on a separate partition.Backup, Repairing and Reinstalling GRUB  To make a backup a copy of the existing menu.lst file use: cp /boot/grub/menu.lst /boot/grub/menu.lst.old You can try re-installing the grub using the Ubuntu Live CD, in two different ways.GUI 1. Boot your computer up with Ubuntu CD 2. Go through all the process until you reach "[!!!] Disk Partition" 3. Select Manual Partition 4. Mount your appropriate linux partions / /boot swap ..... 5. DO NOT FORMAT THEM. 6. Finish the manual partition 7. Say "Yes" when it asks you to save the changes 8. It will give you errors saying that "the system couldnt install ....." after that 9. Ignore them, keep select "continue" until you get back to the Ubuntu installation menu 10. Jump to "Install Grub ...." 11. Once it is finished, just restart your computerCommand line 1. Boot your computer up with Ubuntu CD 2. Open a terminal window or switch to a tty. 3. Go SuperUser (that is, type "sudo -s"). Enter root passwords as necessary. 4. Type "grub" 5. Type "find /boot/grub/stage1". Youll get a response like "(hd0,1)". Use whatever your computer spits out for the following lines. 6. Type "root (hd0,1)", or whatever your hard disk + boot partition numbers are for Ubuntu. 7. Type "setup (hd0)", to install GRUB to MBR, or "setup (hd0,1)" or whatever your hard disk + partition nr is, to install GRUB to a partition. 8. Quit grub by typing "quit". 9. Reboot and remove the bootable CD. If you cant boot into any of your Linux OSs:First, you need to get a grub prompt (grub>) somehow. So what you can do is:  Use a rescue disk, like Super Grub Disk, from which you can boot into your OS, or press the “c” key to get a GRUB prompt.  Use your Live *ubuntu CD. Boot into the LiveCD. Now get a terminal and proceed exactly as in Case 1, starting with sudo grub to get a GRUB prompt. Note: grub is not included with 9.10 Ubuntu LiveCDManually boot into a Linux OS  These are the same 3 methods you see in a menu.lst, except in menu.lst you have “title” lines and you don’t need the boot command (since it’s implied).Ubuntu Workshop – iWillStudy.com Page 21
  22. 22. Method #1: Chainload To chainload Linux which is on (hdx,y): grub> root (hdx,y) grub> chainloader +1 grub> boot grub> root (hdx,y), grub> setup (hdx,y) Method #2: Use the specific kernel-initrd commands (as in a full menu.lst), ending with the boot command. Method #3: Configfile This almost always works! Example: To boot into Kubuntu on sdb3 (= (hd1,2)), type grub> configfile (hd1,2)/boot/grub/menu.lst # you’ll get the boot menu on sdb3Important LinksKernel How-To: https://help.ubuntu.com/community/Kernel?action=show&redirect=KernelHowtoInstall the Server Kernel: https://help.ubuntu.com/community/EnablingPAEUpgrade Kernel: https://help.ubuntu.com/community/Kernel/Upgrade?action=show&redirect=UpgradeKernelKernel Compile: https://help.ubuntu.com/community/Kernel/CompileLinux Kernel Source: https://help.ubuntu.com/community/LinuxKernelSourceUbuntu Kernel Source: https://help.ubuntu.com/community/UbuntuKernelSourceBackup Your System: https://help.ubuntu.com/community/BackupYourSystemSoftware Management: https://help.ubuntu.com/community/SoftwareManagementSpeeding Up Ubuntu on Low-End System: https://help.ubuntu.com/community/LowEndSystemSupport Ask us any question on Ubuntu in this group, and we will make sure to reply back within 24Hours. A free service in the free world of open standards! http://www.iwillstudy.com/group/ubuntuUbuntu Workshop – iWillStudy.com Page 22