Top Banner
Linux Operations and Administration Chapter Twenty Advanced Linux Administration
50
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Chapter TwentyAdvanced Linux Administration

Page 2: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Objectives

• Manage kernel modules and load and configure the kernel

• Explain how to monitor system resources and use system-monitoring tools

• Use commands to fine-tune a file system

• Describe emergency recovery procedures

• Summarize common troubleshooting measures in Linux

2

Page 3: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Working with the Linux Kernel

• Linux kernel– Innermost layer of Linux OS– Also called the core– Acts as an interface to hardware attached to the

computer– Manages communication between processes

• Each Linux distribution includes a precompiled kernel

3

Page 4: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Basics of the Linux Kernel

• Linux kernel can function in one or more modes– User mode and kernel mode

• Source code for the Linux kernel is stored in a group of directories called kernel source tree

• Linux kernel is generally one of two types: – Monolithic– Modular

• Table 20-1 describes some of commands for managing kernel modules

4

Page 5: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration 5

Figure 20-1 Numbering of Linux kernel versions© Cengage Learning 2013

Page 6: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Basics of the Linux Kernel (cont’d.)

6

Table 20-1 Commands for managing kernel modules

Page 7: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Kernel Configuration

• In openSUSE, you must install the Linux Kernel Development pattern to have access to important packages

• You must be in /usr/src/linux directory

• Configuration build file for kernel is .config file

• Configuration tools to edit .config file– make oldconfig– make menuconfig– make config

7

Page 8: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Compiling the Kernel

• Involves translating its contents into a binary format

• Compiling process automated by using make utility• zcat command is used to view the gzipped kernel

configuration– Running in real time in /proc/config.gz virtual

file

• Activity 20-1: Configuring and Building the Linux Kernel– Configure and build the Linux kernel

8

Page 9: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

System Monitoring

• Monitoring a server or a workstation for CPU and memory use is an important task– Helps identify possible performance problems

• OpenSUSE has several commands for monitoring system performance, such as free and top

• Monitoring system performance helps determine possible system errors or performance bottlenecks

• These errors can be diagnosed using system log files

9

Page 10: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Monitoring System Resources

• System monitoring– Process of observing portions of a system for

problems or anomalies– Includes monitoring:

• CPU utilization

• Network bandwidth

• Storage space use

• Memory use

10

Page 11: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Monitoring CPU Utilization

• Context switching– Specifies when CPU stops the currently running

process and starts a new process

• Interrupts– An interrupt occurs when the CPU suspends its

current execution, saves the current work status, and transfers control to an interrupt handler

• Load percentage– Specifies the percentage of time a user-level or a

system-level process spends on a CPU

11

Page 12: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Monitoring Network Bandwidth

• Number of bytes received or sent– Specifies the number of bytes that can be sent or

received over a network connection

• Data transfer speed– Specifies the maximum number of I/O operations

that a network connection can perform per second

12

Page 13: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Monitoring Storage Space

• Free space

• Data transfer speed

• File system–based information

• Seek time

• Latency

13

Page 14: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Monitoring Memory Use

• Memory pages– Gives detailed information about:

• Memory-resident pages, which can be active or inactive

• How the system uses memory pages

• Swapping statistic– Specifies a system’s swapping behavior– Swapping

• Technique of moving data pages from memory to a swap space on a hard drive

14

Page 15: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using Basic System-Monitoring Commands

• top command– Gives you an active view of a running system and

can display system summary information

• vmstat command– Displays virtual memory statistics and information

about processes, CPU activity, and disk space use– Syntax: vmstat -n delay cnt

15

Page 16: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using Basic System-Monitoring Commands (cont’d.)

• free command– Shows in column format the total amount of free,

physical, and swap memory in the system as well as buffers used by the kernel

• df command– Displays the amount of available disk space on the

file system

• Activity 20-2: Using System-Monitoring Commands– Work with Linux system-monitoring commands

16

Page 17: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Administering System Logs

• logrotate utility– Included in OpenSUSE– Can be used by administrators to manage large

numbers of log files– Offers automatic rotation, compression, removal,

and mailing of log files– Configuration file is called logrotate.conf

• Located in /etc directory

17

Page 18: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using GUI System-Monitoring Tools

• Linux offers sophisticated system-monitoring tools, such as the sysstat package

