Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.

Slides:



Advertisements
Similar presentations
Chapter 9: Understanding System Initialization The Complete Guide To Linux System Administration.
Advertisements

Chapter One The Essence of UNIX.
A Guide to Unix Using Linux Fourth Edition
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 12 Printing in Linux.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Chapter 6: Hostile Code Guide to Computer Network Security.
Systems Software Operating Systems.
Slide 1 of 9 Presenting 24x7 Scheduler The art of computer automation Press PageDown key or click to advance.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – Shell Programming The activities of.
Ch 111 Chapter 11 Advanced Batch Files. Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Topics Introduction Hardware and Software How Computers Store Data
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
Introduction to Shell Script Programming
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Managing User Accounts. Module 2 – Creating and Managing Users ♦ Overview ► One should log into a Linux system with a valid user name and password granted.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that contains an ordered series of commands.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
GNU Compiler Collection (GCC) and GNU C compiler (gcc) tools used to compile programs in Linux.
Linux+ Guide to Linux Certification, Third Edition
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Agenda Getting Started: Using Unix Unix Structure / Features Elements of the Unix Philosophy Unix Command Structure Command Line Editing Online Unix Command.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
JavaScript, Fourth Edition
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Sys Admin Course Job Scheduling Fourie Joubert. Sys Admin Course Very often, you may want a job to run once at a certain time, or to run regularly at.
Linux+ Guide to Linux Certification, Second Edition
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 COP 4343 Unix System Administration Unit 8: – at – cron.
Linux Administration Working with the BASH Shell.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Development Environment
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction to Repetition Structures
Agenda Control Flow Statements Purpose test statement
Exploring Microsoft Excel
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Presentation transcript:

Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques

Guide to Linux Installation and Administration, 2e2 Objectives In this chapter, you will: Create shell scripts using basic shell programming features Automate one-time and repetitive tasks using at and crontab Reconfigure the Linux kernel

Guide to Linux Installation and Administration, 2e3 Writing Shell Scripts You can automate the process of entering frequently used commands by creating a shell script A shell script is an executable file containing lines of text as you would enter them at a command line, including special commands to control the order in which lines in the file are executed Valued Gateway Client:

Guide to Linux Installation and Administration, 2e4 Interpreting and Compiling Programs A compiler converts the source code of a compiled language into a binary file An interpreter converts the source code of an interpreted language into numeric codes A shell script is an interpreted program Valued Gateway Client:

Guide to Linux Installation and Administration, 2e5 Understanding Programming Concepts A selection statement lets a computer programmer determine which parts of a program will be executed according to values that are determined as the program is executed A loop statement is used to determine whether part of a computer program should be executed more than once The list of statements controlled by a selection or loop statement is often called a block, or a statement block Valued Gateway Client:

Guide to Linux Installation and Administration, 2e6 A Selection Statement

Guide to Linux Installation and Administration, 2e7 A Loop Repeats a Block of Statements

Guide to Linux Installation and Administration, 2e8 Components of a Shell Script Each script file must start with a line identifying the interpreter to use for that script Each script must have the execute permission set Each script must use only correctly formed statements for the interpreter Valued Gateway Client:

Guide to Linux Installation and Administration, 2e9 Creating a Simple Shell Script Some Linux commands are used mostly within shell scripts The read command causes the shell to pause for a user to enter information at the keyboard You can create your own variables to store values within a script Shell scripts use the Linux redirection operators to change the flow of information to and from commands Valued Gateway Client:

Guide to Linux Installation and Administration, 2e10 Using Variables in Scripts A variable used in a shell script in this way is sometimes called a shell variable To initialize the variable, assign it a value A positional variable takes a value based on the information that the user includes on the command line You indicate positional variables using a dollar sign and a number Positional variables are a useful way to provide information to the commands in a script Valued Gateway Client:

Guide to Linux Installation and Administration, 2e11 Using if/then/else Tests A test is a type of selection statement that lets you determine if a condition is true or false An if command must be followed by a then command, which lists the commands to be executed if the test succeeds The fi command marks the end of the if statement The test command evaluates parameters you provide and returns either true or false The else command adds a block of commands that are only executed if a test returns a value of false Valued Gateway Client:

Guide to Linux Installation and Administration, 2e12 Structure of an if/then Statement

Guide to Linux Installation and Administration, 2e13 File-Testing Operators in the bash Shell

Guide to Linux Installation and Administration, 2e14 Structure of an if/then/else Statement

Guide to Linux Installation and Administration, 2e15 Adding Loops to a Script A loop statement causes a block of commands to be repeated a certain number of times or until a condition is met The for command creates a for loop, which repeats a statement block once for each list item The do and done commands are keywords used to begin and end a statement block in a for loop Loops using for and while repeatedly execute a statement block based on either a fixed number of iterations or a condition being tested Valued Gateway Client:

Guide to Linux Installation and Administration, 2e16 Other Scripting Methods The statements in a shell script must follow specific syntax rules The specific syntax rules a script must follow depend on the interpreter that will execute the script Different scripting languages are used for different purposes Scripts often use standardized file extensions to help users identify them Valued Gateway Client:

Guide to Linux Installation and Administration, 2e17 Popular Scripting Languages

Guide to Linux Installation and Administration, 2e18 perl Scripts Perl –A programming language developed by Larry Wall –Especially well suited to processing text strings –Was very popular as a tool for managing data submitted by Web page forms –perl scripts interact with Web servers using a communication standard called the Common Gateway Interface, or CGI Valued Gateway Client:

