Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cosc 4750 Booting and shutdown. Bootstrapping Starting up a computer, load kernel into memory and begin executing. a vulnerable time, since errors in.

Similar presentations

Presentation on theme: "Cosc 4750 Booting and shutdown. Bootstrapping Starting up a computer, load kernel into memory and begin executing. a vulnerable time, since errors in."— Presentation transcript:

1 Cosc 4750 Booting and shutdown

2 Bootstrapping Starting up a computer, load kernel into memory and begin executing. a vulnerable time, since errors in configurations files, damaged file systems, failing hardware can prevent the computer from booting.

3 Booting manual –varies between venders –Linux boots to single user mode many system process are not running and only one user can log in (usually root) only part of the filesystem is mounted / /tmp, sometimes /usr and /var –Redhat 7.3+, all local partitions are mounted. –SGI boot to a command mode no system processes are running and the file system is not mounted. Only basic maintenance tasks can be done.

4 automatic –Unix boots to multi-user mode. (or mode pre- specified by administrator) –All system process (that are supposed too) are running. –Entire file system is mounted

5 Steps in booting 1.the boot code that is stored in ROM (BIOS or CMOS) is executed 2.the ROM turns over control to a boot loader (grub for Linux) 3.the boot loader loads and executes the kernel a.device detection and configuration 4.the kernel spawns the system init process, which is PID 1 a.manual boot mode: operator intervention (linux)

6 5. the init process executes a series of startup scripts in the from the rc.d directory which starts up system process and daemons. rc = run command 6. Multi-user operation

7 System Processes swapper – process 0 (not linux) init process 1 various memory and kernel handlers 1 getty process (console, not a gui environment)

8 Mutli-user operation More getty processes to handle logins xdm for X-term logins gdm or dtlogin (SUN) prefdm, X11 windows environment (linux) clogin (SGI)

9 Boot Loader (linux) Provides a way to boot linux, and other O/S like windows, etc. lilo: –configured with a text file, lilo.conf –specifies where the “kernel” is located can be /unix, but redhat 9 uses /boot/vmlinuz Grub –Configured through /etc/grub.conf, similar to lilo

10 Dual Boot Grub –List of available linux kernels to boot –And lists the window boot loader. Turns control over to the windows boot loader, which then boots windows Because of this, windows must always be installed first, then linux.

11 Run Levels level 0 is the level for system shutdown level 1 or S is single-user mode mode level 2-5 are varying multi-user levels –Linux: 3 is none-gui, 5 is gui –linux: 2 no gui and no networking. level 6: is a reboot level specified in /etc/inittab

12 Shutdown To shutdown a system, use the command: shutdown (normally found in /etc/ or /sbin Takes arguments to change between run- levels. like run level 0, which is shutdown Two versions (sys V and bsd) –shutdown –g0 –i0 –y –shutdown –h now (linux command)

13 Shutdown is a script that accesses the init process, – except shutdown –n which is a nasty way to shutdown a system. telinit S which simply go to run level 1 telinit 0 which shutdown the system, without telling anyone. Killing the init process will either reboot the system or just cause it to crash (more likely)

14 startup scripts The run level determines which startup scripts are used. –All of the scripts are located in the /etc/init.d/ directory There are also rcX.d directories –where X is the run level –These contain links to the files in the init.d directory So you only have to modify one file, instead 2 or 3.

15 Example of /etc/rc.d/rc5.d/ K05innd K30mcserv K80nscd S20random S80sendmail K10pulse K34yppasswdd K84apmd S25netfs S85gpm K15pvmd K35dhcpd K84ypserv S30syslog S85httpd K20bootparamd K45named K92ipchains S35krb5server S90xfs K20isdn K50snmpd K96pcmcia S40atd S91smb K20rstatd K54pxe S05kudzu S40crond S99linuxconf K20rusersd K55routed S06reconfig S50inet S99local K20rwalld K60mars-nwe S10network S55xntpd K20rwhod K61ldap S11portmap S60lpd K25squid K65identd S14nfslock S60nfs K28amd K75gated S18autofs S75keytable

16 Shell Scripting Shells are the command interface you use on a UNIX system, similar to DOS –Bourne (sh) Most init/startup scripts are written in bourne –c (csh), tcsh –korn (ksh), z (zsh) –Born Again Bourne Shell (bash)

17 Each is similar in characteristics, but each has it own scripting language. zsh and tcsh are upgrades of csh bash is a (much needed) update to Bourne shell –Startup scripts are done in bash or bourne. This is also the shell for root.

18 Shell Scripts (with bourne shell) file containing a series of commands One command per line (or separated by a ;) Output –Standard out and Standard Error output –command >file redirects std output –cmd >file 2>file2 directs std to file and stderr to file 2

19 variables a shell script uses the same environment variables as your shell uses, ie PATH, etc. using variables (in sh) –person=‘jim’ –echo “$person” –output: jim

20 read command echo –n “Pick a number ” read num echo “You picked: $num” OUPUT: –Pick a number –You picked:

21 You can define variables as commands dir=`pwd` (note the backquote) echo “You are in $dir” The output is: You are in

22 Argument variables $0 is the first argument, which is the name of the script $1 - $9 are command line values passed to the script myscript hi $0 contains myscript $1 contains hi

23 If command if ( T/F ) then fi if ( T/F ) then else fi if ( T/F ) then elif ( T/F ) else fi

24 other structures while ( T/F ) do done case in value) ;; value) *) ;; esac

25 Example 1 echo “Do you like UNIX?” read answer case $answer in Y|y ) whoami >>pass echo “good!” ;; N|n ) whoami >>fail echo “To bad.” ;; *) echo “please enter y or n” ;; esac

26 Example 2 filename=‘jim.txt’ if ( test –r $filename ) then echo “$filename is readable.” elif ( test –f $filename ) then echo “$filename does not exists.” else echo “$filename is not readable.” fi

27 Typical linux init.d script #!/bin/sh # chkconfig: # description: Starts and stops the Samba smbd and nmbd daemons used to provide SMB network services. … start() { KIND="SMB" echo -n $"Starting $KIND services: " daemon smbd $SMBDOPTIONS RETVAL=$? echo KIND="NMB" echo -n $"Starting $KIND services: " daemon nmbd $NMBDOPTIONS RETVAL2=$? echo [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \ RETVAL=1 return $RETVAL } stop() { KIND="SMB" echo -n $"Shutting down $KIND services: " killproc smbd RETVAL=$? echo KIND="NMB" echo -n $"Shutting down $KIND services: " killproc nmbd RETVAL2=$? [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb echo "" return $RETVAL } command line output: #/etc/init.d/smb start Starting SMB services: [OK] Starting NMB services: [OK]

28 shorter init.d script if test $1 = "start" then /usr/local/bin/sshd elif test $1 = "stop" then killall -9 sshd fi

29 Q A &

Download ppt "Cosc 4750 Booting and shutdown. Bootstrapping Starting up a computer, load kernel into memory and begin executing. a vulnerable time, since errors in."

Similar presentations

Ads by Google