• Graphical tools in GNOME and KDE desktop environments are also included for monitoring system resources and processes

18

Page 19: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

The GNOME System-Monitoring Tool

• GNOME System Monitor– Displays information on CPU, memory, and swap

utilization in tabular form– Started using gnome-system-monitor command– Contains five tabs:

• System

• Processes

• Resources

• File Systems

• Hardware

19

Page 20: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration 20

Figure 20-4 The GNOME System Monitor interface© Cengage Learning 2013

Page 21: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

The KDE System-Monitoring Tool

• KDE System Monitor– Used to monitor processes– Started using ksysguard command– Contains two tabs:

• Process Table

• System Load

21

Page 22: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration 22

Figure 20-5 The KDE System Monitor interface© Cengage Learning 2013

Page 23: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the sysstat Package for Resource Monitoring

• sysstat package– Used to display detailed information on system

performance– Consists of iostat and mpstat commands

• iostat command– Used to report CPU utilization and I/O statistics for

devices, partitions, and network file systems

23

Page 24: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the sysstat Package for Resource Monitoring (cont’d.)

• mpstat command– Used to display information for each processor,

starting with processor0

• Activity 20-3: Using Tools to Monitor System Performance– Display detailed information on system performance

with the sysstat package and GUI system-monitoring tools

24

Page 25: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Performance Tuning

• After you determine resource use with system-monitoring tools, you should fine-tune system resources to improve performance

• Two frequently used resources that require tuning are the hard drive and file system

25

Page 26: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Performance Tuning a Disk

• Disk I/O performance– Has a large effect on a system’s benchmark

performance– Can be improved by fine-tuning the hard drive

• For example:– You can tune the hard drive to increase disk transfer

speed– This improves system performance

26

Page 27: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the hdparm Command

• Can be used to tune an IDE hard drive

• You must be logged in as root to use this command

• Syntax: hdparm option device– option specifies flags that can be used to improve

drive performance– device specifies the hard drive to be tuned

27

Page 28: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Fine-Tuning a File System

• File system has a major effect on system performance

• If file system size is very large, response time for performing I/O operations increases– Results in reduced system performance

• To improve system performance, you need to tune the file system

28

Page 29: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the mke2fs Command

• mke2fs command– Used to create a Linux ext2, ext3, or ext4 file system

on a specified device, which is usually a hard drive partition

– Format: mke2fs options device

• Best practice– Large files: use a large block size

• If the file size isn’t a multiple of the block size, you should specify the block size as a factor of the file size

– Small files: use small block sizes for optimized performance

29

Page 30: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the tune2fs Command

• tune2fs command– Can be used to tune file system parameters on a

Linux ext2, ext3, or ext4 file system– General format: tune2fs options device

• Example:– Command to change the number of maximum

mounts on /dev/hda4 partition to 60:tune2fs –c 60 –L mypartiton1 /dev/hda4

30

Page 31: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the e2fsck Command

• e2fsck command– Used to check an ext2, ext3, or ext4 file system for

bad data blocks– Syntax: e2fsck options device

• Example:– Command to force a file system check on /dev/hda2 device:e2fsck –f /dev/hda2

31

Page 32: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the badblocks Command

• badblocks command– Used to check a device for bad data blocks– General syntax:badblocks options device

• Example:– Command to check /dev/hda1 device for bad data

blocks and write all bad blocks to the badblockdata file:badblocks –c 20 –o badblockdata /dev/hda1

32

Page 33: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using the noatime Option

• noatime option– A special mount option for a file system– Stored in /etc/fstab configuration file

• When the noatime option is used:– Linux eliminates the need to update the access time

of an inode in the referenced file system– Speeds up file access if files on the referenced file

system are accessed frequently

33

Page 34: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Problem Solving in Linux

• A network’s security must be updated judiciously from time to time

• Administrator should be equipped to face any critical situation and have a thorough knowledge of troubleshooting techniques

34

Page 35: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Preventive Measures

• Having an overall view of a problem is important for troubleshoot

• Applying preventive measures can minimize the effect of critical situations that can cause losses– Backups– Configuration notes– Rescue disks

35

Page 36: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Backups

• YaST System Backup– Started with yast2 backup command– An easy-to-use backup program that searches files on

