32
Booting and Shutdown Linux System Administration 1 Linux System Administration Booting and Shutting Down Booting and Shutdown Linux System Administration 2 Objective At the conclusion of this module, the student will describe the Linux System states including: Boot process Boot levels – Runstates /etc/inittab file – Daemons – Shutdown – CLI

Linux System Administration - Brookdale Community College

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

1

Linux System Administration

Booting and Shutting Down

Booting and Shutdown Linux System Administration 2

Objective• At the conclusion of this module, the student will

describe the Linux System states including:– Boot process – Boot levels– Runstates– /etc/inittab file– Daemons– Shutdown– CLI

Page 2: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

2

Booting and Shutdown Linux System Administration 3

Booting/Bootstrapping• Booting

– hardware-dependent• Boot Configuration

– first task of system administrator on new system• Boot Process

– kernel loaded into memory and executed– Initialization tasks performed– System made available to users

• Potential Boot Problems– Errors in configuration files– missing/unreliable equipment– damaged filesystems

Booting and Shutdown Linux System Administration 4

The Bootloader• A boot loader is a program that resides in the

beginning sectors of a disk– the MBR (Master Boot Record) of the hard disk

• After testing the system during bootup, the BIOS transfers control to the MBR

• The boot loader, the program residing in MBR, is executed

• transfers control to the operating system– OS continues the boot process

Page 3: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

3

Booting and Shutdown Linux System Administration 5

GRUB• GRUB (GRand Unied Bootloader)

– a program that installs a boot loader to the MBR– allows the placement of specific instructions in the MBR

that loads a GRUB menu or command environment– enables users to

• start the operating system of choice• pass special instructions to kernels when they boot• discover system parameters before booting

Booting and Shutdown Linux System Administration 6

GRUB• GRUB is a very powerful boot loader

– Capable of loading a number of different operating systems• configuration files are interpreted• configuration file is /boot/grub/menu.lst

– Some distributions may use a different configuration file• Red Hat Linux uses the file /boot/grub/grub.conf– The Red Hat Fedora version of this file is on the next slide

Page 4: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

4

Booting and Shutdown Linux System Administration 7

/boot/grub/grub.conf# grub.conf generated by anaconda## Note that you do not have to rerun grub after making # changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to # /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/hda3# initrd /initrd-version.img#boot=/dev/hdadefault=1timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle Fedora Core (2.6.9-1.667)

root (hd0,0)kernel /vmlinuz-2.6.9-1.667 ro root=LABEL=/1 rhgb quietinitrd /initrd-2.6.9-1.667.img

Booting and Shutdown Linux System Administration 8

The Linux Boot Process1. GRUB starts and Linux is selected as the

operating system to boot2. The Linux kernel is loaded into memory and

then probes system hardware3. The init process reads /etc/inittab and

determines whether runlevel 0-6 should be started

• Never set runlevel 0 or 6 as the default• runlevel 1 only used for problems and maintenance

4. rc scripts are executed for the specified run level to start various services

Page 5: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

5

Booting and Shutdown Linux System Administration 9

Bootstrapping• Bootstrapping comes from a German legend about a Baron

Münchhausen, who was able to lift himself out of a swamp by pulling himself up by his own hair– In later versions he was using his own boot straps to pull himself out of

the sea which gave rise to the term bootstrapping.• In computers this term refers to any process where a simple

system activates a more complicated system– It is the process of starting a system without the system already

functioning– The processes by which a complex system emerges by starting simply

and, bit by bit, developing more complex capabilities on top of the simpler ones

• In *nix, it is the process by which the kernel is loaded into memory and begins to execute– spawns the init process – executes rc files which check and mount the file system and start

system daemons

Booting and Shutdown Linux System Administration 10

Boot Modes• Automatic

– Performs boot without external assistance• Manual

– Automatic procedure until initialization scripts are run by operator

– Single-user mode• most system processes not running and users unable to log in

Page 6: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

6

Booting and Shutdown Linux System Administration 11

Boot Process – Step 1• Loading and Initialization of the kernel

– Path and name of kernel is vendor dependent• Red Hat /boot/vmlinuz-2.6...

• kernel is loaded into memory• loading is a two-stage process

– small boot program read into memory to enable kernel loading

– kernel runs tests to determine memory availability• kernels run in a fixed amount of memory • knows how much to reserve for internal storage and I/O buffers

Booting and Shutdown Linux System Administration 12

Boot Process – Step 2• Device Detection and Configuration

– kernel performs hardware check• General hardware device info is incorporated in kernel

