LPIC 102 Preparation Guide PDF
Document Details
Uploaded by DynamicCosmos2658
Linux Professional Institute
Alan McKinnon, Michel Bisson
Tags
Summary
This document is a preparation guide for the Linux Professional Institute (LPI) LPIC 102 exam. It covers topics such as kernel management, system boot and shutdown procedures, printing, and online documentation. It provides a detailed overview of the key concepts and commands necessary to pass the exam.
Full Transcript
Linux Professional Institute Exam LPIC 102 Preparation Guide Version 3 Alan McKinnon Michel Bisson LPIC 102 Preparation Guide Table of Contents About this document......................................................................viii Regarding the LPI...
Linux Professional Institute Exam LPIC 102 Preparation Guide Version 3 Alan McKinnon Michel Bisson LPIC 102 Preparation Guide Table of Contents About this document......................................................................viii Regarding the LPI 102 Exam............................................................ix Approximate number of questions per topic.................................................................ix Weight per topic............................................................................................................ix Tips on writing the exam................................................................................................x Topic 105: Kernel..............................................................................1 Summary.........................................................................................................................1 1.105.1 Manage/Query kernel and kernel modules at runtime.........................................2 Kernel types....................................................................................................................2 Kernel options at boot time............................................................................................2 Kernel Modules...............................................................................................................2 Loading Modules............................................................................................................3 Controlling modules.......................................................................................................4 lsmod..........................................................................................................................4 insmod........................................................................................................................4 modprobe...................................................................................................................4 rmmod........................................................................................................................4 depmod.......................................................................................................................5 modinfo......................................................................................................................5 /etc/modules.conf (or /etc/conf.modules).......................................................................5 uname.............................................................................................................................6 1.105.2 Reconfigure, build, and install a custom kernel and kernel modules...................8 Kernel source code.........................................................................................................8 Configuring the kernel...................................................................................................8 Getting the source code and the current kernel configuration file..........................8 Preparing the old.config for a new kernel source....................................................8 Configuration programs.............................................................................................9 Preparing the compilation.........................................................................................9 Compiling the kernel..................................................................................................9 Compiling the modules............................................................................................10 Installling the modules.............................................................................................10 Installing the new kernel.........................................................................................10 Make an initrd..........................................................................................................10 Install the Boot Loader............................................................................................10 All kernel compilation commands - short form.......................................................10 Safeguard against a faulty new kernel....................................................................11 Topic 106: Boot, Initialization, Shutdown and Runlevels................12 Summary.......................................................................................................................12 1.106.1 Boot the system...................................................................................................13 Boot sequence and Runlevels......................................................................................13 Giving kernel options to the bootloader.......................................................................13 /etc/modules.conf (or /etc/conf.modules).....................................................................14 Boot Log files................................................................................................................14 /etc/lilo.conf parameters...............................................................................................14 /boot/grub/menu.lst parameters...................................................................................15 1.106.2 Change runlevels and shutdown or reboot system.............................................16 Runlevels......................................................................................................................16 The /etc/init.d directory................................................................................................16 i LPIC 102 Preparation Guide Displaying the current runlevel....................................................................................17 Changing the runlevel..................................................................................................17 /etc/inittab file format...................................................................................................17 Shutting down the system properly.............................................................................18 shutdown command.................................................................................................19 Topic 107: Printing.........................................................................20 Summary.......................................................................................................................20 1.107.2 Manage printers and print queues......................................................................21 How lp printing works..................................................................................................21 Print related commands...............................................................................................21 Principle of print queues under Linux.........................................................................22 Definition of print queues in /etc/printcap...................................................................22 Other files.....................................................................................................................22 Controlling the print queues........................................................................................22 Displaying print jobs.....................................................................................................23 Deleting print jobs........................................................................................................23 Important points...........................................................................................................24 1.107.3 Print files..............................................................................................................25 Controllling print queues.............................................................................................25 Print engine lpd daemon..............................................................................................26 Special file types converters for printing....................................................................26 Important points...........................................................................................................27 1.107.4 Install and configure local and remote printers..................................................28 Printer definitions file: /etc/printcap............................................................................28 /etc/printcap examples.................................................................................................28 Using Filters.................................................................................................................29 apsfilter....................................................................................................................29 Magicfilter................................................................................................................30 Linking to a remote Windows print server..................................................................31 lpd print Daemon..........................................................................................................31 Topic 108: Documentation..............................................................33 Summary.......................................................................................................................33 1.108.1 Use and manage local system documentation....................................................34 Different sources of help..............................................................................................34 Man pages....................................................................................................................35 Files, programs and variables.................................................................................35 Locations of man pages..........................................................................................36 manpath...................................................................................................................36 Pager........................................................................................................................36 man command examples..........................................................................................36 man pages filters and GUIs.....................................................................................37 Filters examples..................................................................................................37 man command options.............................................................................................37 catman......................................................................................................................38 info pages.....................................................................................................................38 1.108.2 Find Linux documentation on the Internet.........................................................40 Linux Documentation Project.......................................................................................40 Newsgroups..................................................................................................................40 Newsgroup Archives....................................................................................................41 Mailing lists..................................................................................................................41 1.108.5 Notify users on system-related issues.................................................................42 Login Sequence............................................................................................................42 /etc/issue.......................................................................................................................42 ii LPIC 102 Preparation Guide Topic 109: Shells, Scripting, Programming and Compiling.............44 Summary.......................................................................................................................44 1.109.1 Customize and use the shell environment...........................................................45 Login vs. Non-login shell..............................................................................................45 Reason for 2 types of shell...........................................................................................45 Variable inheritance.....................................................................................................45 Interactive and non-interactive shells..........................................................................46 Sequence of events when bash starts..........................................................................46 Commands for shell/environment variables.................................................................46 Aliases...........................................................................................................................47 Functions......................................................................................................................47 Command search priority.............................................................................................48 set.................................................................................................................................48 unset.............................................................................................................................49 1.109.2 Customize or write simple scripts.......................................................................50 What is a shell script?...................................................................................................50 Conditions for running a script...............................................................................50 Language used in shell scripts................................................................................50 Passing parameters to a script.....................................................................................50 Special Parameters..................................................................................................51 The shift command.......................................................................................................51 The set and unset commands.......................................................................................51 Conditional statements.................................................................................................52 The if conditional branching directive....................................................................52 The case conditional branching directive...............................................................53 Looping in scripts.........................................................................................................53 The while conditional loop directive........................................................................53 The until conditional loop directive.........................................................................54 The for loop directive...............................................................................................54 Shell functions..............................................................................................................54 Exit codes and the variable $?.....................................................................................55 The && and || conditional branching......................................................................55 Mailing messages to root from a script.......................................................................55 Location and security for bash scripts.........................................................................56 CONDITIONAL EXPRESSIONS...................................................................................56 Test File Operators..................................................................................................56 Test String Operators..............................................................................................57 Test Integer Operators............................................................................................57 Other test Operators................................................................................................57 Topic 111: Administrative Tasks.....................................................59 Summary.......................................................................................................................59 1.111.1 Manage users and group accounts and related system files..............................60 /etc/passwd...................................................................................................................60 /etc/shadow...................................................................................................................60 Administration of user accounts..................................................................................61 useradd....................................................................................................................61 usermod...................................................................................................................61 userdel.....................................................................................................................62 passwd.....................................................................................................................62 chage........................................................................................................................62 newusers..................................................................................................................63 chpasswd..................................................................................................................63 /etc/login.defs...........................................................................................................63 Other login / user related commands......................................................................63 iii LPIC 102 Preparation Guide Administration of groups..............................................................................................64 Group administration commands............................................................................64 groupadd.............................................................................................................64 groupmod............................................................................................................65 groupdel..............................................................................................................65 gpasswd...............................................................................................................65 newgrp.................................................................................................................66 sg.........................................................................................................................66 grpck....................................................................................................................66 The groups configuration files.................................................................................66 /etc/group............................................................................................................66 /etc/gshadow.......................................................................................................66 Converting between password systems.......................................................................67 Checking the consistency of password and group files...............................................67 pwck.........................................................................................................................67 grpck........................................................................................................................68 Tips & Tricks................................................................................................................68 1.111.2 Tune the user environment and system environment variables.........................69 Shell configuration.......................................................................................................69 Parameters defined for bash in configuration files......................................................69 Environment Variables.................................................................................................70 The directory /etc/skel/.................................................................................................71 1.111.3 Configure and use system log files to meet administrative and security needs.........................................................................................72 The syslogd daemon.....................................................................................................72 Format of /etc/syslog.conf............................................................................................72 Facilities...................................................................................................................72 Levels.......................................................................................................................73 Destinations.............................................................................................................73 General examples.....................................................................................................74 Using a syslog server...............................................................................................74 Watching the real-time content of a log file.................................................................74 Generating log messages from the command line or scripts......................................74 Show the very start of kernel mesages at boot-up......................................................75 Stop generation of the -----MARK----- lines in the log files...........................................75 logrotate.......................................................................................................................75 Other possible log files (SuSE only).............................................................................75 Log file viewer under X-Windows (kde).......................................................................76 1.111.4 Automate system administration tasks by scheduling jobs to run in the future...........................................................................................77 at and cron services.....................................................................................................77 The cron/crontab service.........................................................................................77 Types of crontabs.....................................................................................................77 Users crontabs....................................................................................................77 System wide crontab file: /etc/crontab...............................................................78 The /etc/cron.d/ directory...................................................................................78 The /etc/cron.{hourly,daily,weekly,monthl} directories....................................78 File format of the user crontab...........................................................................78 File format of the system crontabs.....................................................................78 Rules for CRONTAB files.........................................................................................78 Crontab commands..................................................................................................79 Access control of cron scheduling service..............................................................79 Examples of user crontabs......................................................................................80 The anacron service.....................................................................................................80 The file /etc/anacrontab...........................................................................................81 iv LPIC 102 Preparation Guide The at spool service......................................................................................................81 How to launch an AT job..........................................................................................82 at options.................................................................................................................82 Time formats............................................................................................................82 atq............................................................................................................................82 atrm..........................................................................................................................83 AT command on one line (useful in scripts)............................................................83 Files involved...........................................................................................................83 Alternatives to at and Batch.........................................................................................83 1.111.5 Maintain an effective data backup strategy........................................................84 Types of backups..........................................................................................................84 Full Backup..............................................................................................................84 Differential Backup..................................................................................................84 Incremental Backup.................................................................................................84 Restoring data..............................................................................................................84 Backup media devices files..........................................................................................85 Basic backup programs................................................................................................85 tar (Tape ARchive)...................................................................................................85 dump........................................................................................................................86 restore...................................................................................................................... 87 cpio...........................................................................................................................88 dd.............................................................................................................................89 1.111.6 Maintain system time..........................................................................................90 Time clocks under Linux..............................................................................................90 Clock control programs................................................................................................90 Time settings and zones...............................................................................................90 Setting the time in Linux..............................................................................................91 hwclock....................................................................................................................91 date..........................................................................................................................92 Network Time Service..................................................................................................93 ntpdate.....................................................................................................................94 ntpd or xntpd...........................................................................................................94 Topic 112: Networking Fundamentals.............................................95 Summary.......................................................................................................................95 1.112.1 Fundamentals of TCP/IP......................................................................................96 OSI and TCP/IP models................................................................................................96 TCP header...................................................................................................................97 UDP header...................................................................................................................97 IP Header......................................................................................................................97 TCP/IP Network Tools..................................................................................................97 IP Addresses Classes....................................................................................................98 ICMP Messages............................................................................................................98 Error Messages........................................................................................................98 Information Messages..............................................................................................98 TCP/IP Services............................................................................................................99 1.112.3 TCP/IP configuration and troubleshooting........................................................ 100 Networking configuration files..................................................................................100 Networking tools........................................................................................................101 Boot time scripts........................................................................................................102 1.112.4 Configure Linux as a PPP client........................................................................104 Connection protocols..................................................................................................104 PPP Protocol...............................................................................................................104 Sequence of PPP connection build-up.......................................................................104 Modem connection build-up..................................................................................104 v LPIC 102 Preparation Guide PPP Connection via login chat script....................................................................105 PPP Connection set-up...........................................................................................105 The dialer wvdial........................................................................................................106 Extra wvdial options for pppd...............................................................................106 pppd options...............................................................................................................107 Content of /etc/ppp/options file..................................................................................107 Shutting down a ppp connection...............................................................................107 Topic 113: Networking Services....................................................108 Summary.....................................................................................................................108 1.113.1 Configure and manage inetd, xinetd, and related services..............................109 inetd............................................................................................................................109 The configuration file inetd.conf...........................................................................109 xinetd..........................................................................................................................110 Advantages of xinetd over inetd............................................................................110 xinetd.conf.............................................................................................................110 tcpwrappers................................................................................................................111 Wildcards...............................................................................................................112 1.113.2 Operate and perform basic configuration of sendmail.....................................114 Mail system components............................................................................................114 SMTP Principle...........................................................................................................114 sendmail configuration file.........................................................................................114 sendmail mailboxes....................................................................................................115 Starting sendmail.......................................................................................................115 Permanent Internet connection.............................................................................115 Temporary Internet connection.............................................................................115 Mail Aliases................................................................................................................116 Piping mails to programs...........................................................................................116 Redirecting incoming mail.........................................................................................116 Outgoing mail server..................................................................................................117 Files in /etc/mail/ Directory........................................................................................117 Access control of incoming mail................................................................................117 Converting the sender name......................................................................................118 Mail delivery control..................................................................................................118 Virtual mail domains or redirections.........................................................................118 Important Note...........................................................................................................119 1.113.3 Operate and perform basic configuration of Apache........................................120 Configuration files......................................................................................................120 Directives of Apache configuration file......................................................................120 List of directives to remember...................................................................................121 Main server directives...........................................................................................121 Configuration of Virtual Servers...........................................................................122 Starting and stopping of the Apache main Daemon..................................................123 The httpd daemon command line options..................................................................123 1.113.4 Properly manage the NFS, smb, and nmb daemons.........................................124 NFS - Network File System........................................................................................124 Mounting an NFS remote directory......................................................................124 Setting-up the NFS server.....................................................................................124 NFS Server processes...........................................................................................125 UID and GID in NFS mounted shares...................................................................126 Squashing UID and GID for ALL...........................................................................126 Selecting which UIDs and GIDs will be squashed................................................126 Mounting share as root user.................................................................................126 Simple shares with SAMBA........................................................................................127 smb.conf.................................................................................................................128 vi LPIC 102 Preparation Guide Structure of smb.conf.......................................................................................128 Sections in smb.conf.........................................................................................128 Parameters of section [global]..........................................................................128 Parameters of section [homes].........................................................................129 Parameters of section [printers].......................................................................129 Parameters of a section for a single printer.....................................................129 Parameters of a section for a normal file share................................................130 Setting passwords for share access..................................................................130 Security types in Samba authentication...........................................................130 Using WINS server for NetBIOS names conversion........................................131 Using Samba as WINS server...........................................................................132 Typical Configuration of smb.conf........................................................................133 Server Global Options.......................................................................................133 Interfaces or networks that samba will respond to..........................................133 Standard Shares................................................................................................133 Normal Shares..................................................................................................134 List of extra usefull share parameters..............................................................134 1.113.5 Setup and configure basic DNS services..........................................................136 Introduction................................................................................................................ 136 Registering Domain Names........................................................................................136 Resolving host names.................................................................................................136 BIND DNS sever.........................................................................................................137 BIND-4 DNS Server...............................................................................................138 BIND-8/9 DNS Server............................................................................................138 Configuration of BIND-4........................................................................................138 Configuration of BIND-8/9.....................................................................................138 DNS Database Files....................................................................................................139 Types of database files..........................................................................................139 Record syntax........................................................................................................140 Types of DNS records............................................................................................140 Example of Database Files....................................................................................141 DNS Resolving request tools......................................................................................142 Cache only DNS..........................................................................................................143 1.113.7 Set up secure shell (OpenSSH).........................................................................144 Topic 114: Security.......................................................................145 Summary.....................................................................................................................145 1.114.1 Perform security administration tasks..............................................................146 1.114.2 Setup host security............................................................................................147 1.114.3 Setup user level security...................................................................................148 vii LPIC 102 Preparation Guide About this document Version 3 by Alan McKinnon I needed an exam preparation guide for my students once they had completed their Linux training and wanted to prepare to write the LPI level 1 exams. I found version 2 of this guide by Michel Bisson on the LPI website (http://www.lpi.org) and it suited my needs. The content of this guide is essentially still the same as Michel wrote it. I have merely reformatted it, changed the order of some sections and fixed some typos and grammar errors. Any queries about this guide should be directed to me: [email protected] This guide is re-released under the same terms as the original – see below. Version 2 by Michel Bisson This document was produced to help candidates pass the LPI 102 exam. I have created it essentially as a reference document and not as a tutorial. That's why in general, it doesn't have many explanations for the subjects treated. I usually use it in my courses as exam preparation. To my knowledge it covers the most important aspects of the topics asked in the exam, but it's layout and content organization is not perfect. Helped by this document and with enough practice, most of my students passed the exam. In some topics I have added more information than is needed for the LPI 102 exam. When in doubt, refer to the description of the requirements located at the beginning of each topic. This is a free document. You may distribute, modify, or improve it for personal or commercial use as you wish.. I take no responsibility of any kind for the accuracy of the information in this document, nor for the success or failure of any participants in passing the exam. I would appreciate it that if you make modifications to this document, you send me a copy of the new version. Please let me know of any errors or inaccuracies in the information in this document, that would help me improve it. Feedback of any kind is welcome. If anybody wants to contribute to this document, you're very welcome, please contact me at [email protected] I hope it will help you to prepare for the LPI 102 exam and remember, that practice, practice, and more practice is the key. Note: This guide is still incomplete. The section 1.112.1 Fundamentals of TCP/IP is incomplete and might stay that way, at least for a while. This section needs to be expanded with explanations which I don't have time to write. At the moment there are only protocol references. viii LPIC 102 Preparation Guide Regarding the LPI 102 Exam This is a required exam for LPI certification Level 1. It covers basic system administration skills that are common across all distributions of Linux. Each objective is assigned a weighting value. The weights range roughly from 1 to 10, and indicate the relative importance of each objective. Objectives with higher weights will be covered in the exam with more questions. Approximate number of questions per topic Total number of questions 73 The Linux Kernel................................................................................................................. 5 Boot, Initialization, Shutdown and Runlevels.....................................................................4 Printing on Linux.................................................................................................................3 Documentation....................................................................................................................6 Shells, Scripting, Programming and Compiling.................................................................6 Administrative Tasks.........................................................................................................15 Networking Fundamentals................................................................................................10 Networking Services.........................................................................................................18 Linux Security.....................................................................................................................6 Weight per topic Total weights for all topics and sections 99 Topic 105 Kernel 7 1.105.1 Manage/Query kernel and kernel modules at runtime................................4 1.105.2 Reconfigure, build, and install a custom kernel and kernel modules.........3 Topic 106 Boot, Initialization, Shutdown and Runlevels 6 1.106.1 Boot the system............................................................................................3 1.106.2 Change runlevels and shutdown or reboot system.....................................3 Topic 107 Printing 3 1.107.2 Manage printers and print queues..............................................................1 1.107.3 Print files......................................................................................................1 1.107.4 Install and configure local and remote printers..........................................1 Topic 108 Documentation 8 1.108.1 Use and manage local system documentation............................................4 1.108.2 Find Linux documentation on the Internet..................................................3 1.108.5 Notify users on system-related issues.........................................................1 Topic 109 Shells, Scripting, Programming and Compiling 8 1.109.1 Customize and use the shell environment...................................................5 1.109.2 Customize or write simple scripts...............................................................3 Topic 111 Administrative Tasks 21 1.111.1 Manage users and group accounts and related system files......................4 1.111.2 Tune the user environment and system environment variables.................3 ix LPIC 102 Preparation Guide 1.111.3 Configure and use system log files to meet admin and security needs......3 1.111.4 Automate system admintasks by scheduling jobs to run in the future.......4 1.111.5 Maintain an effective data backup strategy................................................3 1.111.6 Maintain system time...................................................................................4 Topic 112 Networking Fundamentals 14 1.112.1 Fundamentals of TCP/IP..............................................................................4 1.112.3 TCP/IP configuration and troubleshooting..................................................7 1.112.4 Configure Linux as a PPP client..................................................................3 Topic 113 Networking Services 24 1.113.1 Configure and manage inetd, xinetd, and related services.........................4 1.113.2 Operate and perform basic configuration of sendmail................................4 1.113.3 Operate and perform basic configuration of Apache..................................4 1.113.4 Properly manage the NFS, smb, and nmb daemons...................................4 1.113.5 Setup and configure basic DNS services....................................................4 1.113.7 Set up secure shell (OpenSSH)...................................................................4 Topic 114 Security 8 1.114.1 Perform security administration tasks.........................................................4 1.114.2 Setup host security......................................................................................3 1.114.3 Setup user level security.............................................................................1 Tips on writing the exam Most questions that require you to fill-in the blanks, don't require any options. eg. cat or ls or cp (without options) Use your experience and common sense to deciding what is important and what is not when studying. When in doubt, just read the description of the requirements located at the beginning of each topic again. I recommend you create a checklist of topics for yourself and to review it once in a while. This can help avoid spending too much time in one subject at the expense of other important subjects. Note the weight of each topic and spend the equivalent amount of time on it. When doing the exam, I recommend you first answer the questions that you are sure of and then go back to the other ones afterwards. Read the questions thoroughly and make sure you understand them well. Then read ALL the answers carefully before answering. I almost got caught a few times, answering something I was sure couldn't be anything else, but when I read the other answers I saw which one was really the correct answer. The exam is difficult and needs concentration and a good memory. It is not recommended to eat a heavy meal before the exam. There is no need to rush through the exam and risk overlooking something. There is more than enough time to answer all the questions. When you're finished and there is still time left, review your answers once. x Topic 105: Kernel Topic 105: Kernel Total weight for this topic 7 1.105.1 Manage/Query kernel and kernel modules at runtime................................4 1.105.2 Reconfigure, build, and install a custom kernel and kernel modules.........3 Summary TODO 1 Topic 105: Kernel 1.105.1 Manage/Query kernel and kernel modules at runtime Description: Candidates should be able to manage and/or query a kernel and kernel loadable modules. This objective includes using command-line utilities to get information about the currently running kernel and kernel modules. It also includes manually loading and unloading modules as appropriate. It also includes being able to determine when modules can be unloaded and what parameters a module accepts. Candidates should be able to configure the system to load modules by names other than their file name. Weight: 4 Key files, terms, and utilities include: /lib/modules/kernel-version/modules.dep /etc/modules.conf & /etc/conf.modules depmod insmod lsmod rmmod modinfo modprobe uname Kernel types In Linux kernel version 1.x.x the kernel is monolithic and must be recompiled for new features or device drivers to become available. From Linux kernel version 2.x.x the kernel is modular and external modules can be compiled separately from the kernel and dynamically loaded or unloaded. They are called Kernel Modules. Kernel options at boot time The list of options supported by the current kernel can be found in: /usr/src/linux/Documentation/kernel-parameters.txt. Kernel Modules The kernel modules are normally located in /lib/modules/kernel-version /etc/magicfilter lpd Printer definitions file: /etc/printcap This file can contain the definitions of local and remote printers. Entries in this file are in reality only one line per printer, the '\' at the end of each line simulates the single line like in bash scripts. Except for the name of the printer each item starts and ends with a ':'. See examples below: Keywords: lp|ljet4: lp(default) or ljet4 are 2 alias names of the printer. :af=Filename: Account File for the printer :if=FilterName: Input Filter Name :lp=PrinterDevice: Local Printer device, such as /dev/lp0. :lf=Log_File: Error messages log file. :mx=Max_Size: Maximum size of a print job in blocks. 0 = no limit :rm=RemMachineName: Remote Machine. Printer server name if used remotely. :rp=RemPrinter: Remote Printer Name on the remote machine. :sd=Spool_directory: Spool Directory under /var/spool/lpd. :sh: Suppress Header pages for a single printer definition. /etc/printcap examples lp|hplaser:\ :lp=/dev/lp0:\ :sd=/var/spool/lp:\ :mx#0:\ :lf=/var/spool/lp/hp-log: Here (above) the printer device is local (:lp=/dev/lp0:). The next example doesn't use the keyword lp=, instead it uses rm= for remote: 28 Topic 107: Printing lp1|remote printer on marvin:\ :sd=/var/spool/lp1:\ :rm=marvin.mydomain.net:\ :rp=lp:\ :sh:mx#0: Note: Pay attention to the function of the /etc/printcap and its syntax including the variable's keywords. Using Filters Filters are used to convert different document formats (txt, HTML, Postscript, graphics, etc) into Postscript format (ps). It is then passed on to GhostScript which (if needed) converts it into a raster format (Printer-specific data) and then sends it to the printer. Filters look at the 'Magic Code' at the beginning of a document to determine the type of file. If it is already a PostScript document it will be sent to GhostScript without changes. Two of the most popular filters used in Linux (that we need to know for the LPI-102) are Apsfilter and Magicfilter. apsfilter Its configuration file: /etc/apsfilter/apsfilterrc Its configuration tool: apsfilterconfig Its location: /usr/lib/apsfilter/filter10 * * * * root ping -c1 www.suse.de Sends a ping once every 10 minutes (*/10)to www.suse.de as user root. (The username entry is only in /etc/crontab) The anacron service anacron is a service similar to cron, except that its frequency is expressed in days and not in minutes. Unlike cron, it does not assume that the machine is running continuously. Hence, it can be used on machines that aren't running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron. When executed, anacron reads a list of jobs from a configuration file, normally / etc/anacrontab. This file contains the list of jobs that anacron controls. Each job entry specifies a period in days, a delay in minutes, a unique job identifier, and a shell command. For each job, anacron checks whether this job has been executed in the last n days, where n is the period specified for that job. If not, anacron runs the job's shell command, after 80 Topic 111: Administrative Tasks waiting for the number of minutes specified as the delay parameter. After the command exits, Anacron records the date in a special timestamp file for that job, so it can know when to execute it again. Only the date is used for the time calculations. The hour is not used. The file /etc/anacrontab The /etc/anacrontab file describes the jobs controlled by anacron. Entries are one line each and can be one of four kinds: job-description lines, environment assignments, empty lines or comments. Environment assignments, blank lines and comments are the same as for crontab. Job-description lines are of the form: period delay job-identifier command The period is specified in days The delay is specified in minutes The job-identifier can contain any non-blank character, except slashes'/'. It is used to identify the job in anacron messages, and as the name for the job's timestamp file. The command can be any shell command. Eg 1 5 cron.daily nice run-parts --report /etc/cron.daily 7 10 cron.weekly nice run-parts --report /etc/cron.weekly 30 15 cron.monthly nice run-parts --report /etc/cron.monthly In this example, anacron runs all the scripts contained in the directory /etc/cron.daily, (using default nice value) every day as soon as the day has changed after it has waited for 5 minutes (delay). runs all the scripts contained in the directory /etc/cron.weekly, every week as soon as the 7th day has come after it has waited for 10 minutes. runs all the scripts contained in the directory /etc/cron.monthly, every month as soon as the 30th day has come after it has waited for 15 minutes. The at spool service at is a service (atd daemon) that checks its job queue every minute and executes the ones that are programmed to be run at that time. at Runs a command only once at a predetermined time. batch command is only a script and does the same as at except that it executes commands when system load levels permit; in other words, when the load average drops below 0.8 Syntax: at [options] time batch [options] time 81 Topic 111: Administrative Tasks How to launch an AT job Type at and any options and time of execution Enter the command(s) you want to run (press Enter after each command). Note: The commands MUST contain the full path of the command. Press Ctrl-D to save the job(s). at options -b Run command only when the system load is low -d jobNr Delete an at job from queue (same as atrm) -f filename Read job from a specified file -l List all jobs for that user. If user is root, shows all jobs. -m Mails user when job completes. -q queueName Send the jobs to a specific queue. Queue names are single letters: a to z and A to Z. a is the default and set highest AT priority (nice=2). b is the default for batch command queues. The higher the letter the higher the nice value (less priority): nice of: a=2 b=4 c =6 d=8 etc. Time formats now Well.... NOW! 17:00 At 17:00 hours +3 hours In 3 hours from now +2 minutes In 2 minutes from now +2 days Same time as now but In 2 days +3 months Same time as now but In 3 months 19:15 12.03.01 On 12 March 2001 at 19:15 now, noon, teatime (4pm), Stated times midnight, today, tomorrow 4PM At 4 pm today if not too late, otherwise tomorrow at 4PM 16:00 + 3 days At 16:00 hours in 3 days mon Next Monday same time. Days are: mon, tue, wed, thu, fri, sat, sun 18:25 31 March 2001 On March 31 2001 at 18:25 Allowed date formats: MMDDYY, MM/DD/YY, DD.MM.YY atq Show the AT jobs queue of user. Includes job numbers If user is root, shows all jobs. Same as at -l 82 Topic 111: Administrative Tasks atrm atrm jobNr [jobNr]... Deletes an AT job from the jobs queue AT command on one line (useful in scripts) echo "command1;comman2;..." | at time Example: xhost + localhost echo "xmessage -display :0 'It works'" | at +1 minutes watch -n1 atq Files involved /var/spool/atjobs Where the jobs are stored. at Produces jobs starting with a if queue is not given (-q). These jobs are a snapshot of environment variables plus the commands given. /var/spool/atspool Unknown!! /proc/loadavg Average system load value that gives a one line display of the following information: The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. /var/run/utmp Uptime of the processes list in binary format. Used to determine the system load averages. /etc/at.allow List of users that are allowed to use the commands batch and at. If present: /etc/at.deny is ignored and all users listed here are allowed to use at. /etc/at.deny List of users that are NOT allowed to use the at and batch commands. If present and /etc/at.allow is NOT present, then all users are allowed to use at and batch except the ones listed here. Alternatives to at and Batch If the system is heavily loaded, consider another batch system like nqs. 83 Topic 111: Administrative Tasks 1.111.5 Maintain an effective data backup strategy Description: Candidate should be able to plan a backup strategy and backup file systems automatically to various media. Tasks include dumping a raw device to a file or vice versa, performing partial and manual backups, verifying the integrity of backup files and partially or fully restoring backups. Weight: 3 Key files, terms, and utilities include: cpio dd dump restore tar Types of backups Generally, there are three different kinds of backup: Full Backup Backs up all files, regardless of whether they were previously backed up or not. This method uses the most media space. In this case it is recommended to use compression like gzip or other methods to reduce the media space needed. Differential Backup Saves only files that have been modified or created since the last Full Backup. Normally a Full backup is made and then regular differential Backups are performed. Advantages: Only the full backup and the last good differential backup are needed to restore the whole of the data. Disadvantages: Takes longer to make than incremental backups and needs larger media. Incremental Backup Saves only the files that have been changed or created since the last backup (Full or Differential). Advantages: Shorter to make than the differential backups and needs smaller media size. Disadvantages: All of the incremental backups, up to the last known good one, and the full backup are needed for restoring the whole data. If one of the incremental backups has some media fault, the entire backup may be unreliable. Note: Normally a full backup is coupled with either periodic differential backups or periodic incremental backups. Restoring data With differential backups: The Full backup and the last good differential backup is needed. 1 - Read the full backup 84 Topic 111: Administrative Tasks 2 - Read last good differential backup. With incremental backups: The Full backup and ALL of the incremental backup are needed. 1 - Read the Full Backup 2 - Read sequentially each incremental backup up to the last good one. Backup media devices files To create backups, external media devices are needed. Here are some common ones used under Linux: /dev/st0 First SCSI Tape Drive /dev/ft0 First floppy-controller tape drive /dev/fd0 First floppy disk drive /dev/hdx May be an ATAPI Zip or other removable disk Basic backup programs tar (Tape ARchive) Recursively creates archives of files and directories including file properties. It requires at least one mode option to function properly. Basic Mode options: -c Create a new archive. -t List the content of the archive -x Extract files from the archive. Common Options: Basic mode options f tarfile Unless tar is using standard I/O, use the 'f' option with tar to specify the tarfile. This might be simply a regular file or it may be a device such as /dev/st0. v Verbose mode. By default, tar runs silently. When 'v' is specified, tar reports each file as it is transferred. w Interactive mode. In this mode, tar asks for confirmation before archiving or restoring files. This option is useful only for small archives. z Enable compression. When using 'z', data is filtered through the gzip compression program prior to being written to the tarfile, saving additional space. The savings can be substantial, at times better than an order of magnitude depending on the data being compressed. 85 Topic 111: Administrative Tasks An archive created using the 'z' option must also be listed and extracted with 'z'; tar will not recognize a compressed file as a valid archive without the 'z' option. Tarfiles created with this option will have the.tar.gz file extension. j BZ2 Compression. Similar to the 'z' compression except that it’s compression method is a bit more efficient on the media space used. The filename of the archive should then have the extension.tar.bz2 N date Store only files newer than the date specified. This option can be used to construct an incremental or differential backup scheme. V "label" Adds a label to the.tar archive. Quotes are required to prevent the label from being interpreted as a filename. A label is handy if you find an unmarked tape or poorly named tarfile. dump From the BSD UNIX world, dump allows you to backup a whole partition or a full directory. But Linux dump is unique and written specially for ext2. Now a version for ReiserFS is also available. dump searches through files and decides which ones should be written. Output of dump: Hard Disk, or Tape or File(Option -f) Feature: Span files on multiple medias.(medium change). Max. Backup Levels: 10 (0-9) Level 0: Full backup Level 1-9: Incremental backup relative to the lower level backup. Syntax: dump [-level] [-ua] [-f BackupFile] Source Options: -level 0 to 9 -u Update. Uses the file /etc/dumpdates to know which update to do. -a Automatically asks for next medium change. -f BackupFile Name of destination filename. Example: /dev/st0 Tape drive. 86 Topic 111: Administrative Tasks /bckp/backup01.dump Normal file. Source Device (partition) or directory name to backup. The file /etc/dumpdates contains a list of backups already done. Format: Source BackupLevel Date_Time eg. /dev/sda5 0 Sat May 18 23:55:32 2003 /dev/sda5 1 Mon May 20 23:54:13 2003 Shows that on Sat. May 18 a Full backup was made using the command: dump -0ua -f /dev/tape /dev/hda5 and an incremental backup relative to the Full backup using the command: dump -1ua -f /dev/tape /dev/hda5 restore This program is the counterpart of the backup program dump. It is not only used for restoring but also to compare the backed-up data with the current original data. Commonly used options are: restore -C -f BackupDevice Will compare (-C) the content of the BackupDevice (eg. /dev/st0) to the original and the differences will be shown. restore -i -f BackupDevice Will start in interactive (-i) mode and wait for commands relating to the list of files to restore. The most important commands are: cd Directory Changes to another directory on the backed-up medium. ls [Directory |file] Lists the current directory (like bash's ls) add Directory|File Add the Dir. or File in the list to restore. delete Directory|File Delete the Dir or File in the list to restore. extract Start the restoring the files listed. quit Exit restore program. Important: When the restore is activated, its restores the files in the current directory. Therefore if files backed-up to /dev/st0 need to be restored to /dev/hda8 which is mounted on /mnt/data, you need to change the current directory to the mount point. Example: cd /mnt/data restore -r -f /dev/st0 87 Topic 111: Administrative Tasks Here the full Backup located in /dev/st0 will be restored to the directory /mnt/data which is the mount point of /dev/hda8 partition. Restoring single files: restore -x -f BackupDevice File1 File2 File3.... Restores File1 File2 File3 etc. from the BackupDevice to the current directory. cpio This back-up utility can handle different types of backup format including the TAR format. Its advantage over tar is that, it takes the list of the files to backup from STDIN instead of from the command line. This way it facilitates the use of the find program to feed the list of files to backup. cpio Modes of operation: copy-out (-o) The output of the program is an archive: Backup copy-in (-i) Files are extracted from the archive: Restore copy-pass (-p) Simple copy of files from one location to another: Copy cpio works with a very large amount of options. They are not the goal of LPI-102. Here are some commonly used cpio options to remember: -d Create directories if needed. -f Specifies a filename -t Shows the contents of an archive. -u Overwrites existing files -v Runs in verbose mode Examples of commands: cpio -iv < /dev/tape The above command reads in files from a tape and displays them as it is operating. find / -name mart* | cpio -pdv /home/martin/backups Copy all files from the whole system which start with mart to the home subdirectory of martin, creating all the needed subdirectories (-d), using the verbose mode (-v). find. -name "*.old" | cpio -ocBv >/dev/st0 88 Topic 111: Administrative Tasks Backup (-o) all files with ext..old, using the new (SVR4) portable format (-c) and the block size of 5120 Bytes(-B) to a tape drive (/dev/st0), using the verbose mode (-v). cpio -icdv "*.c" < /dev/st0 Restore (-i) all the *.c files using the new (SVR4) portable format (-c), creating new subdirectories if needed (-d) from the tape drive (/dev/st0), using the verbose mode (-v). find. -depth | cpio -pd /tmp/newdir Copy (-p) recursively all files in current directory (.) to /tmp/newdir, creating all the needed subdirectories (-d). dd This DiskDump program allows you to read and write directly to and from a block device as well as normal files. It can copy data blocks directly from a device to a file and vice versa as well as device to device. Syntax: dd if=InputFile of=OutputFile bs=BlockSize count=NumberOfBlocks Extra options: ibs=InputBlockSize obs=OutputBlockSize Sets the input block size and the output block size when they differ. The default for bs is the original block size of if=InputFile The default for count is the whole device or file. Examples: To copy a full partition to a file: dd if=/dev/hda4 of=/tmp/hda4_Image.img To backup the current MBR to a file: dd if=/dev/hda of=/var/backup/MBR.img bs=512 count=1 To create a CD image file from a CD-ROM. dd if=/dev/cdrom of=/home/martin/images/cdrom2.img To create a bcakup of partition to a Streaming Tape: dd if=/dev/hda4 of=/dev/st0 To restore the above backup: dd if=/dev/st0 of=/dev/hda4 89 Topic 111: Administrative Tasks 1.111.6 Maintain system time Description: Candidate should be able to properly maintain the system time and synchronize the clock over NTP. Tasks include setting the system date and time, setting the BIOS clock to the correct time in UTC, configuring the correct timezone for the system and configuring the system to correct clock drift to match NTP clock. Weight: 4 Key files, terms, and utilities include: /usr/share/zoneinfo /etc/timezone /etc/localtime /etc/ntp.conf /etc/ntp.drift date hwclock ntpd ntpdate Time clocks under Linux Linux uses two clocks: Hardware Clock: aka RTC, RealTimeClock, CMOS Clock, BIOS Clock. Runs independent of the Operating System and runs even when the computer is turned OFF, as long as the CMOS battery lasts. Software Clock: aka System Clock. Runs via the system timer interrupt. Counts the number of seconds since 1st. Jan. 1970. Is the main clock under Linux. At boot time it reads the hardware clock and continues alone from there. Clock control programs Under Linux 2 main programs are used to control the 2 clocks. hwclock Controls the Hardware Clock date Controls the System Clock Time settings and zones There are 2 standard ways to set the clock. Local time Time at this geographic location UTC Universal Co-ordinate Time. Normal way of setting the time from which a time zone 90 Topic 111: Administrative Tasks offset is given to calculate the Local Time. Setting the time in Linux The procedure is relatively simple: 1) Set the Hardware clock to UTC via the BIOS setup. 2) Set the environment variable TZ to the proper time zone using the script: tzselect Alternative step 2: Use the program tzconfig which will set a symbolic link in the form of: ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime 3) To tell Linux that our Hardware clock and system clock are set to UTC run: hwclock --utc --hctosys hwclock This program is used to display or set the Hardware clock. Syntax: hwclock [option] Options: (only one of the following options is used at a time) --show Read the Hardware Clock and print the time to Standard Output. The time shown is always in local time, even if you keep your Hardware Clock in Coordinated Universal Time (UTC). --set Set the Hardware Clock to the time given by the --date option. --hctosys Set the System Time from the Hardware Clock. Also set the kernel's timezone value to the local timezone as indicated by the TZ environment variable and/or / usr/share/zoneinfo. This is a good option to use in one of the system startup scripts. --systohc Set the Hardware Clock to the current System Time. --adjust Add or subtract time from the Hardware Clock to account for systemic drift since the last time the clock was set or adjusted. --utc Indicates that the Hardware Clock is kept in Universal Coordinated Time. --localtime 91 Topic 111: Administrative Tasks Indicates that the Hardware Clock is kept in Local Time. It is your choice whether to keep your clock in UTC or local time, but nothing in the clock tells which you've chosen. So this option is how you give that information to hwclock. date This program is used to show or set the System time. Syntax: date [options] Options: +text_and_metacodes Allows control of the display of the current time /and/or date. Example: date "+It is now %H Hours and %M Minutes" Will have the following result: It is now 14 Hours and 33 Minutes Interpreted sequences are: %% a literal % %a locale's abbreviated weekday name (Sun..Sat) %A locale's full weekday name, variable length (Sunday..Saturday) %b locale's abbreviated month name (Jan..Dec) %B locale's full month name, variable length (January..December) %c locale's date and time (Sat Nov 04 12:02:33 EST 1989) %C century (year divided by 100 and truncated to an integer) [00-99] %d day of month (01..31) %D date (mm/dd/yy) %e day of month, blank padded ( 1..31) %F same as %Y-%m-%d %g the 2-digit year corresponding to the %V week number %G the 4-digit year corresponding to the %V week number %h same as %b %H hour (00..23) %I hour (01..12) %j day of year (001..366) %k hour ( 0..23) %l hour ( 1..12) %m month (01..12) %M minute (00..59) %n a newline 92 Topic 111: Administrative Tasks %N nanoseconds (000000000..999999999) %p locale's upper case AM or PM indicator (blank in many locales) %P locale's lower case am or pm indicator (blank in many locales) %r time, 12-hour (hh:mm:ss [AP]M) %R time, 24-hour (hh:mm) %s seconds since `00:00:00 1970-01-01 UTC' (a GNU extension) %S second (00..60); the 60 is necessary to accommodate a leap second %t a horizontal tab %T time, 24-hour (hh:mm:ss) %u day of week (1..7); 1 represents Monday %U week number of year with Sunday as first day of week (00..53) %V week number of year with Monday as first day of week (01..53) %w day of week (0..6); 0 represents Sunday %W week number of year with Monday as first day of week (00..53) %x locale's date representation (mm/dd/yy) %X locale's time representation (%H:%M:%S) %y last two digits of year (00..99) %Y year (1970...) %z RFC-822 style numeric timezone (-0500) (a nonstandard extension) %Z time zone (e.g., EDT), or nothing if no time zone is determinable By default, date pads numeric fields with zeroes. GNU date recognizes the following modifiers between `%' and a numeric directive. `-' (hyphen) do not pad the field `_' (underscore) pad the field with spaces Time Parameters MMDDhhmm Set the System time to a specific value MMDDhhmmYYYY.[ss] Set the System time to a specific extended value. Note:In the file /etc/adjtime the correction factor can be saved to keep the clock as accurate as possible. Network Time Service This service is used to set the client clocks to a very precise clock. The service compensates for the delay introduced by TCP. 93 Topic 111: Administrative Tasks Protocol: NTP Methods: 1) Cron job queries the time server using the ntpdate program. 2) Local daemon (ntpd or xntpd) runs on client and polls the time server. Note: This solution transforms the client to a Time Server. ntpdate This program connects with a Time Server and sets the System time. Syntax: ntpdate TimeServerName Normally it is regularly called from a cron job. Eg: 10 * * * * root /usr/sbin/ntpdate ntp3.fau.de Note: A list of time servers on the Internet is located at: http://www.eecis.udel.edu/~mills/ntp/clock1a.html ntpd or xntpd These daemons poll one or more Time Server(s) every 5 minutes and sets the system time. Configuration file: /etc/ntp.conf Example contents: server ntp3.fau.de driftfile /etc/ntp.drift This driftfile will store the local Hardware Clock drift and will be used at boot time to set local System Clock to a more accurate time till a connection to a Time Server is achieved. Note1: If the local time has drifted off more than 1000 seconds then a syslog message is generated and the clock must be set manually. Note 2: It is also possible to use both methods: ntpd and ntpdate at the same time. 94 Topic 112: Networking Fundamentals Topic 112: Networking Fundamentals Total weight for this topic 14 1.112.1 Fundamentals of TCP/IP..............................................................................4 1.112.3 TCP/IP configuration and troubleshooting..................................................7 1.112.4 Configure Linux as a PPP client..................................................................3 Summary TODO 95 Topic 112: Networking Fundamentals 1.112.1 Fundamentals of TCP/IP Description: Candidates should demonstrate a proper understanding of network fundamentals. This objective includes the understanding of IP-addresses, network masks and what they mean (i.e. determine a network and broadcast address for a host based on its subnet mask in "dotted quad" or abbreviated notation or determine the network address, broadcast address and netmask when given an IP-address and number of bits). It also covers the understanding of the network classes and classless subnets (CIDR) and the reserved addresses for private network use. It includes the understanding of the function and application of a default route. It also includes the understanding of basic internet protocols (IP, ICMP, TCP, UDP) and the more common TCP and UDP ports (20, 21, 23, 25, 53, 80, 110, 119, 139, 143, 161). Weight: 4 Key files, terms, and utilities include: /etc/services ftp telnet host ping dig traceroute whois OSI and TCP/IP models OSI Model TCP/IP Stack Protocols Application Process FTP,Telnet, SSH, HTTP,... Presentation Session Host to Host TCP, UDP Transport Network Internetwork IP, ICMP, ARP, OSPF, EGP Ethernet, FDDI, AAL5, PPP, Data Link Network Interface PPPoE Physical Ethernet Frame Examples: Fig. 1 TCP/IP layer structure 96 Topic 112: Networking Fundamentals TCP header Fig. 2 TCP protocol header UDP header Fig. 3 UDP header IP Header Fig. 4 IP header TCP/IP Network Tools ping Sends an ICMP Packet (type 8) to verify the presence of a remote host. The remote host normally sends an ICMP packet (Type 0) back. traceroute Displays the Names/IP of routers encountered to a remote destination. whois 97 Topic 112: Networking Fundamentals Asks a whois server (RFC 812) for the owner and administrator of a DNS Domain. host, nslookup, nsquery, dig Ask a DNS (Name Server) to translate an FQDN to an IP or reverse. Example dig. ns Displays the list of all ROOT DNS Servers. (hint types servers) IP Addresses Classes Class Start Address End Address Netmask Normal Internet Addresses (Unicast=Single machine) A 1.0.0.0 127.255.255.255 255.0.0.0 B 128.0.0.0 191.255.255.255 255.255.0.0 C 192.0.0.0 223.255.255.255 255.255.255.0 Reserved Addresses (Internet Non-Route-able Addresses=Reserved for Intranet) per RFC 1597 A 10.0.0.0 10.255.255.255 255.0.0.0 B 172.16.0.0 172.31.255.255 255.255.0.0 C 192.168.0.0 192.168.255.255 255.255.255.0 Special Addresses (Reserved) D 224.0.0.0 239.255.255.255 (Multicasting-Groups) RIPv2 224.0.0.9 All RIPv2 Routers OSPF 224.0.0.5 All OSPF Routers OSPF 224.0.0.6 Some OSPF Routers E 240.0.0.0 255.255.255.255 (Internet Administration) ICMP Messages Error Messages 3 Destination unreachable 4 Source quench 5 Redirect 11 Time exceeded 12 Parameter Problem Information Messages 0 Echo reply 8 Echo request 13 Time stamp 98 Topic 112: Networking Fundamentals 14 Time stamp reply 15 Information request 16 Information reply 17 Address mask request 18 Address mask reply TCP/IP Services Also found in /etc/services Port Protocol Transport Protocol Description 20 FTP-Data TCP Data Channel of FTP Connection.. 21 FTP TCP Control Channel of FTP Connection. 22 SSH TCP or UDP Secure Shell 23 TELNET TCP Terminal Emulation over Network 25 SMTP TCP Simple Mail Transfer Protocol 53 DNS TCP or mostly UDP Domain Name Server 80 WWW/HTTP mostly TCP or UDP Hypertext Transfer Protocol 110 POP3 TCP or UDP Post Office Protocol 119 NNTP TCP Net News Transfer Protocol 139 NetBIOS-SSN TCP or mostly UDP Windows Network Session Service 143 IMAP2 TCP or UDP Interim Mail Access Protocol (Encrypted) 161 SNMP UDP Simple Network Management Protocol TODO: Extra subjects treated in LPI 102 but not described here: Netmask and Subnetting, including CIDR Routing fundamentals including default gateway 99 Topic 112: Networking Fundamentals 1.112.3 TCP/IP configuration and troubleshooting Description: Candidates should be able to view, change and verify configuration settings and operational status for various network interfaces. This objective includes manual and automatic configuration of interfaces and routing tables. This especially means to add, start, stop, restart, delete or reconfigure network interfaces. It also means to change, view or configure the routing table and to correct an improperly set default route manually. Candidates should be able to configure Linux as a DHCP client and a TCP/IP host and to debug problems associated with the network configuration. Weight: 7 Key files, terms, and utilities include: /etc/HOSTNAME or /etc/hostname /etc/hosts /etc/networks /etc/host.conf /etc/resolv.conf /etc/nsswitch.conf ifconfig route dhcpcd, dhcpclient, pump host hostname (domainname, dnsdomainname) netstat ping traceroute tcpdump and the network scripts run during system initialization. Networking configuration files /etc/HOSTNAME or /etc/hostname Contains the name (FQDN) of the present host /etc/hosts Contains a translation table of IPs and equivalent hostnames. A short and/or a long name(s) per IP. Was used to list all hosts on the Internet before DNS was developed. Can now be used to list all machines on local intranet, as well as hosts in Internet accessed frequently. /etc/networks Contains a translation table of Network Addresses and equivalent Network name(s) /etc/host.conf Contains the sequence that the local resolver should follow for translating a name to an IP (resolving). Examples: multi on Multiple names are allowed per host order host bind 100 Topic 112: Networking Fundamentals First try to resolve using /etc/hosts then use DNS queries /etc/nsswitch.conf Same purpose but more refined function as /etc/host.conf. /etc/resolv.conf List of search domains for resolving short names and list of (max 3) of IP of NameServers to resolve FQDNs. Example: search linux.local domain linux.local (deprecated) nameserver 194.25.2.129 nameserver 192.76.144.66 nameserver 145.253.2.171 Networking tools ping Sends an ICMP Packet (type 8) to verify the presence of a remote host. The remote host normally sends an ICMP packet (Type 0) back. traceroute Displays the Names/IP of routers encountered to a remote destination. whois Asks a whois server(RFC 812) for the owner and administrator of a Domain. host, nslookup, nsquery, dig Ask a DNS (Name Server) to translate an FQDN to an IP or reverse. eg. dig. ns Displays the list of all ROOT DNS Servers. (hint types servers) hostname Displays different parts or all of the local host FQDN. domainname Displays the local NIS domain name (different from DNS name) dnsdomainname Displays the local DNS Domain Name. ifconfig Tool to configure or turn OFF the network interface. eg. ifconfig eth0 192.168.100.60 up route Tool to display and set and erase entries in the routing table netstat Tool to display a variety of network information including 101 Topic 112: Networking Fundamentals Routing Table UNIX and TCP/IP Sockets Ports in listening mode Present TCP/UDP connections status tcpdump A network sniffer program to display the content of network packets. dhcpcd DHCP client program (The one used by SuSE) pump DHCP client program (The one used by RedHat) dhclient ISC DHCP client program. With extended functions compare to the above two DHCP clients. Boot time scripts These scripts are part of the runlevel system and are run at boot time to configure the network devices and get services ready for operation. They are normally located in: /etc/init.d/* These scripts often use configuration files located in /etc/ or subdirectories of /etc. Example: /etc/sysconfig/network/* Frontends for ifconfig and route (ifup and ifdown) are often used to configure the network interface – uisage is easier than on the command line. TODO: Extra subjects treated in LPI 102 but not described here Parameters and options of all the network tools ftp commands Paramters of /etc/nsswitch.conf Parameters of ifconfig Parameters of route Options of netstat and their results meanings. How ifup and ifdown get called and how they work DHCP server configuration DHCP Clients parameters Function and configuration of DHCP Parameters of /etc/host.conf Parameters of /etc/resolv.conf 102 Topic 112: Networking Fundamentals Options of tcpdump 103 Topic 112: Networking Fundamentals 1.112.4 Configure Linux as a PPP client Description: Candidates should understand the basics of the PPP protocol and be able to configure and use PPP for outbound connections. This objective includes the definition of the chat sequence to connect (given a login example) and the setup commands to be run automatically when a PPP connection is made. It also includes initialization and termination of a PPP connection, with a modem, ISDN or ADSL and setting PPP to automatically reconnect if disconnected. Weight: 3 Key files, terms, and utilities include: /etc/ppp/options.* /etc/ppp/peers/* /etc/wvdial.conf /etc/ppp/ip-up /etc/ppp/ip-down wvdial pppd Connection protocols Most TCP/IP connections use one of the following connection protocols: Ethernet with MAC address (ARP protocol) SLIP (Serial Line IP): Older and almost not any more used PPP (Point to Point Protocol) Mostly used. PPP Protocol This protocol allows a connection from on host to another via a Point-to-Point Protocol. It can also be used to connect to a host which is a gateway to the Internet. This is the way it is mostly used these days. PPP Protocol comes in different versions: PPP for Analog Modems syncPPP for ISDN PPPoE for SDL Sequence of PPP connection build-up 1 - Modem connection build-up 2 - PPP Connection via Login chat script 3 - PPP Connection set-up Modem connection build-up The modem connection build-up is usually done by controlling the analog/ISDN/DSL Modem in order to establish contact between the local and a remote modem. With analog modems this control is achieved via 'AT' (Hayes compatible) commands sent to the modem. After each command, if it is successful, the modem answers with an 'OK'. 104 Topic 112: Networking Fundamentals Example: ATZ Reset the modem to User Settings AT&F Reset the modem to Factory Settings ATD0017853 Dial the number 0017853 Once the Modems have synchronized, the local modem sends a message that contains the word CONNECT (eg. CONNECT 28800) to the dialer. Once the modems have connected and synchronized, they become transparent and simulate a simple serial cable connection between the 2 hosts. The modem connection is then established. PPP Connection via login chat script Once the modem connection is completed, the remote getty program (in the ppp server) will then send the message Login: and wait. At this point the pppd daemon needs to be started with its positional parameters which sets: The Login program and parameters The device connected to the modem The speed of connection Example: pppd "chat -f /etc/ppp/provider" /dev/ttyS1 38400 Using the Login script (/etc/ppp/provider) the local chat program wi