Você está na página 1de 33

CCTM220

Linux Administration
Level II

Welcome

 Please...
 Pick Up Materials at the Front...
 Workbook
 Notebook

Housekeeping Information

 Roll Call
 Course Times
 Refreshments -Time / Locations
 Drinks OK / No Food in Classroom

Workbook Page 1
Housekeeping Information

 Washroom Locations
 No Smoking Indoors
 Temperature Control
 Fire Exit Locations
 Please Recycle

Introductions
 Name / Company Name / Duties
 Computer / Networking Experience
 Linux Experience
 System Administrator Experience
 Expectations
 Reasons for Taking Class

Course Outline
 Install Software
 Source *
 RPM's
 yum / yast
 Kernel Updates and Customization
 Update the Kernel
 Customize and Compile Kernel

Workbook Page 2
Outline
 Library Management
 Software Install Practice
 Setup servers as time permits
 Mail, Web, FTP, Samba, etc.

Introduction and Course Overview

Introduction and Course Overview

 Technical Role
 System Administrator
 Technical Support
 Power User Role
 Command-line Oriented

Workbook Page 3
Introduction and Course Overview

 This Course is Part of the Linux (UNIX)


Administrator Certificate:
 CCTM110 Linux User Level I
 CCTM210 Scripting for Administration
 CCTM120 Linux Administrator Level I

 CCTM220 Linux Administrator Level II

 CCTM131 Linux Networking

10

Software Installation

11

Software Installation

 Linux Architecture
 Sarwar, Koretsky & Sarwar p22
 Static and Dynamic linking

12

Workbook Page 4
Applications

Software Installation Shells

Shell(s)
Libraries

API

In te rp ro ce ss
Co m mu n ica tio n
F ile ( IP C)
Mama ge me nt

Kernel P ro ce ss M a n a g e m e n t

P rim a ry a n d S e co n d a ry
S to ra g e M a n a g e m e n t

CP U
S ch e d u le r

Device Drivers

L in u x S o ftwa re A rch ite ctu re


L in u x T h e T e xtb o o k
A d d iso n- W e sle y Hardware
IS B N 0 -2 0 1-7 2 5 9 5- 9
S a rwa r, K o re tsky, S a rwa r

13

Software Installation

 Software Sources
 Free Software Foundation
 Your Distro's Site
 Project Sites: Source Forge, Freshmeat, etc
 Commercial Sources
 etc, etc
 Security Issues
 File integrity
 Signatures / Message digests 14

Software Installation

 Methods...
 Install Binary files (executables)
 RPM Binaries, yum, yast
 Debian package management
 dpkg / apt-get tool

 Manual copying of files

15

Workbook Page 5
Software Installation

 Methods...
 Install from Source Code
 Tarballs
 RPM Source Packages
 Debian package management Packages

16

Software Installation

 Techniques
 RPM (Redhat Package Management)

 Query packages
 Install / Update / Freshen package
 Erase packages

17

Software Installation

 Techniques
 yum / yast / others
 Front-end for RPM
 Databases (repositories) of files
 Meta-data stores

 track installed vs latest versions

 Check dependencies

18

Workbook Page 6
Software Installation

 Techniques
 Compile Source Code

19

Software Installation

 Development Environment for Programmers


 Same as for us Users
 Compilers, libraries, etc

 Comprehensive Development-Management
Packages
 http://www.eclipse.org/

20

Software Installation

 Techniques
 Finding Installed Software

 whereis, which
 chkconfig
 find, locate
 rpm, yum, yast

21

Workbook Page 7
Installation from Source

 Source Install Summary


 First Time (General)...
 Create Download directory structure
 Install development tools, compiler, etc
 Install Message Digest and Signature Check s/w
 First Time (Per Package)...
 create folder under download directory
 create config script in new folder

22

Installation from Source

 Source Install Summary


 Every Time (Per Package)...
 Download source tarball (or sources RPM)
 Unpack tarball
 Read documentation
 [edit configuration file(s)]
 create start-up script
 run config script (includes ./configure)

23

Installation from Source

 Source Install Summary


 Every Time (Per Package)...
 make
 [make clean], make, make install, ...
 run program
 test
 check for errors
 /var/log/messages, etc

 [periodic updates]

