45
Guide to Linux Installation and Administration 1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Embed Size (px)

Citation preview

Page 1: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 1

Chapter 4

Running a Linux System

Page 2: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 2

Objectives

In this chapter, you will:

• Manage files and directories on a Linux system using basic commands

• Launch programs and manage corresponding software packages

• Add and remove features from the Linux kernel

• Review and change the initialization process that starts a Linux-based computer

• Shut down a Linux system in an orderly way

Page 3: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 3

Working with Linux Files and Directories

• Information in Linux is stored in files organized in directories

• Parent directory contains child directories and files

• The parent directory for all directories is the root directory

• All Linux configuration files are located in subdirectories of the root directory

Page 4: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 4

Standard Linux Subdirectories of the Root Directory

Page 5: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 5

Working at a Command Line

• Logging in to Linux at a text-mode console launches a command-line environment

• Within a graphical environment, you can a command-line window by using the xterm program

• The command-line window is also called a terminal emulator window

Page 6: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 6

A Command-Line Window in a Graphical Environment

Page 7: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 7

Managing Files with Command-Line Utilities

• The command-line environment is provided by a shell

• Shell: program that accepts and acts on the commands that you enter

• Absolute path: complete description of the directory in absolute terms

• Relative path: partial description of the directory relative to another location

Page 8: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 8

Managing Files with Command-Line Utilities

• Linux commands– are case sensitive

– can include options and parameters

• Information about the date and time when an event occurred is stored in the form of a timestamp

Page 9: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 9

Commands for Managing Files and Directories

Page 10: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 10

Commands for Managing Files and Directories

Page 11: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 11

Managing Files with Command-Line Utilities

• Filenames– Are case-sensitive

– Can be up to 256 characters

– Can include file extensions

Page 12: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 12

Managing Files with Graphical Utilities

• Linux desktop includes a file manager• File manager: graphical program to display the

contents of a directory and manage files and directories

• The file manager in Red Hat Linux 7.3 is called Nautilus

• To perform basic file management tasks, you can drag and drop file icons

Page 13: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 13

The Nautilus File Manager Window

Page 14: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 14

File Properties

• Each file in Linux has several basic properties:– Type

– Name

– Size

–  Location

– Timestamp

• Each file has the owner of the file, the group assigned to the file, and the permissions granted to access the file

Page 15: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 15

The Properties Dialog Box

Page 16: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 16

File Permissions

• File permissions define the access that the owner has granted to others on the Linux system

• Types of permissions:– Read permission (r)– Write permission (w)– Execute permission (x)

• Permissions can be assigned in three different ways:– User permission– Group permission– Other permissions

Page 17: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 17

File Permissions

• You can alter file ownership and file permissions using the chown and chmod commands

• The chmod command uses letters or numeric codes to define the file permissions assigned to a file or directory

• The umask command determines the file permissions assigned when you create a new file

Page 18: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 18

Commonly Used File Permission Settings

Page 19: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 19

The Permissions Tab of the Properties Dialog Box

Page 20: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 20

Running and Managing Software

• Environment variables: defined by the Linux shell so that all programs can access their values

• Variable: memory location used by a program to store a value

• The PATH environment variable includes a list of all the directories where programs on the system are located

• You can display values of the PATH using the echo command

Page 21: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 21

Function Libraries

• A function is a small task that a computer program performs

• A function library is a file that contains commonly used functions

• The ldd command lists the libraries that a program requires

Page 22: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 22

Using rpm to Manage Software Packages

• rpm command– Manages all of the rpm software packages– Maintains a database for all the software installed

on the Linux system• You can use the rpm command to query the

software package database or to install or erase software packages from the system

• Hundreds of options are supported by the rpm command

Page 23: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 23

Using Graphical Tools to Manage Software Packages

• GNOME and KDE include graphical programs to manage software packages

• The GnoRPM package management utility is included with Gnome

• The KDE Desktop includes a package management tool called kPackage

• Both GmoRPM and kPackage provide menu items

Page 24: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 24

The Main Window of the GnoRPM Utility

Page 25: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 25

Using kPackage to Display Software Package Information

Page 26: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 26

Using tar Archive Files

• A tar archive is a collection of many files stored in a single file