Guide to Linux Installation and Administration, 2e19 Scripts for Graphical Programs Tcl/Tk (tool control language/toolkit) is a scripting language developed by John Ousterhout Scripts written in Tcl/Tk are executed by an interpreter called wish The Python scripting language uses the same Tk graphical programming toolkit as Tcl Valued Gateway Client:

Guide to Linux Installation and Administration, 2e20 A program Written as a Python Script

Guide to Linux Installation and Administration, 2e21 Automating Tasks with at and crontab The at command lets you define one or more commands to be executed at some future time The crontab command lets you define one or more commands that will be executed repeatedly at intervals that you designate The at command relies on a daemon called atd The crontab command relies on a daemon called crond A scheduled task is often called a job Valued Gateway Client:

Guide to Linux Installation and Administration, 2e22 Automating One-Time Tasks You can perform a task automatically at some future time You can use the at command to schedule the task for future execution Valued Gateway Client:

Guide to Linux Installation and Administration, 2e23 Using the at Command To automate a task with the at command, you can either enter commands directly at the command line, or you can list them in a file The atd daemon will check once per minute for any jobs that have been scheduled using the at command The time specification in the at command is very flexible Valued Gateway Client:

Guide to Linux Installation and Administration, 2e24 Example Time Specifications Using the at Command

Guide to Linux Installation and Administration, 2e25 Using at Interactively The only disadvantage of entering commands interactively is that you cannot alter a command after it has been edited After entering all the commands that you want the atd daemon to execute, you indicate that you have finished by pressing Ctrl+D You can use the tty command to send output from a command to the location where you are currently logged in Valued Gateway Client:

Guide to Linux Installation and Administration, 2e26 Using the batch Command The batch command runs your commands when the system load average drops below 0.8 The batch command is similar to the at command and also relies on the atd daemon The batch command accepts tasks for future execution without a fixed time Commands are executed when the system is not busy Valued Gateway Client:

Guide to Linux Installation and Administration, 2e27 Automating Recurring Tasks You can use the crontab command to execute commands automatically at regular intervals Many administrators place scripts in the cron- related directories instead of creating their own cron job definitions In Red Hat Linux 7.3, the /etc directory contains subdirectories named cron.hourly, cron.daily, cron.weekly, and cron.monthly Valued Gateway Client:

Guide to Linux Installation and Administration, 2e28 Managing Automated Tasks Submitted commands for future execution using at or crontab can be viewed and deleted The root user can view or modify jobs submitted by any user on the system Valued Gateway Client:

Guide to Linux Installation and Administration, 2e29 Checking the Status of Jobs The two daemons atd and crond are started when you boot Linux using standard service scripts in /etc/rc.d/init.d You can use those scripts to stop and restart the daemons Jobs submitted using at are stored in the /var/spool/at directory; jobs submitted using crontab are stored in the /var/spool/cron directory The atq and atrm commands are used to manage at jobs that are awaiting execution You should not directly edit a crontab file in the /var/spool/cron directory Valued Gateway Client:

Guide to Linux Installation and Administration, 2e30 Controlling Access to at and crontab You can restrict access to at and crontab so that only certain users can use these commands /etc/cron.allow: Contains usernames that are allowed to use the crontab command /etc/cron.deny: Contains usernames that are not allowed to use the crontab command /etc/at.allow: Contains usernames that are allowed to use the at command /etc/at.deny: Contains usernames that are not allowed to use the at command Valued Gateway Client:

Guide to Linux Installation and Administration, 2e31 Modifying the Linux Kernel You can modify the Linux kernel to activate or deactivate features, including making features built-in instead of loadable modules You can recompile the Linux kernel from source code, creating a new kernel The file vmlinuz contains the Linux kernel Valued Gateway Client:

Guide to Linux Installation and Administration, 2e32 Installing Kernel Source Code To create a new kernel, make certain the kernel source code and supporting packages are installed on your system The kernel source code is available as an rpm package or as raw source code from Valued Gateway Client:

Guide to Linux Installation and Administration, 2e33 Configuring Kernel Features Three kernel configuration utilities are supported: –config, –menuconfig –xconfig Kernel configuration utilities are started using the make command The make command is a programming utility that uses instructions in a configuration file (called Makefile) to execute a series of instructions Valued Gateway Client:

Guide to Linux Installation and Administration, 2e34 The config Utility for Setting kernel Options

Guide to Linux Installation and Administration, 2e35 The menuconfig Utility for Setting kernel Options

Guide to Linux Installation and Administration, 2e36 The xconfig Utility for Setting kernel Options

Guide to Linux Installation and Administration, 2e37 Compiling a New Kernel After configuration is completed the make command is used to start the actual kernel compilation process You also compile and install new modules for the new kernel as a separate operation The make bzImage command creates a compressed kernel image called bzImage in the directory /usr/src/linux-2.4/arch/i386/boot To use that kernel, you should make a backup copy of your current kernel in /boot, then copy the bzImage file to /boot Valued Gateway Client:

Guide to Linux Installation and Administration, 2e38 Summary Shell scripts are used to execute a complex set of commands by entering a single script name Each script file starts with a line identifying the interpreter, has the execute permission set, and uses only correctly formed statements for the interpreter The if/then/else statement tests a condition and executes statements if the condition is present Loops using for and while repeatedly execute a statement block based on either a fixed number of iterations or a condition tested Many scripting languages are used on Linux systems, including perl, PHP, Python,and Tcl/Tk

Guide to Linux Installation and Administration, 2e39 Summary The at command schedules a task for execution by atd at some future point Tasks scheduled using at can be managed using the atq and atrm commands The crontab command schedules tasks that are to be executed on a regular basis, such as daily or weekly The kernel source code is available as an rpm package or as raw source code Three kernel configuration utilities: config, menuconfig, and xconfig are started using the make command