24

Workbook Page 8
Installation from Source

 Installation from Source Overview


 Compile/assemble source files to binary object files
 Link object files to binary executable files
 Install binary files

25

Installation from Source

 Source Formats
 Source RPMs
 Tarballs*
 Developer's Source Directory Tree
 encapsulated with tar
 compressed with gzip

26

Installation from Source

 Make 'Home' Folder for each Package and


Download latest tarball there
 /home/<user>/sourceTree/<package1>/
 <package1>.tar.m.n.gz file (older version)
 <package1>.tar.m+.n+.gz file, ... (newer ...)
 /home/<user>/sourceTree/<package2>/
 <package2>.tar.m.n.gz file (older version)

 <package2>.tar.m+.n+.gz file, ...

(newer ...)
27

Workbook Page 9
Installation from Source

 Check File Integrity


 md5sum
 sha1
 etc

28

Installation from Source

 tar command
 tar -t list archive
 tar -c create archive
 tar -x extract from archive
 tar -d show differences
 etc
 compression
 z = gzip; j = bzip2
29

Installation from Source

 Extract the Source Code


 cd /home/<user>/downloads/<packageX>/
 tar -zxvf appX.tar.gz or
 tar -jxvf appX.tar.bz2 creates a source tree
 in /home/<user>/downloads/<packageX>/:
 ./<package1>-m.n/ (older version)
 ./<package1>-m+.n+/ (newer version)

30

Workbook Page 10
Installation from Source

 Create Configuration Script


 cd /home/<user>/downloads/<packageX>/
 vi <packageX>-config
 #!/bin/bash
 ./configure \
 # Options List goes here. See next slide.

 exit 0

 chmod 0744 <packageX>-config

31

Installation from Source

 Modify Options List in Configuration Script


 Move desired options above the exit 0 line
 vi <packageX>-config
 #!/bin/bash
 ./configure \
 # Options List (for example)
 --WITH-mysql
 --WITH-apxs2=/usr/local/apache2/bin/apx2
 exit 0
 other undesired options below exit 0 32

Installation from Source

 Run the Configuration Script


 cd /home/<user>/downloads/<packageX>/ \
/<packageX>.tar.m+.n+/
 ../<packageX>-config (runs the script.)

 This methodology uses the same install options for all


versions of the package

33

Workbook Page 11
Installation from Source

 Tools and Processes


 C Language Compiler - gcc
 the configure script
 created by author using autoconfig utility
 Checks for compiler, libraries, utilities, etc
 Creates custom Makefile
 http://www.gnu.org/software/autoconf/
 http://www.gnu.org/software/automake/
 http://www.gnu.org/software/libtool/

34

Installation from Source

 Tools and Processes


 Read README and INSTALL files
 cd /home/<user>/downloads/<packageX>/ \

/<packageX>.tar.m+.n+/
 less README

 less INSTALL

 Read other help files, on-line documentation,


HowTo's, etc

35

Installation from Source

 Tools and Processes


 make utility
 Manages compile process
 source {compile>} object {link>} executable
 targets (executable modules) and their dependencies
 source modules > object modules are targets

 object modules > executables are targets

 Installs executables to proper directories

36

Workbook Page 12
Libraries

37

Software Installation

 Libraries
 Statically Linked Libraries
 create stand-alone programs don't rely on user
having particular libraries installed, but...
 increase program size
 consume memory if several programs are concurrently
using their own copy of a library
 each program using a statically linked library requires
manual, individual recompile; a functionality and security
concern.

38

Software Installation

 Libraries
 Dynamically Linked (Shared) Libraries
 Many programs can share one block of code
 Saves storage
 Improves efficiency and effectiveness of updates

39

Workbook Page 13
Software Installation

 Libraries
 Dynamically Linked (Shared) Libraries
 ldd shows libraries required by an application
 Running a program invokes ld.so (old a.out) or ld-
linux.so* (new ELF) which finds and loads the
shared libraries needed by the program, prepares
the program to run, and then runs it.

40