• The tar command is used to create a tar archive, to extract its content, and to create backups of files on the system

• A tar archive has a .tar extension• The resulting file after the tar command with the

compression options is called a gzipped tarball

Page 27: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 27

Compression Utilities in Linux

Page 28: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 28

The Linux Kernel

• Each Linux kernel has:– Release number

– Timestamp

– Modules

Page 29: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 29

Learning about Your Kernel

• The uname command with the –r option displays the version of your Linux kernel followed by the release number

• A release number is assigned by the company that prepared the Linux product

• A timestamp indicates the date and time when the kernel was created

Page 30: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 30

Kernel Modules

• Linux kernel modules are files containing computer code that can be loaded into the kernel or removed from the kernel

• Kernel modules can be automatically loaded based on the configuration set during the Linux installation

• The lsmod command lists the modules that are installed in the Linux kernel

Page 31: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 31

Adding and Removing Modules

• The modprobe command loads a module with any required supporting modules

• The rmmod command removes a module from the kernel

• Module parameters provide information needed by amodule to locate system resources

Page 32: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 32

Locating Modules

• The module files are stored in /lib/modules/version/kernel directory, where version id the version number of the Linux kernel on the system

• This directory contains subdirectories for networking-related modules, device drivers, and other module types

Page 33: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 33

The Initialization Process

1. A boot manager loads and starts the Linux kernel

2. The Linux kernel initializes hardware and then launches the init program

3. The init program launches a script based on the run level in which Linux is to operate

4. The script started by init typically runs many other scripts to launch and manage system services

Page 34: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 34

Booting the Kernel

• GRUB and LILO are the boot managers• The boot manager displays a prompt listing the

available operating system to launch• Boot parameters instruct the Linux kernel how to

operate or how to access parts of the computer system’s hardware

• You can add boot parameters at the boot manager selection prompt

Page 35: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 35

Configuring the Boot Manager

• You can update the configuration of a boot manager after the installation is completed

• The configuration file for the LILO boot manager is /etc/lilo.conf

• The configuration file for GRUB boot manager is /boot/grub/grub.conf

Page 36: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 36

Initializing System Services

• The init program is a master control program that starts other programs and scripts that initialize the system services

• A script is a collection of commands that are stored in a text file and executed without user intervention

• The init program is controlled by the /etc/inittab configuration file

Page 37: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 37

Reviewing Run Level Services

• A run level is a mode of operation in which a preconfigured set of services is activated

Page 38: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 38

The Linux Initialization Process

Page 39: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 39

Starting and Stopping System Services

• The chkconfig program allows you to start and stop services when you boot Linux

• RedHat Linux includes a graphical utility to configure system services called serviceconf

• The KDE Desktop includes a similar graphical utility called ksysv

Page 40: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 40

The Service Configuration Utility

Page 41: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 41

The ksysv Graphical Services Configuration Utility

Page 42: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 42

Configuring System Services

• The initialization scripts in /etc/rc.d/init.d are provided when you install Linux

• Configuration details for system services scripts are located in the /etc/sysconfig directory and its subdirectories

Page 43: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 43

Shutting Down Linux

• You can shut down Linux by:– The reboot command

– The halt command

– The shutdown command

– Pressing Ctrl+Alt+Del

– The telinit 0 command

Page 44: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 44

Summary

• Information in Linux is stored in files organized in a directory structure that begins with the root directory

• There are basic commands to manage files and directories

• Files can be compressed using tar, zip, gzip, and other utilities

• Read, Write, and Execute permissions for a file or directory can be assigned to the owner, to the assigned group, or to all other users on the system

• The rpm command is used to query the software package database or to install or erase software packages from the system

Page 45: Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System

Guide to Linux Installation and Administration 45

Summary

• The Linux kernel supports loadable modules, which are managed using the lsmod, insmod, rmmod, and modprobe commands

• You can provide boot parameters to the Linux kernel at the boot manager selection prompt

• The Linux kernel starts the init program, which in turn runs several scripts based on information stored in the run level directories

• You can set up which services are activated at boot time using the chkconfig command or using various graphical utilities

• To avoid data loss, you must gracefully shut down Linux using a command such as reboot, halt, or shutdown