configuration• Locate and initialize each device • Acquire more information via drivers

– If not found, will disable hardware– If hardware added new versions will enable

– Most newer versions of Linux use kudzu to detect new hardware or hardware changes

• If changes found, kudzu will ask if you wish to configure new hardware

Page 7: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

7

Booting and Shutdown Linux System Administration 13

Boot Process – Step 3• After initialization, kernel creates spontaneous

processes in users space – Not created via normal fork mechanism

• fork creates copy of the original process with new PID that is identical to the parent

– BSD has 3 processes• swapper - process 0• init - process 1• pagedaemon - process 2

– ATT: varies• sched - process 0• init - process 1; various memory handlers

– kernel role complete• init handles processes for basic operations and UNIX daemons

Booting and Shutdown Linux System Administration 14

Boot Process – Step 4• Operator Intervention in Single-User Boot Only• init notified via command-line flag from kernel

– creates a shell and waits for it to terminate (<control-d>or exit) before continuing startup procedure

• runs as root with root partition mounted• Available programs located in /bin, /sbin, /etc, and /usr; ~

other filesystems must be mounted by operator • daemons are not available• fsck (checks and repairs filesystems) must be run by hand

Page 8: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

8

Booting and Shutdown Linux System Administration 15

Boot Process – Step 5• Execution of Startup Scripts

– The location, content, and organization of shell– scripts vary from system to system

• BSD: kept in /etc and names begin with rc• Linux and other SYSV: kept in /etc/init.d with links made

to other directories such as /etc/rc0.d, /etc/rc1.d…– Examples of tasks performed in initialization scripts

• Set computer name• Set time zone• fsck disk check;• Mount system’s disks• Remove files from /tmp• Configure network interfaces;• Start up daemons and network services• Turn on accounting and quotas

Booting and Shutdown Linux System Administration 16

Boot Process – Step 6• Multi-User Operation• To complete boot process and allow user access

– init produces getty process on each workstation• In BSD: init has only two states - single-user and multi-user• In Linux and SYSV: init has one single-user and several multi-

user run levels to determine which system resources are enabled

Page 9: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

9

Booting and Shutdown Linux System Administration 17

The Linux and SYSV init Process• init reads /etc/inittab, which designates what

runlevel to start. A runlevel of initdefault is selected unless otherwise designated.

• The runlevel determines what functionality the system should be providing

• Run levels for SYSV systems are:0 Halt the system1 Single-user (no networking)2 Multiuser without NFS3 Multiuser with NFS4 Unused5 Same as 3 but with X11 console (X Windows)6 Reboot the system

Booting and Shutdown Linux System Administration 18

UNIX Run Levels• Run Level 0

– The system halt or shutdown run level– All system processes are stopped and the system halts

• Run Level 1 – single user mode– Also called maintenance mode– No prompts for login or password – Accessible only via console – no remote access to the

system (i.e. telnet)– Very minimal services are running – no networking, no

X Windows– Console user has root permissions– Used for system maintenance– Used when you forget the root password

Page 10: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

10

Booting and Shutdown Linux System Administration 19

UNIX Run Levels (con’t)

• Run Level 2– All typical services are started– Multi-user mode – users are allowed to log into the

system– NO NFS (Network File System) file sharing

• Run Level 3– Same as run level 2, but NFS is enabled– ***This is the DEFAULT system run level for

command line• Run Level 4

– Not used (historical)

Booting and Shutdown Linux System Administration 20

UNIX Run Levels (con’t)• Run Level 5

– Same as run level 3, but the system will automatically boot into X Windows

– console users will authenticate via an X Windows username/password interface

• Run Level 6– The system reboot run level.– System processes are stopped and the machine is restarted

Page 11: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

11

Booting and Shutdown Linux System Administration 21

Startup Files• A major part of startup is running programs that perform some

function and quit or continue running as daemons– These programs are configured and executed in the startup scripts

• The rc.d directory has the following entries/init.d /rc0.d /rc1.d /rc2.d/rc3.d /rc4.d /rc5.d /rc6.drc rc.local rc.sysinit

• rc is an acronym for resource configuration and dates back to the early days of UNIX– it is the master script that executes the others when called by init