Software Installation

 Libraries
 Dynamically Linked (Shared) Libraries
 These runtime shared object (.so) dynamic linkers
try to satisfy dependencies from information in:
 binary index cache /etc/ld.so.cache and
 environmental variable LD_LIBRARY_PATH which is a
colon delimited list of directories

41

Software Installation

 Libraries
 Working with Dynamic Libraries
 ldconfig updates binary index cache
/etc/ld.so.cache from:
 files in /lib/ and /usr/lib/

 directories pointed at from lines in file /etc/ld.so.conf

 directories pointed at from lines in files in directory

/etc/ld.so.conf.d
 files in directories in ldconfig's command line [transient]

 ldconfig [-p] [-v] [lib-dirs] shows cache


 where -p prints (displays) current contents of cache
42

Workbook Page 14
Software Installation

 Glossary
 Compile / Compiler
 Assemble / Assembler
 Object Code
 Libraries
 Link / Linker
 Static Links / Dynamic Links
 Binaries (Executables)
43

Kernel Updates

44

Kernel Updates

 Updating Current Kernel (from RPM's)


 No kernel customization
 Checking current package versions
 rpm -q <package-name>
 Packages: kernel, kernel-headers, kernel-ibcs, kernel-
pcmcia-cs, kernel-source
 Other packages: mkinitrd, SysVinit, initscripts
 Download latest versions

http://download.fedora.redhat.com/pub/fedora/linux/core/5/i386/,

ftp://mirrors.usc.edu/pub/linux/distributions/

other; see www.kernel.org
45

Workbook Page 15
Kernel Updates

 Updating the Current Kernel


 Checking current boot version
 # cat /etc/grub.conf, or
 # cat /etc/lilo.conf
 Checking current running version
 # uname -a

46

Kernel Updates

 Updating the Current Kernel


 Make emergency boot diskette

mkbootdisk [--device /dev/fd0] <verNum>

(eg) # mkbootdisk 2.4.20-31.9

47

Kernel Updates

 Updating the Current Kernel


 With downloaded RPM's in, say,
 /tmp/new-kernel-packages, then
 # rpm -ivh /tmp/new-kernel-packages/*.rpm

48

Workbook Page 16
Kernel Updates

 Updating the Current Kernel


 Create initial ramdisk
 mkinitrd /boot/initrd-m.n.p-xxx.img m.n.p-xxx
 Update /etc/lilo.conf or,
 /sbin/lilo
 Update /etc/grub.conf

49

Kernel Updates

 Updating Current Kernel (with yum)


 yum update 'kernel*' (!! single quotes) or
 yum update

50

Kernel Customization

51

Workbook Page 17
Kernel Customization

 Version Numbering


2.4.21-13mdk


| | | |_ The distro-specific version. Only found on distro kernels.




| | |_ The build number. These grow with fixes/patches to minor changes.


| |_ Minor number. This indicates even/odd for stable/development.


|_ Major number. These grow with major changes to the kernel.

 Odd versions are development versions


 Even versions are stable, production
versions

52

Kernel Customization

 Rationale

Light-weight Kernel...
 just the right built-in drivers and configuration

 security exclude risky hardware, for instance

 performance tuning

 special distros, special requirements

53

Kernel Customization

 Download Kernel source and headers


 RPM's or Tarballs*
 yum install 'kernel-devel'
 Extract tarball in /usr/src/
 creates .../linux-m.n.p-xxx folder
 Replace symbolic link to new folder
 cd /usr/src
 rm -f linux-2.4
 ln -s linux-2.4.29 linux-2.4 54

Workbook Page 18
Kernel Customization

 Clean up development environment


 cd /usr/src/linux
 make mrproper
 Examine /usr/src/linux:
 .config
 Makefile
 subdirectories

55

Kernel Customization

 .config file
 back up original
 [make oldconfig] makes a default file
 Make custom .config file with one of:
 make config
 make menuconfig
 make xconfig
 Or, copy a canned file from /usr/src/<kernel-m.n>/configs/ \
/usr/src/<kernel-m.n>/.config ; make oldconfig
56

Kernel Customization

 .config options:
 M install as module
 Y compile into kernel
 N don't compile-in; no module support

57

Workbook Page 19
Kernel Customization

 Compile and Install Kernel


 make dep
 make clean
 make bzImage
 make install ??????
 make modules
 make modules_install
 make install ??????

58

Kernel Customization

 Kernel boot steps


 copy compressed image to /boot
 cp /usr/src/m.n.p-xxx/arch/i386/boot/bzImage \
/boot/vmlinuz-m.n.p-xxx
 copy System.map to /boot; create symLink
 cp /usr/src/m.n.p-xxx/System.map \
/boot/System.map-m.n.p-xxx
 ln -sf /boot/System.map-m.n.p-xxx \
/boot/System.map

59

Kernel Customization

 Kernel boot steps


 Create initial ramDisk
 mkinitrd /boot/initrd-m.n.p-xxx.img \
m.n.p-xxx
 Update /etc/lilo.conf
 run /sbin/lilo
 or, Update /etc/grub.conf

60

Workbook Page 20
Manage Kernel Modules

61

Manage Kernel Modules

 Monolithic Kernels
 all support is built-in
 negative: too many / too few modules
 negative: driver updates require recompile
 Modular Kernels
 module support is dynamically installed as
needed
 Linux supports both methods
62

Manage Kernel Modules

 Linux modules are compiled object code


 <filename.o>
 Modules are not linked to the kernel
executable until loaded
 at boot-up time or
 by the insmod or modprobe utilities

63

Workbook Page 21
Manage Kernel Modules

 Linux modules are located in:


 Module categories called tags at:

/lib/modules/<kernel-version>/kernel/drivers/<tag>

where <kernel-version> = `uname -r`

tags: block, cdrom, ipv4,misc, net, scsi, video, etc.
 multiple <kernel-version> folders may exist

64

Interface Configuration

 Module Management
 edit /etc/modules.conf to use <tag option>. Add:
path= /lib/modules/<kernel-version>/kernel/drivers/
 lsmod list installed modules
 rmmod remove installed modules (-sa)
 modinfo module information (-alpdv)
 insmod install module (-sv)

65

Manage Kernel Modules

 Module utilities
 lsmod list loaded modules
 insmod insert module into kernel
 insmod -s -v mod_name
 -s=log to syslog; -v=verbose
 Watch for unsatisfied dependencies
 rmmod remove module from kernel
 rmmod -s -a mod_name
 -s=log to syslog; -a=all unused modules

66

Workbook Page 22
Manage Kernel Modules

 Module utilities
 modinfo display module's information
 modinfo -a -d -p mod_object_file
 -a=author; -d=description; -p=typed parameters
 -l=licence; -v=version; etc

67

Manage Kernel Modules

 Module utilities
 modprobe load modules, dependencies, etc
 modprobe [options] module [symbol=value ...]
 modprobe=insmod + more (a wrapper)
 options
 -v = verbose
 -a = all probes all modules
 -a -t <tag> probes all modules in <tag>
 -s = log to syslog

68

Manage Kernel Modules

 Module utilities
 modprobe load modules, dependencies, etc
 options
 -l [-t <tag>]= list modules [in <tag>]
 -r = remove module ...
 -c = display complete module configuration [including

/etc/modules.conf (/etc/conf.modules)]

69

Workbook Page 23
Network Servers

70

Network Servers

 Time Permitting...
 WebMin
 Cups
 Web Server
 FTP Server
 Samba Server

71

Web Server

72

Workbook Page 24
Web Server

 Apache 2.0
 Download from www.apache.org
 to: ~clientxx/downloads
 check md5sum, sha1sum, pgp signature
 Extract Source
 tar -zxvf httpd-m.n.tar.gz
 cd to httpd-m.n

73

Web Server

 Apache 2.0
 Read supplied documentation
 README (not much)
 INSTALL (useful Quick Install)
 Read full Install Instructions
 httpd.apache.org/docs-2.0/install.html
 Follow 'overview for the impatient' instructions

74

Web Server

 Apache 2.0
 Observe Directives
 ./configure help | more
 Start Apache
 /usr/local/apache2/bin/apachectl start
 Test Apache
 ps -ef | grep httpd
 lynx localhost
 browse from alien machine: http://<hostIP>
75

Workbook Page 25
Web Server

 Apache 2.0
 Starting Apache at bootup
 in /etc/rc.d/rc.local
 /usr/local/apache2/bin/apachectl -k start

76

Web Server

 Apache 2.0
 Starting Apache at bootup (2)
 in /etc/rc.d/init.d
 script file: httpd (see notes)
 in .../rc[35].d
 symbolic link: Sxxhttpd > /etc/rc.d/init.d/httpd

77

Web Server

 Apache 2.0
 Install sample site

78

Workbook Page 26
FTP Server

79

FTP Server

 wu-ftpd www.wu-ftpd.org
 note documentation links
 FAQ
 Example Configuration Files
 HowTo's
 Resource Centrehttp://www.landfield.com/wu-
ftpd/

80

FTP Server

 wu-ftpd
 download current version tarball to:
 /opt/wu-ftpd
 login to user account (non-root)
 tar -zxvf wu-ftpd-<version>
 cd to wu-ftpd-<version>
 Read README and INSTALL** (alternate
method)

81

Workbook Page 27
FTP Server

 Compile wu-ftpd
 ./configure
 make
 make install (as super user)
 Setup xinetd (Super Daemon)
 /etc/hosts.allow
 in.ftpd: 192.168.1.

82

FTP Server

 FTP Site Directories


 /home/ftp
 /home/ftp/bin
 copy /bin/ls
 /home/ftp/etc
 copy /etc/passwd and /etc/group
 /home/ftp/public
 /home/ftp/incoming

83

FTP Server

 FTP Site Directories



/home/ftp (555)

/home/ftp/bin (111)

/home/ftp/etc (111)
 edit passwd and group files (444)


/home/ftp/public

/home/ftp/incoming (1777)
 chown -R root:wheel /home/ftp
84

Workbook Page 28
FTP Server

 The FTP User



vipw ftp:*:200:50:anonymous ftp user:/home/ftp:/bin/false
 Login Shell must exist in /etc/shells

85

FTP Server

 The ftpaccess file


 cat /etc/ftpaccess
 class domain real,anonymous 192.168.1
 The ftp client
 ftp a.b.c.d
 login as anonymous/email-password

86

FTP Server

 The ftpaccess file


 cat /etc/ftpaccess
 class domain real,anonymous 192.168.1
 The ftp client
 ftp a.b.c.d
 login as anonymous/email-password
 Set Messages (/etc/messages/deny.msg)

87

Workbook Page 29
FTP Server

 More ftpaccess file


 cat /etc/ftpaccess
 deny 192.168.1.22 /etc/messages/deny.msg
 limit domain 2 MoTuWeThFr0000-1700 \
/etc/messages/toomany.msg
 banner /etc/messages/security.policy
 email ftp-admin@domain.tld

88

FTP Server

 Other Files
 /etc/ftphosts
 allow user-name address
 /etc/ftpusers (deny access to...)
 root. admin, etc

89

FTP Server

 Other Files
 /var/log/xferlog

90

Workbook Page 30
FTP Server

 Other Programs
 ftpshut -l 10 -d5 2300 message
 rm /etc/shutmsg to restart
 OR ftprestart
 ftpwho

91

Mail Server

92

Mail Server

 Sendmail
 Postfix
 qMail

93

Workbook Page 31
Samba File System

94

Samba File Systems

 Samba

95

Thank You

96

Workbook Page 32
Legal Stuff
 This Presentation file is Copyright 1999 - 2012 by Jim
Stevenson. All rights are reserved.
 This presentation is provided for the private use of students
who have taken this course as an aid in the study and review of
the material covered. The student is permitted to view the slides
and/or print the slides for their private use only. No other use of
the material is permitted, including, but not limited to:
duplicating slides, notes, or the entire file; using the materials in
training sessions or other group events; lending of the materials
to other persons or groups; incorporating these materials into
other slide shows or printed works.
 Permission to use these materials in ways other than described
above may be granted (perhaps for a fee). Contact Jim
Stevenson at (780)487-7743; jim.stevenson@shaw.ca
97

Workbook Page 33

Você também pode gostar