a Linux system to create a backup archive

• Pax– A POSIX utility that can read and write a wide variety

of archive formats– Command-line utility included with openSUSE Linux

• Ark– KDE archiving tool– A GUI tool

36

Page 37: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration 37

Figure 20-7 The YaST System Backup tool© Cengage Learning 2013

Page 38: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Configuration Notes

• Keep notes on the system configuration

• Notes should contain data about partition table entries and other important information, such as:– Partition number and size– Mount points– User details– Network card details

38

Page 39: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Rescue Disks

• Rescue disks are emergency disks you create ahead of time to save critical data

• To use openSUSE bootable CD as a rescue disk:– Select Rescue System from the boot menu

39

Page 40: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Recovering from a Disaster

• You should try to identify the root cause and find a solution to recover from the problem– Observe and read– Monitor the system log file– Refer to Linux user groups

• A disaster can also result from server downtime caused by a system crash

40

Page 41: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Single-User Mode

• Also known as maintenance mode

• An OS mode in which only the root partition is active and mounted

• Linux runs in runlevel 1

41

Page 42: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Rescue Mode

• You can boot a small Linux environment from some type of medium, such as a CD-ROM

• This medium is called a rescue disk

• Helpful if you cannot recover from a system crash or are having hardware or software problems

• Enables you to access files on the system’s hard drive, even if you’re having trouble running Linux from it

42

Page 43: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Troubleshooting Linux

• Two widely used Linux boot loaders:– LILO and GRUB

• Boot loader– A small program stored on the Master Boot Record

(MBR) that can load one or more OSs by reading file system information through a pointer from the disk partition containing OS files

• Linux Loader (LILO)– One of the original boot loaders– No longer supported by openSUSE

43

Page 44: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Using GRUB

• Grand Unified Boot Loader (GRUB)– A more flexible boot loader than LILO– Has become the boot loader of choice for current

Linux distributions– Packaged with the latest version of openSUSE

• In openSUSE, the GRUB configuration file is controlled by /boot/grub/menu.lst file

44

Page 45: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Login Problems

• Login requires a username and password for validation

• Sometimes root users forget their passwords

• You can change this password by editing the kernel entry in the GRUB menu screen, which tells the system to boot to a specific shell

• Activity 20-4: Changing a Root Password– Change a root password

45

Page 46: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

File System Problems

• Problem– System fails to unmount file system because it’s

been powered off by a hard reboot or power failure

• Solution– System might run a file system check (by using fsck command) to fix problems in file system

• Journaling file systems do not use fsck – Use a log to recover from problems

• To use fsck command, you need to know partition details

46

Page 47: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Network Troubleshooting

• ping command– Used to send Internet Control Message Protocol

(ICMP) packets to a remote host in an attempt to get the remote host to send back an Echo packet

• traceroute command– Tracks the route packets take through a network and

displays the routers used along the way

• Activity 20-5: Using the ping and traceroute Commands– Use ping and traceroute commands to check

network connectivity47

Page 48: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Summary

• Linux kernel performs two main tasks:– Servicing low-level hardware programming

requirements– Providing an environment for different processes in

the computer

• OS can function in user mode or kernel mode

• Linux kernel’s source code is stored under a group of directories known as kernel source tree

• Kernel can be monolithic or modular

• You can use lsmod and insmod commands to manage Linux kernel modules

48

Page 49: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Summary (cont’d.)

• System monitoring is used to determine possible performance bottlenecks and errors– Monitoring CPU utilization, network connection’s

bandwidth, storage space, and memory use

• Basic system-monitoring commands in Linux: top, vmstat, free, du, and df

• Logrotate utility enables administrators to manage large numbers of log files

• Linux includes GUI tools in GNOME and KDE for monitoring system resources and processes

49

Page 50: Linux Operations and Administration Chapter Twenty Advanced Linux Administration.

Linux Operations and Administration

Summary (cont’d.)

• Two frequently used resources that require tuning are hard drives and file systems

• Preventive measures can minimize the effect of critical situations

• In single-user mode, also known as maintenance mode, only root partition is active and mounted

• Grand Unified Boot Loader (GRUB): a small program that can load one or more Oss

• Command for fixing file system problems: fsck• Two useful commands for diagnosing networks: ping and traceroute

50