(rc#)– it is the first script run is controlled by a sysinit action – it normally runs /etc/rc.d/rc.sysinit

Booting and Shutdown Linux System Administration 22

rc.d Startup ScriptThis script performs basic operations in order: • Set up logging (/sbin/initlog) • Set up a minimal network (/etc/sysconfig/network) • Set script functions (/etc/init.d/functions) • Print a banner (/etc/motd)• Mount /proc• Configure kernel params (sysctl -e -p

/etc/sysctl.conf) • Configure the clock (/etc/sysconfig/clock) • Setup console and keyboard • Turn on swapping (swapon -a -e) • Initialize USB

Page 12: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

12

Booting and Shutdown Linux System Administration 23

rc.d Startup Script Cont’dThis script continues to perform basic operations:

– Perform fsck checking as necessary – Mount root – Set up disk parameters – Update quotas – Load modules – Initialize RAID – Mount file systems – Initialize process accounting (/sbin/accton) – Configure things not configured (root password, network,

time, authentication – Clean up

Booting and Shutdown Linux System Administration 24

rc Scripts• Run level scripts are located in /etc/rc.d/rcX.d

(X=runlevel #, e.g. /etc/rc.d/rc3.d for run level 3). They are used for both startup and shutdown purposes.

• These directories have startup scripts that run processes and applications during boot time

• The scripts use the following naming convention:– K or S + Number + Service Name (i.e. S80sendmail)– S is for start. K is for kill. Lower numbers start before higher.

• Startup scripts take two options: start or stop. Scripts with an S are run with start option

• Scripts with a K are run with a stop option.

Page 13: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

13

Booting and Shutdown Linux System Administration 25

rc scripts Cont’d• The scripts in the rcX.d directories are typically NOT

actual files themselves – they are usually symbolic links to links to scripts located in /etc/rc.d/init.d or /etc/init.d– A script that starts the apache server, might exist: /etc/rc.d/init.d/apache

– This script need only contain the commands that required to start apache.

– To start Apache during run level 3, create a symbolic link in /etc/rc.d/rc3.d called, for example, S99apache and link it to /etc/rc.d/init.d/apache

Booting and Shutdown Linux System Administration 26

rc script Example• Assume you have a script that checks the system for files

that are world writeable (files that anyone on the system can write to) and emails these filenames to you.

• This script is called findwrite and is located in /etc/rc.d/init.d.

• You would like to run this script when the system starts in ANY multiuser mode (I.e. run level 2, 3 and 5)

• Therefore, you must create symbolic links to /etc/rc.d/init.d/findwrite from the /etc/rc.d/rc2.d, rc3.d and rc5.d directories.

Page 14: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

14

Booting and Shutdown Linux System Administration 27

Determining the Current Runlevel• If you are operating at the CLI, you can determine the

current runlevel with the command:who -r

• The end of the output line shows the previous runlevel. Red Hat uses last=who -rrun-level 3 May 22 14:35 last=S

• The previous output shows that the system went from runlevel S to runlevel 3 on May 22 at 14:35 (2:35PM)

Booting and Shutdown Linux System Administration 28

Ways of Changing Run Levels/sbin/telinit [0-6]/sbin/init [0-6]

Allows you to specify a specific run level to change toCTRL-ALT-DELETE

Key combination on PC-based UNIX systems reboots the systemCan be disabled in /etc/inittab.

***Only power-cycle a UNIX system as a last resort

Page 15: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

15

Booting and Shutdown Linux System Administration 29

Changing the Runlevel from the CLI• Using the init command to change the runlevel dumps

all current users– It is a good way to increase the number of visitors to your

office, or to fill email box with messages if you are lonely• To change the runlevel to 1 after a 5 second delay,

execute the command:init –t 5 1

• To change to the GUI, execute:init 5

• To start the GUI without dumping all users, enter the commandstartx

Booting and Shutdown Linux System Administration 30

Changing the Default Run Level• To change the default run level, use vi or a text editor to

edit the file /etc/inittab• look for the line:

id:3:initdefault:

• After id: put the run level number you wish to use as your default run level. (3 and 5 are most common options)

• Now when your machine boots, it will automatically enter that run level.

• After installation of Red Hat Fedora, the default runlevel is 5.

Page 16: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

16

Booting and Shutdown Linux System Administration 31

Unix Shells• Bourne shell ($)

– original shell program– default shell for Solaris– developed by Stephen Bourne for AT&T– mostly used by system administrators

• Korn shell ($)– superset of the Bourne shell– developed by Stephen Korn at Bell Labs– added features such as aliasing and history– most widely used shell. Industry standard for users– this course is based primarily on the Korn shell

• Bash shell ($) (Bourne Again shell)– Subset of Borne shell– has very convenient command editing features

Linux System Administration

Mounting filesystems

Page 17: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

17

Booting and Shutdown Linux System Administration 33

ObjectiveAt the conclusion of this module, the student will be able to:• Represent devices on a Linux system • List the device-to-file mapping conventions for your system • Create a new filesystem on a floppy disk • Explain how inodes and filenames interact • Examine the output of the mount command to determine

where physical devices reside • Use the mount and umount commands • Examine the system configuration file to mount special device

files • Explain how removable media are attached directly to the

filesystem • Read and Write to Flash memory and ZIP drives connected to

a USB port

Booting and Shutdown Linux System Administration 34

Linux filesystem Definition• A Linux filesystem is a data structures that manages files,

directories, and devices • Physical devices attached to a Linux or UNIX system are

represented by entries in the filesystem by device special files– Under Linux, these special files correspond to physical devices are

located in the /dev directory – Other versions of UNIX may use a different directory such as /mnt

• filesystems comprise– FAT, superblocks, inodes– The way files are organized on a disk (NTFS, ext2, ext3)

• Provides a layer of abstraction so that programs do not have to directly access the raw disk

Page 18: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

18

Booting and Shutdown Linux System Administration 35

Typical Linux Directory Structure• / -- Root of the file system• /bin -- Essential commands, shared by the system,

the system administrator and the users • /boot -- The bootloader files and the kernel, vmlinuz

• /dev -- Contains device files– references to all the CPU peripheral hardware

• /etc -- System configuration files– Most important system configuration files

• /home -- the users home directories• /initrd -- initial RAM disk boot support

– loaded by the boot loader and used during boot• /lib -- shared libraries, kernel modules• /lost+found -- Files rescued during failures

Booting and Shutdown Linux System Administration 36

Typical Linux Directory Structure• /mnt -- mount point for local and remote file systems • /opt -- Third party and extra software • /proc -- Acts as an interface to internal data structures in the

kernel– Used to obtain information about the system – Used to change certain kernel parameters at runtime

• /root – Home directory of superuser – the root’s $HOME

• /sbin -- Programs use by the system and the system administrator

• /tmp -- Temporary space for use by the system • /usr -- Secondary software programs • /var -- Temporary data like log files and spooled files

Page 19: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

19

Booting and Shutdown Linux System Administration 37

Common Subdirectory Structure/etc (etcetera) directory

system admin files (passwd file)

/boot directorybasic operating system files main UNIX kernel

/dev (devices) directoryfiles which are pointers to device names

/home directoryuser home directories

/usr directoryexecutables, system admin utilities, and library routines

/opt (optional) directoryapplications and third party applications

/var (variable) directoryprint spooling and mail system error messages

Booting and Shutdown Linux System Administration 38

File System Hierarchy• File System –

– group of directories that can be thought of as a separate tree structure

– similar to logical partitions • like C: or D: drive in

Windows/DOS– made available (mounted) or

unavailable (unmounted) at the administrator’s discretion

– can either be local or remote• Directory

– location for other files and subdirectories

• like a file drawer in a file cabinet• Subdirectory –

– Any directory (child) below another directory (parent)

• Files – contained in directories and

subdirectories

Page 20: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

20

Booting and Shutdown Linux System Administration 39

ext2 filesystem• the old default filesystem for Linux• supports partitions up to 4 TB, with a single files up to 2 GB

– Some kernels only support block devices up to 2TB• Filenames may be up to 255 characters long• Improper shutdown may leave the disks may in unclean state

– some data is only partly written or where data has been written without the directory entry being updated

– Linux must perform a filesystem check on the next boot using thee2fsck

– To make sure that the filesystem is healthy, e2fsck is run periodically even with proper shut down.

• Permits undeleting of files– with ext2, even when a file is actually deleted, it is possible to restore

it unless it has been overwritten• allows secure deletion

– ensures that a confidential file cannot be undeleted– Special attributes allow files to be marked unmodifiable or append-only

Booting and Shutdown Linux System Administration 40

swap partition• a reserved disk space in that Linux uses to write

temporarily data from RAM to the swap file• frees RAM for other processes• not used for storing files

Page 21: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

21

Booting and Shutdown Linux System Administration 41

Windows and DOS filesystems• FAT16 was the standard partition type up to

Windows 95• FAT16 partitions are supported by all versions of

Windows• FAT32 partitions are the standard with Windows 98

– supported beginning with Windows95 second edition and Windows 2000

– not supported in Windows NT• Linux supports both reading from, and writing to

FAT16 and FAT32 partitions– Purpose is to share files between Linux and Windows – FAT16 partitions are limited to a maximum of 2Gb

Booting and Shutdown Linux System Administration 42

NTFS• Introduced in Windows NT v4.0 • Designed to remove the limitations in the old FAT16

filesystems • added new features not found in OS/2• Linux currently supports this filesystem in read-only

mode– not all Linux distributions enable this feature– Read-write access to this disk is under development and in

beta

Page 22: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

22

Booting and Shutdown Linux System Administration 43

Journaled Filesystems• Eliminates filesystem problems associated with

improper system shutdown• system maintains a journal on the disk that describes

all the changes that must be made to disk– a background process takes each journal entry, makes the

change and marks it as completed• If system is halted without a shutdown, the pending

changes are performed when the system is restarted – much faster than running fschk

• Incomplete entries in the journal are discarded.– guarantees consistency and removes the need for a long and

complex filesystem check on boot

Booting and Shutdown Linux System Administration 44

ext3 filesystem• a descendant of ext2• it is essentially ext2 with added support for journaling• Advantages:

– It is backwards compatible– ext2 partitions can be converted to ext3 and vice-versa

without reformatting the partition– An ext3 partition can be mounted by an older kernel with

no ext3 support - it is just seen as a normal ext2 partition– allow files to be undeleted

Page 23: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

23

Booting and Shutdown Linux System Administration 45

Virtual File System (VFS)• kernel software layer that handles all calls related to

Linux filesystem• Manages all different filesystems that are mounted• Provides a common interface to disk-based, network-

based and special filesystems– Special filesystems are located in /proc and /dev

• Maintains a data structure that describes the entire (virtual) filesystem and the physical (mounted) filesystem

• Describes system files in terms of superblocks and inodes

Booting and Shutdown Linux System Administration 46

The Virtual File System

Page 24: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

24

Booting and Shutdown Linux System Administration 47

Superblocks and Inodes• The part of the UNIX operating system that deals

with inode storage• The superblock comprises the following:

– The size of the file system – The number of free blocks in the current filesystem – The size of the inode list – The number of free inodes in the file system – A list of free inodes in the current file system – An index of the next free inode data structure in the free

inode list – A flag to show modified superblock

• An inode is a data structure that identifies a file• Each inode has a number that identifies it• inode numbers can be viewed using the command ls -iF

Booting and Shutdown Linux System Administration 48

mount Command• mount is a system call • you must have root permissions to mount filesystems• instructs the system to attach the filesystem on the

specified device special file to the directory given as a mount-point

• takes many options that affect the way the mounted filesystem is treated

• The command syntax is: • mount device -t type mount-point

– type is file system type such as ext2, vfat, msdos, etc.– Device is device filename such as /dev/usbstick– Mount-point is the directory where the device must be

attached

Page 25: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

25

Booting and Shutdown Linux System Administration 49

umount Command• umount is used to remove the filesystem• A filesystem cannot be unmounted if it is busy

– A filesystem is busy if some process has files open in that filesystem

• you must have root permissions to umount filesystems

Booting and Shutdown Linux System Administration 50

Useful Keyboard Shortcuts• Change to one virtual console

from another CTRL-ALT-[F1-F6]• Change to X-Windows (must already be running

from another console or from boot) CTRL-ALT-F7

• Terminate X-SessionCTRL-ALT-Backspace

Page 26: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

26

Linux System Administration

Downloading Files with ftp

Booting and Shutdown Linux System Administration 52

ftp

• File Transfer Protocol– Used to transfer files between remote and local computer– Uses many standard Linux commands– get – download file from remote system– mget - download multiple files from remote system

• You must answer y or n as the system prompts for each file that will be downloaded

– put – upload file from remote system– mput - upload multiple files from remote system– quit – terminate ftp session– See page 345 of course text for all commands

• From the ftp prompt, execute normal Linux commands for execution on the remote filesystem

• Place an ! in front of commands to be executed on the local filesystem• In the following slides, all user entries are in red and bold.

Page 27: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

27

Booting and Shutdown Linux System Administration 53

ftp Loginftp 172.16.11.2Connected to 172.16.11.2.220 Access to this system is restricted to authorized users only.User (172.16.11.2:(none)): netw110331 Please specify the password.Password: atc*109230 Login successful.ftp> ls200 PORT command successful. Consider using PASV.150 Here comes the directory listing.bind-9.2.4rc6.tar.gzcups-1.1.21rc1-source.tar.gzdhcp-3.0.1rc13.tar.gzopenssh-3.9p1-1.src.rpmvsftpd-2.0.1.tar226 Directory send OK.ftp: 140 bytes received in 0.01Seconds 9.33Kbytes/sec.

Booting and Shutdown Linux System Administration 54

ftp get Commandftp> get openssh-3.9p1.tar.gz200 PORT command successful. Consider using PASV.150 Opening BINARY mode data connection for openssh-3.9p1-

1.src.rpm (910869 bytes).226 File send OK.ftp: 910869 bytes received in 0.80Seconds 1142.87Kbytes/sec.

Page 28: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

28

Booting and Shutdown Linux System Administration 55

ftp mget Commandftp> mget *.gz200 Switching to ASCII mode.mget bind-9.2.4rc6.tar.gz? y200 PORT command successful. Consider using PASV150 Opening Binary mode data connection for bind-

9.2.4rc6.tar.gz <4504630 bytes>.226 File send OK.ftp: 4504630 bytes received in 3.11Seconds 1448.43Kbytes/sec.mget cups-1.1.21rc1-source.tar.gz? y200 PORT command successful. Consider using PASV150 Opening Binary mode data connection for cups-1.1.21rc1-

source.tar.gz <4488767 bytes>.226 File send OK.

Booting and Shutdown Linux System Administration 56

ftp mget Commandmget dhcp-3.0.1rc13.tar.gz? y200 PORT command successful. Consider using PASV150 Opening Binary mode data connection for dhcp-

3.0.1rc13.tar.gz <854832 bytes>.226 File send OK.ftp: 854832 bytes received in 0.58Seconds 1478.95Kbytes/sec.ftp> quit

Page 29: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

29

Booting and Shutdown Linux System Administration 57

Anonymous ftp• Many Internet sites maintain files in a public

directory that you can download even though you do not an account on the system

• You are restricted to specific public directories, and on most sites you are restricted to downloading files only and some basic UNIX command

• Your login to these sites is anonymous• Your password is usually either guest or your email address

Linux System Administration

Controlled Shutdown and Reboot

Page 30: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

30

Booting and Shutdown Linux System Administration 59

Shutting Down• Failure to properly shut down can cause damage to the

filesystem• Here are the commands:

– shutdown: Broadcasts a message to all users logged in prompting a system shut down

– halt: Performs essential duties required to bring the system down, waits for the filesystem writes to complete then halts the kernel

– reboot: Executes identically to halt with the excepting that it causesto system to restart from scratch rather than halting the kernel

– kill init: This is not recommended but will cause the system to immediately shutdown

• Since init is the parent of all processes, all child processes will be terminated when init is killed

Booting and Shutdown Linux System Administration 60

Shutdown Command• shutdown –r 15 – reboot in 15 minutes• shutdown –r 0 – reboot immediately

– Same as reboot• shutdown –h 30 – shutdown in 30 minites• shutdown –h now – shutdown immediately

– Same as halt• Example of shutdown in 30 seconds with a message to all

logged on usersshutdown –t 30 –h “System going down for maintenance”

• Example of shutdown in 30 minutes with a message to all logged on usersshutdown 30 –h “System going down for maintenance

• CTRL-C will terminate a timed shutdown

Page 31: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

31

Booting and Shutdown Linux System Administration 61

Emergency Boot Procedures• If system is unable to boot normally or you

forgot your root password, the following options are available:– Boot from your boot disk –

• Can be created usually be created during a UNIX install process.

• Linux also has a mkbootdisk command.– Boot from your the install floppy or cdrom

• You may be prompted to boot into single user mode or into a recovery mode

– Boot into single user mode.

Linux Network Administration

Recovery from Lost root Password

Page 32: Linux System Administration - Brookdale Community College

Booting and Shutdown Linux System Administration

32

Booting and Shutdown Linux System Administration 63

Root Password Recovery• If you lose or forget the root password, you can change it by booting to the

single user mode• This gives you root privileges without networking, and you just change

your password with the passwd command• You must be at a local terminal as rebooting will close any open

connectionsReboot the systemWhen the Grub loader screen appearsPress eUse the arrow keys to select the line that begins with the word kernel Press e again, Move to the end of the line. Delete everything after the / in Label=/ and type single (or 1) Press Enter to acceptPress b

Booting and Shutdown Linux System Administration 64

Root Password Recovery• For lilo, just enter the command linux single

• From either GRUB or lilo, the procedure now is the same

• The system boots up into the single user mode with no network support

• Your system prompt is similar to sh-3.00b#• Type passwd and change it the normal way.• After your password is accepted, type the command reboot