it136.presentation16..

boundlessbazaarΔιακομιστές

9 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

176 εμφανίσεις

Quiz


25 minutes


Open book, open note, open computer


No talking


No collaboration


Please hand in your homework with the quiz

Review


Regex

cheatsheets


Static string



DocumentRoot



Ranges


[A
-
Za
-
z0
-
9]


.


any single character/symbol


+/*
-

one/zero or more of what came before
(.*)


\
d
\
w
\
s


sed

and
awk


No more
regex’s
! (until the final)

Today


Runlevels



Or, why I hate
Ubuntu



But
Debian’s

still okay


/etc/
rc
[0
-
6].d and /etc/
init.d


The GUI!


Commands and their menus

Runlevels


Linux boot behavior


You push the power button and the power
causes firmware to initialize components


“Enumerates” everything in the server


motherboard,
cpu
, memory, NIC cards, etc…


Firmware looks for special partition called
MBR


Master Boot Record


Linux MBR is either
LiLO

(old) or GRUB (new)


Grub



Press ‘e’



Grub


Tells where to load the system


Root at
hd

(hard drive 0), partition 0


On the installation, you can put the MBR on the
‘boot sector’ or elsewhere


kernel


the actual kernel image and
runlevel

the system will move into


initrd



a temporary
filesystem

that adapts the
kernel image to the hardware before kernel is
loaded

OS Loading


Grub kicks off the
initrd


Initrd

does set up of a temporary
filesystem


Kernel image loads the final
filesystem

and the
running process


There are different versions of the same
kernel


Once that is loaded, the kernel starts it’s
“initialization” or init

Runlevels


0


Off (system halt)


1


Single
-
user mode (without networking)


2


Single
-
user mode with networking


3


Multi
-
user mode (no GUI; w/networking)


4


“Reserved” (not used)


5


Multi
-
user mode with GUI & networking


6


Reboot

Runlevels

Best Practice


It’s safe to assume if you
boot into

the GUI,
you’re in
runlevel

5


It’s safe to assume if you
boot into

a command
line (such as on our VM or on a server) you’re in
runlevel

3


PS most Linux servers do not have GUI installed


Ubuntu

ignores this (is the only distribution I’m
aware of that does)


is always
runlevel

2


Other
admins

I’ve discussed this with agree


on
the previous slide, what
runlevel

might be better
for a ‘special’ configuration?

Runlevel

Details


From the command line,
runlevel

command
shows your current level


The init command is used to move into an
‘initialization’ level


init 6 (reboot the system); init 3 (etc…)


shutdown

h now (calls init 0)


The system will run the scripts in the
runlevel

folder
-

/etc/
rc
[0
-
6].d


Can also do this in Grub


Press any key to enter Grub, press e to edit the
entry, add ‘single’ for single
-
user mode


Quick Aside
-

PXE


Large corporations use PXE


Prebuilt
eXecution

Environment


to install lots of
computers at once


Linux PXE servers require the DNS package
(Bind), TFTP server, and Apache web server


The server to get the OS image needs to have
PXE turned on (usually in the BIOS)


Three files needed to get a running image:
initrd
, kernel, and anaconda
-
ks.cfg file

Boot Messages



Init Scripts


So each folder is associated with the number of
the
runlevel


/etc/rc0.d (halt


all kill scripts except the script
to start a shutdown)


/etc/rc1.d (single user mode, no networking)


/etc/rc2.d (single user mode, w/networking)


Where are the ‘init’ scripts held for configuring
runlevel

6 (reboot)?



Run an
ls

of any of the above directories and two
types of scripts show


K## and S##

K for Kill; S for Start


K scripts are shutdown scripts


they stop the
process for that
runlevel


S scripts are startup scripts


they initialize the
process for that level


Each script is run based no the number


lowest
first


K01dnsmasq is run before K20nfs, which is run
before K88syslogd


So which is run first, second and third?


S55sshd, S08iptables, S10network

Run an
ls

of any
rc
[0
-
6].d directory

Symlinks


Symlinks

are like shortcuts


In Windows we can right
-
click and select
‘Create Shortcut’


In Linux, we can use the
ln

(link) command to
make a shortcut


Symlinks

are blue, actual files are green


We can run the
symlink

as if it was the file itself


ln

-
s
real_file

symlink_name

Runlevels


0


Off (system halt)


1


Single
-
user mode (without networking)


‘Minimal’ boot


usually used for troubleshooting a broken
system


2


Single
-
user mode with networking


Same as above, but if you need network for some reason


3


Multi
-
user mode (no GUI; w/networking)


Standard ‘command line’ system


our VM’s


4


“Reserved” (not used)


5


Multi
-
user mode with GUI & networking


Everything and the kitchen sink


6


Reboot

The GUI!


Run the ‘
startx
’ command


Two ‘standard’ GUI’s


Gnome and KDE


Again,
Ubuntu

decided to go do their own thing


RHEL/
CentOS

default is Gnome


More Mac/Apple
-
like


More Windows
-
like is KDE


Best practice dictates NO GUI on servers


Gnome/KDE “backend” is based on X11 which is
very complex and is widely regarded as more
insecure

Gnome



Toolbar On Top


Menus,
Quicklinks
, Desktop Icons


Desktop icons


same as Windows


My Computer, Recycle bin, Folder Viewer


Quicklinks



hover over to show (similar to
Windows)


Internet, email, spreadsheet, doc, presentation


Menus


Applications, Places, System


Applications


Games, System Tools, Office, Internet


Connecting to the network (or your system)


Administration!

Who Remembers
Useradd
?



GUI Users



Useradd


Flags?


Shell, Home directory, user ID, group ID, etc…

Et all


Scripting!


How long does it take for a script to execute?


Especially with a username/password passed as
arguments?



How long does it take for you to tab through
each option and enter each item?

And Services (and more)!



Extra Credit!


One extra credit assignment


How would I use Linux &
Xen

to create a “cloud”?



Assume I have a computer with
CentOS

installed


What are the parts of
Xen

I need to install


How do I configure them?


How does everything talk to each other?


Why is this useful?


The point is to connect you with an “application”
and the “real world”

Practicals


Monday is Labor Day


You can come to class, but I won’t be here


Runlevel

questions are in interviews!


I failed one because I was on the L in Chicago and
he couldn’t understand me saying ‘zero’
vs

‘three’


(I SWEAR, IT WAS THE LONG E)


Ubuntu
/Google is messing with stuff, but no
other distributions have followed (yet)


Go forth, and gain practical experience