1 networking c shell programming. 2 network services zhaving your systems available over a network...
TRANSCRIPT
1
NetworkingC Shell Programming
2
Network Services
Having your systems available over a network is required for most businesses today
Providing those services is the task of the System Administrator
3
Network Services
How do your users connect to your systems tera term telnet rlogin rcp ftp
4
Type of Networks
broadcast each system examines the address of every
message and picks up its own i.e. Ethernet can be CSMA/CD or CSMA/CA
token ring only one system transmits at a time i.e. FDDI
point-to-point only two endpoints most connections to WANs are point-to-point
5
Internetworking
Gateways devices that switch packets between different
physical networks deciding which gateway to use is called
routing
Routers a device that filters traffic based on IP address
Bridges a device that filters traffic based on ethernet
address
6
Network Protocols
TCP/IP Transmission Control Protocol/Internet
Protocol Not based on OSI model, has a 4 layer model
UDP - User Datagram Protocol Alternate layer above IP, less robust than TCP NFS is based on UDP
XNS (Xerox Network Software)DECnet (DEC Network)Can coexist on the same network or even
the same computer...
7
Unix Network Services
Seven layer model - OSI Reference Model Application Presentation Session Transport Network Data Link Physical
8
Communicating on the Network
use the hostname command to find the identity of your local system#hostname -saries
uname -a will show hostname, domain name and version of operating system#uname -aSunOS poincare 5.6 Generic_105181-11 sun4u sparc
SUNW,Ultra-1
9
Communicating on the Network
finger used to learn about remote users finger @aries
shows info about all users logged onto host aries
finger dbittrol@airesshows info about the user dbittrol on host
aries only works if the site is running the
appropriate software (the finger daemon)
10
Communicating on the Network
mail and mailx most commonly available email software create, send and receive email front end to sendmail daemon you need to know address considered by some to be difficult to use
...actually these programs are just very basic...and command line oriented
11
Host Addresses
most common is IP addresses four octets separated by periods 192.192.192.2 Will talk about more in Sys Admin classes
Network Information Center (NIC) hands out blocks of addresses to organizations each organization assigns individual addresses
12
Host Addresses
Typically.... 131.251.252.253 131.251 represents campus/company 252 represents subnetwork 253 represents individual equipment Example is a Class B Address
range for each octet is 0 to 255symbolic names can be associated
with each IP address
13
Host Addresses
127.0.0.1 is reserved for localhost name hook for network software when no
network is actually available.more efficient name services include...
DNS (Domain Name Service) NIS (Network Information Service) NIS+
14
Host Addresses
oldest (and simplest) name service is /etc/hosts file127.0.0.1 localhost192.168.3.8 aries loghost192.168.3.12 linux01192.168.3.251 matthew
15
Network Utilities
rlogin and telnet provide ability to connect to a remote host
over the network and start a login session there.
you must have an account on the remote system to gain access
rlogin assumes your user name at loginif your rhost allows, no password needed
telnet asks for user name at login telnet also works with non-UNIX systems
and has more configuration options
16
Network Utilities
Tera Term (Pro) is a free software terminal emulator (communication program) for MS-Windows. It supports VT100 emulation, telnet connection, serial port connection, and so on.
Reflection connectivity software establishes and maintains communications between your computer and a host computer . This software allows your computer to operate like a Digital VT terminal.
17
Trusted Hosts
Some commands only work if the remote system trusts your local computer like rcp and rsh trusted systems are listed in /etc/hosts.equiv
Often not allowed due to security
can also use .rhosts in your home directorybeware - using .rhosts allows another user to log in
as you on a remote system, without knowing your password!!!
18
Transferring Files
rcp (remote copy) works like cp (but only for Trusted Hosts) copy between systems without logging in examples
rcp memo.921 bravo:memo.921• copies from home directory on current system to
home directory on bravorcp memo.921 watson@bravo:memos
• if memos exists as directory then memo.921 is copied into it - if not memo.921 is copied to file memos
19
Transferring Files
ftp (file transfer protocol) an interactive program use commands like:
binary, ascii, promptput, get, mput, mgetcd, lshelp, quit
20
Commands
rsh (remote shell) run a command on a remote system without
logging in (see Trusted Hosts)will prompt for your password if the local host is not
trustedlocal host gets standard out from remote hostspecial characters on command line are interpreted by the
local hostrsh bravo ls -Fla - list home dir on remote hostrsh bravo - start shell on remote host
traceroute - you provide IP or full name and the route from your machine to the system named is shown
21
Testing Network Connection
ping - sends a test packet to a remote system which then sends back a reply
# /usr/sbin/ping matthewmatthew is alive# /usr/sbin/ping -s matthewPING matthew: 56 data bytes64 bytes from matthew (192.168.3.251): icmp_seq=0. time=1. ms64 bytes from matthew (192.168.3.251): icmp_seq=1. time=0. ms64 bytes from matthew (192.168.3.251): icmp_seq=2. time=0. ms64 bytes from matthew (192.168.3.251): icmp_seq=3. time=0. ms----matthew PING Statistics----4 packets transmitted, 4 packets received, 0% packet lossround-trip (ms) min/avg/max = 0/0/1- end with <ctrl>-c
22
Domain Name Service (DNS)
a distributed servicename servers around the world
cooperate to keep the database up to date
no one system has a complete copy organized hierarchically local name server knows local hosts and how to contact other name servers
23
DNS
Seven original top level domains countries outside U.S. use ISO country
codeau for Australia, ja for Japan
inside U.S. the other six are:• .com commercial enterprises• .edu educational institutions• .gov nonmilitary government agencies• .mil military government agencies• .net networking organizations• .org other (often nonprofit) organizations
24
DNS
New TLDs started coming online late 2001 .biz .info .name .museum .coop .aero .pro
25
DNS
some examples the same host name can be used by two
completely different systems!okeefe.berkeley.edu
• host okeefe at University of California
okeefe.mma.org• host okeefe at Museum of Modern Art
NOTE: DNS is not case-sensitive
26
DNS
most common interface is BIND software Berkeley Internet Name Domain translates host name <=> ip address follows client/server model client looks to name server to resolve host
ip addressesnslookup - interface to any DNS server
DNS Server resolving, name and ip
27
Network Information Service (NIS)
developed by Sun Microsystems to help simplify network administration
formerly called Yellow Pages (yp) hence, commands like....
ypcat - display NIS database tableypmatch - search NIS database tableetc... etc...
used in addition to /etc system config fileswhich now only contain minimum info
28
Network File System (NFS)
work locally with files that are stored on a remote system’s disks
remote file system appears to be localremote system acts as serverlocal system acts as clientusers mount dirs from other systems
on their systems to use. Can “automount”
df command (display filesystems)
29
example output of df
aries% df/ (/dev/dsk/c0d0s0 ): 106980 blocks 85665 files/usr (/dev/dsk/c0d0s6 ): 17590 blocks 30931 files/proc (/proc ): 0 blocks 958 files/dev/fd (fd ): 0 blocks 0 files/export (/dev/dsk/c0d0s3 ): 1415974 blocks 498944 files/usr/openwin (/dev/dsk/c0d0s4 ): 59752 blocks 68067 files/tmp (swap ): 114808 blocks 11689 files/cdrom/devpro_v5n1_intel(/vol/dev/dsk/c1d0/devpro_v5n1_intel): -1 blocks -1 files
aries% df -kFilesystem kbytes used avail capacity Mounted on/dev/dsk/c0d0s0 159919 106429 37500 74% //dev/dsk/c0d0s6 91039 82244 0 100% /usr/proc 0 0 0 0% /procfd 0 0 0 0% /dev/fd/dev/dsk/c0d0s3 1013807 305820 606607 34% /export/dev/dsk/c0d0s4 137631 107755 16116 87% /usr/openwinswap 57416 12 57404 1% /tmp/vol/dev/dsk/c1d0/devpro_v5n1_intel 234370 -1 0 100% /cdrom/devpro_v5n1_intel
From Aries(Solaris)
30
AFS File System
created at Carnegie Mellon University - hence name “Andrew File System”
commercially available from Transarcprovides ability for few sys admins to
administer hundreds of systemsprovides virtual file system,
transparent to users, looks like one big tree
31
AFS File System (cont)
provides enhanced security on top of Unix rwlidka
read, write, lookup, insert, delete, lock, admin
On every directory (not file level) Permissions granted to users or groups of
users Overlays Unix owner permissions
Unix group and other permissions are ignored
User obtains a data structure called a “token” to authenticate themselves
32
DFS File System
Distributed File System - follow on to AFS
Added more layers of permissions Mask for files created in a dir Another mask for dirs created in a dir Very hard to manage permissions
New versions of AFS are now being made available
33
C Shell
The Bourne shell and the C shell are not compatible syntactically Both interactive commands and shell
scripts differThe aim was to allow users to easily
substitute custom programs for existing UNIX commands
Made the syntax for shell scripts similar to that of the C programming language
34
C Shell
When you are using the C shell your prompt should either be $ or % $ standard shell % C shell
C shell has special files you can use to customize your working environment .login #For things that you want active during current
login .cshrc#Defines special characteristics local to a shell .logout #What happens when you log off the
system
35
Built-in Commands
history set history = 20 history will list out last # of commands
(but not history command) !! repeats last command !4 repeats 4th command
36
Built-in Commands
alias is an abbreviation for a frequently used command alias h history would set up h alias dir ls –l if you liked your old DOS
commands like dir
37
Built-in Commands
Some that are built into the C-shell are:
bg cd setecho exec stopexit fg suspendglob jobs umaskkill notify unalias
38
C-Shell
Filename completion (must be turned on) set filec (this turns it on, you must be in
csh) cat myrpt [press ESC key not Enter] Will look for a match for myrpt, it will display
the remainder of the file name (if it’s unique) so you can press enter to run the command. If the match isn’t found then it will do nothing. Sometimes you need to type in more of the file name to get a unique match
39
C-Shell
~ represents your home directory du ~ > disk_info&
Pattern matching (BSD only) =~ match !~ does not match
40
.login
stty - set terminal command will show your current terminal settings
to change your settings type in:
stty erase ^h
stty kill ^x
stty intr DEL
41
.login
env is established from hereUse setenv to declare
setenv TERM vt100.login should include anything you
want executed once
42
.cshrc
Is invoked each time you start up a new C shell
Used to establish variables and parameters that are local to a specific shell
It is not required that there is a .cshrc file
43
.logout
Runs when you end your sessionYou can use it to clean up
directories, track your sessions etc.This is a file you can create (not
required by the system)
44
C Shell
To do the equivalent of a read command you would do the following: set variablename =$<
To display a string of data to the screen use the echo command such as: echo “Hello World!”
45
C Shell - If Constructs
You’ll find that script syntax differs from what you used in the bash, bourne or ksh environments
If statements do not end in fi, etc.
46
C Shell - If Constructs
1. if (expression) command2. if (expression) then
command(s) endif
3. if (expression) then command(s)
else command(s)
endif
47
C Shell - If Constructs
4. if (expression) then command(s)
else if (expression) then command(s)
else command(s) endif
48
C Shell - goto
Has the formgoto wordword:for examplegoto errerr:
exit 1
49
C Shell -Foreach
Allows script to process a set number of items placed in a listforeach person ( ann bruce tim sam deb)
echo “Dear $person.\You are cordially invited to a
Welcome luncheon for our new employee, Jane Doe” | mail $personend
50
C Shell – While Loop
While loop handles situations where the number of iterations is not know in advance. This loop terminates when the controlling expression becomes false.
while (expression)command(s)
end
51
C Shell - Switch
Used when a variable can take a wide variety of values
Can replace a long sequence of if-then-else statements
Used similar to C++
52
C Shell - Switch
switch (string)case pattern1:
command(s)breaksw
case pattern2:command(s)breaksw
default:command(s)breaksw
endsw
53
C Shell - Interrupts
break causes execution to resume after the end statement of the innermost loop
continue makes the shell skip the rest of the commands within the innermost loop and resume execution just before the end statement
54
C-Shell
The source command causes the current C Shell to execute a shell script given as its argument. The source command expects a C Shell script so no leading pound sign is required in the script.
The current shell executes source so the commands such as set will affect the current shell (I.e; % set history = 100)
After you make changes to the .cshrc or .login file, you can use source to execute it from within the login shell in order to put the changes into effect. i.e.; % source .cshrc
55
find
You’ve used which and whereis to find paths
But these only search a few pathsUse find
find / -name vi -print