lecture
in color
/etc/rc.d/rc and sub-scripts in /etc/rc.d/rc?.d/S*
init: /etc/inittab.
inetd: /etc/inetd.conf (or /etc/inet/inetd.conf).
cron: /var/spool/cron/, /etc/cron.d/.
/etc/inittabgetty: accept login.
S0:2345:respawn:/sbin/getty ttyS0 DT9600 vt100 || | | | | | | ^^^^^^^^^^^^^^^^^^ command line arguments || | | | | ^^^^^^^^^^^ name of daemon || | | ^^^^^^^ action if it dies || ^^^^ run levels that invoke it ^^ name
getty on ttyS0, 9600 baud, emulating a vt100.
/etc/gettytab for details on DT9600.
prefdm: X display manager
x:5:respawn:/etc/X11/prefdm -nodaemon | | | | | | ^^^^^^^^^ arguments | | | | ^^^^^^^^^^^^^^^ command | | ^^^^^^^ restart if dies | ^ run level 5 only ^ name
-nodaemon: don't detach console (helps init know when to restart it)
kill -HUP 1 (or kill -1 1: instructs init to re-read its databases
and change the state of its daemons (either stopping
or starting them, as appropriate to your run-level).
-HUP: send a hangup signal.
1: process ID of init (always).
HUP signals this way.
inetd.confinetd is the internet meta-daemon.
inetd.conf
telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd | | | | | | | | | | | | ^^^^^^^^^^ name of daemon | | | | | | | | | | ^^^^^^^^^^^^^^^^^^^^ true path of daemon | | | | | | | | ^^^^ what user | | | | | | ^^^^^^ what to do after starting daemon | | | | ^^^ network layer to use | | ^^^^^^ type of network connection ^^^^^^ name of service (see /etc/services)
talk dgram udp wait root /usr/sbin/tcpd in.talkd | | | | | | | | | | | | ^^^^^^^^ name of daemon | | | | | | | | | | ^^^^^^^^^^^^^^ command to run | | | | | | | | ^^^^ what user to run as | | | | | | ^^^^ wait for completion before starting another | | | | ^^^ network layer to use | | ^^^^^ type of network connection ^^^^ name of service
tcp and udp: types of network connections.
stream and dgram (redundant)
wait and nowait: whether to wait to start another instance
wait: only one instance should run at a time.
nowait: run one instance per request.
This behavior must be programmed into the daemon.
/usr/sbin/tcpd aliased to in.talkd.
/etc/services/etc/services: describes what services are available by name
tcp:
telnet 23/tcp
^^^ protocol (tcp or udp) (see /etc/protocols)
^^ port number between 0-65535
^^^^^^ service name (same as first field of /etc/inetd.conf)
udp:
talk 517/udp
^^^ protocol (see /etc/protocols)
^^^ port number
^^^^ service name (same as first field of /etc/inetd.conf)
/etc/protocols/etc/protocols changes the numbers in a protocol headers to words
we can read.
tcp 6 TCP # transmission control protocol
udp 17 UDP # user datagram protocol
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comments
^^^ aliases
^^ protocol number
^^^ protocol name
/etc/protocols, /etc/services, /etc/inetd.conf are
simply ways of naming things so we can understand them.
tcp or udp)
/etc/inetd.conf, /etc/services)
netstat -a:
UDP
Local Address Remote Address State
-------------------- -------------------- -------
*.sunrpc Idle
*.* Unbound
...etc...
*.talk Idle
...etc...
TCP
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
-------------------- -------------------- ----- ------ ----- ------ -------
*.* *.* 0 0 0 0 IDLE
...etc...
*.telnet *.* 0 0 0 0 LISTEN
...etc...
Conbrio.EECS.Tufts.EDU.689 Conmoto.EECS.Tufts.EDU.nfsd 8760 0 8760 120 ESTABLISHED
...
Conbrio.EECS.Tufts.EDU.22 Louvre.EECS.Tufts.EDU.2571 7908 0 8760 0 ESTABLISHED
...
netstat translates between numbers and names.
Conbrio.EECS.Tufts.EDU.689 means ip 130.64.23.39 port 689
Conmoto.EECS.Tufts.EDU.nfsd means ip 130.64.23.38 port 2049
/etc/services!
Conbrio.EECS.Tufts.EDU.22 means ip 130.64.23.39 port 22 (ssh)
Louvre.EECS.Tufts.EDU.2571 means ip 130.64.24.90 port 2571
ssh lookup: not in /etc/services!
telnetd is listening for telnet.
telnetd with something else.
telnet is concerned.
tcpd program into the same directory as the daemon.
/etc/inetd.conf to call tcpd instead of the real daemon.
/etc/hosts.allow and /etc/hosts.deny to tell which daemons
to allow or deny access to. Most people just use hosts.allow.
/etc/inetd.conf:
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd(real telnet is
/usr/sbin/in.telnetd)/etc/hosts.allow:
in.telnetd : emerald.tufts.edu : banners /var/local/tcpd/banners/has-ssh : \ spawn (/usr/bin/logger -i -p daemon.notice denied %s to %u@%h) & : DENY in.telnetd : .eecs.tufts.edu : banners /var/local/tcpd/banners/warn : \ spawn (/usr/bin/logger -i -p daemon.notice warned %s to %u@%h) & : ALLOW in.telnetd : ALL : banners /var/local/tcpd/banners/warn : \ spawn (/usr/bin/logger -i -p daemon.notice warned %s to %u@%h) & : ALLOWTo wit:
emerald and tell them they're idiots for not using SSH!
eecs.tufts.edu but warn everyone about the dangers.
inetd, use /etc/rc.d/init.d/network
/etc/rc.d/init.d/network start
/etc/rc.d/init.d/network stop
inetd to re-read /etc/inetd.conf,
send it a HUP signal. kill -HUP 357.
croncron daemon handles repetitive scheduling.
/var/spool/cron/crontabs/*
conbrio:/var/spool/cron/crontabs/root:
10 3 * * 0 /usr/lib/newsyslog | | | | ^^^^^^^^^^^^^^^^^^ command to run | | | | ^ day of week: sun=0, sat=6 | | | * month number; *=all | | ^ day of month: *=all | ^ hour ^^ minuteThis says to run the script
newsyslog at 3:10 am every Sunday morning (the script copies /var/adm/messages to /var/adm/messages.1 and starts over with a blank messages file).0 0 1,10 * 1,2means to do something at midnight on the 1st and 10th of each month, as well as every monday and tuesday.
croncrontab: allows editing of your personal crontab.
crontab -e root: edit root's crontab.
setenv EDITOR emacs first or you'll end up in vi.
HUP'ing cron for you!
at: allows scheduling a job in the future of now.
andante% at 1am next week <stuff_to_dowhere
stuff_to_do consists of a list of the commands you want to execute. This allows you to do things when the system is less busy (and you're
asleep).
at -l: describes the jobs you're waiting to do.
at -r <jobid>: removes a job from the queue.
lecture
in color