|
| |
Displaying Routes
Routes can be displayed with netstat -rn
root@tpeccp01 # netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-----------------------------------------------------------------------------------
10.205.0.192 10.205.20.2 UG 1 0
10.205.0.224 10.205.20.2 UG 1 0
10.205.20.128 10.205.20.2 UG 1 0
10.205.20.0 10.205.20.10 U 1 0 ce0
10.205.19.128 10.205.19.143 U 1 23 ce1
10.128.2.0 10.128.2.14 U 1 24 ce2
10.132.52.0 10.128.2.1 UG 1 0
10.132.50.0 10.128.2.1 UG 1 0
10.132.49.0 10.128.2.1 UG 1 0
147.147.0.0 10.205.19.130 UG 1 0
147.150.0.0 10.205.19.130 UG 1 0
147.149.0.0 10.205.19.130 UG 1 22
147.148.0.0 10.205.19.130 UG 1 0
172.21.0.0 10.205.19.130 UG 1 0
10.0.0.0 10.205.19.130 UG 1 46
224.0.0.0 10.205.19.143 U 1 0 ce1
default 10.128.2.1 UG 1 77
127.0.0.1 127.0.0.1 UH 2 51 lo0
root@tpeccp01 #
Adding Static Routes
Static routes are appended to the /etc/init.d/inetinit file or can be added 'on-the-fly'
using same commands shown below, but syntax can vary with Unix flavour: -
#Static Routes
route add 10.0.0.0 -netmask 255.0.0.0 10.205.19.130
route add 147.147.0.0 -netmask 255.255.0.0 10.205.19.130
route add 147.148.0.0 -netmask 255.255.0.0 10.205.19.130
route add 147.149.0.0 -netmask 255.255.0.0 10.205.19.130
route add 147.150.0.0 -netmask 255.255.0.0 10.205.19.130
route add 172.21.0.0 -netmask 255.255.0.0 10.205.19.130
route add 10.205.20.128 -netmask 255.255.255.192 10.205.20.2
route add 10.205.0.192 -netmask 255.255.255.224 10.205.20.2
route add 10.205.0.224 -netmask 255.255.255.224 10.205.20.2
route add 10.132.49.0 -netmask 255.255.255.0 10.128.2.1
route add 10.132.50.0 -netmask 255.255.255.0 10.128.2.1
route add 10.132.52.0 -netmask 255.255.255.0 10.128.2.1
root@tpeccp01 #
route add -host 217.140.33.177 10.205.26.65
route add 10.1.1.0 -netmask 255.255.255.0 10.1.1.254
Interface Config Information
Interface information can be obtained using ifconfig -a
root@tpgend02 # ifconfig -a
lo0: flags=1000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
eri0: flags=1000843 mtu 1500 index 2
inet 10.128.4.10 netmask ffffff00 broadcast 10.128.4.255
ether 0:3:ba:17:fb:22
ge0: flags=1000843 mtu 1500 index 3
inet 10.205.19.6 netmask ffffffc0 broadcast 10.205.19.63
ether 0:3:ba:17:fb:22
hme0: flags=1000843 mtu 1500 index 4
inet 10.205.19.138 netmask ffffff80 broadcast 10.205.19.255
ether 0:3:ba:17:fb:22
or
# ifconfig lan0
lan0: flags=863
inet 194.101.1.50 netmask ffffff00 broadcast 194.101.1.255
Get the interface name from "netstat -i"
NB. If command is not found use …
root@tpgend02 # /usr/sbin/ifconfig -a
eg. Mask Change
Actions performed on "tpacgpd1" ...
/etc/netmasks
10.205.26.64 255.255.255.240 -> 10.205.26.64 255.255.255.224
tpacgpd1# ifconfig ce1 down
tpacgpd1# ifconfig ce1 10.205.26.77 netmask 255.255.255.224 up
tpacgpd1# ifconfig ce1
ce1: flags=1000843 mtu 1500 index 6
inet 10.205.26.77 netmask ffffffe0 broadcast 10.255.255.255
ether 0:3:ba:43:ff:89
e.g. IP Change
JHGSI-NOK01[admin]# ifconfig eth1c0 10.230.1.1 netmask 255.255.255.0
Ifconfig {interface}
e.g.
ifconfig ce1 down
ifconfig ce1 unplumb
ifconfig ce1 10.205.26.81 netmask 255.255.255.224
ifconfig ce1 plumb
ifconfig ce1 up
Resolve.conf File
Resolv.conf File
The following is the /etc/resolv.conf file for DNS to work :
domain acme.gov.uk
nameserver 151.176.242.171
nameserver 151.176.242.173
Nsswitch.conf File
Nsswitch.conf File
Host will search for a name according to the sequence in Nsswitch.conf, So need
to ensure that the following line in the /etc/nsswitch.conf file includes "dns":
hosts: files dns
Default.router File
Default.router File
The default router is detailed in the /etc/default.router file.
Unix Config Files
Unix Config Files
/etc/netmasks
/etc/hostname.XX (x3)
/etc/hosts
/etc/rc2.d/S99routes
/etc/resolv.conf - if configured
/etc/nsswitch.conf - if configured
/etc/passwd
/etc/shadow "
Show OS version on Unix system
Show OS version on Unix system
uname -a
root@tpgend02 # uname -a
Show time on Unix system
Show time on Unix system
date
[root@localhost mark]# date
Wed Nov 15 23:47:44 GMT 2000
Show system uptime on Unix system
Show system uptime on Unix system
uptime
[root@localhost mark]# uptime
11:46pm up 53 min, 1 user, load average: 0.00, 0.00, 0.00
Show diskspace for volumes in system
Show diskspace for volumes in system
(Commands depend on Unix flavour)
df
df -P or df -v (shows % used etc)
du -k (shows disk space of current directory)
[root@localhost mark]# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda8 256667 63794 179621 27% /
/dev/sda1 23302 7825 14274 36% /boot
/dev/sda6 1778840 187132 1501344 12% /home
/dev/sda5 1778840 1360488 327988 81% /usr
/dev/sda7 256667 30671 212744 13% /var
Searching for a file in Unix
Searching for a file in Unix
find /.. -name protocols
Searches from the top level directory downwards for the specified file.
[root@localhost mark]# find /.. -name fstab
/../usr/lib/linuxconf/help.de/fstab
/../usr/lib/linuxconf/help.eng/fstab
Mounting a CD-Rom in Unix
Mounting a CD-Rom in Unix
mount /mnt/cdrom {assuming cd device is called cdrom, which is the default}
cd /mnt/cdrom
Floppy disks on Unix
Floppy disks on Unix
Normally Unix formats floppies in the "ext2" system, as opposed to DOS using "vfat"
(V7.0 Redhat auto-sence file system on floppy see below).
[root@localhost mark]# more /etc/fstab
LABEL=/ / ext2 defaults 1 1
LABEL=/boot /boot ext2 defaults 1 2
LABEL=/home /home ext2 defaults 1 2
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
LABEL=/usr /usr ext2 defaults 1 2
LABEL=/var /var ext2 defaults 1 2
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/sda9 swap swap defaults 0 0
In order to change this default edit /etc/fstab ....from...
/dev/fd0 /mnt/floppy ext2 noauto,owner
to....
/dev/fd0 /mnt/floppy vfat noauto,owner
Mounting a DOS formatted floppy (if not auto-sensing)
[root@localhost doc]# mount -t vfat /dev/fd0 /mnt/floppy
[root@localhost doc]# cd /mnt/floppy
[root@localhost floppy]# ls -l
total 801
-rwxrwxr-x 1 root root 112128 Sep 20 16:58 ATTSQNYN#2.doc
-rwxrwxr-x 1 root root 19968 Nov 6 16:52 Analysis Info.doc
-rwxrwxr-x 1 root root 617984 Nov 7 10:15 BBG Analysis Report.doc
-rwxrwxr-x 1 root root 858 Nov 6 01:19 bbemail.txt
-rwxrwxr-x 1 root root 16735 Oct 25 19:40 bill.txt
-rwxrwxr-x 1 root root 50688 Oct 25 19:39 bill.txt.doc
-rwxrwxr-x 1 root root 736 Oct 20 16:07 kk
-rwxrwxr-x 1 root root 508 Oct 20 16:08 kkk
[root@localhost floppy]#
Unmounting a DOS Formatted floppy
[root@localhost floppy]# umount -t vfat /dev/fd0
umount: /mnt/floppy: device is busy
[This is because my PWD is is still on the device, so must move PWD away so as to
release the device, as shown below.]
[root@localhost floppy]# cd /home/mark
[root@localhost mark]# umount -t vfat /dev/fd0
[root@localhost mark]#
Unpacking 'tar' and '.Z' files
Unpacking 'tar' and '.Z' files
To unpack a 'tar' file
tar xvf filename
To unpack a '.Z' file
/usr/bin/zcat filename
If the file is both a 'tar' and '.Z', e.g..
maint1-cam23-hpux_tar.Z
Then both commands can be used with the pipe command e.g.
/usr/bin/zcat maint1-cam23-hpux_tar.Z | tar xvf
VI Editor Commands
VI Editor Commands
Cursor Movement Editing Commands
j Move cursor down o Open new line below current line
k Move cursor up O Open new line above current line
h Move cursor left r Replace character under cursor
l Move cursor right R Overtype characters
CTRL-G Display current line number i Insert text before cursor
nG Move to line number n a Insert text after cursor
G Move to last line in file I Insert text at beginning of line
:n Move to line number n A Insert text at end of line
J Join two lines
u Undo last edit
U Restore current line
Cut & Paste Exit Commands
x Delete char under char ZZ Write (save) and quit file
dd Delete line :x Write (save) and quit file
D Delete to end of line :wq! Write (save) and quit file
p Put dele/yanked text after cursor :q! Quit file (discarding any changes)
P Put dele/yanked text before cursor
ym Yank (copy) text block (defined by mark)
yy,Y Yank current line
Esc Exits back to command mode / pattern Search for pattern
: Follows Esc to issue further commands
CTRL-L Redraw screen :! cmd Give Unix command
CTRL-R Redraw screen :r ! cmd Read output of Unix cmd into current file
Unix Scripts
Unix Scripts
After writing a text script file the 'x' (for execute) flag may need to be enabled before it will run.
# ./auto
sh: ./auto: Execute permission denied.
# chmod +x auto
# ./auto
To debug a script
# sh -x auto
+ nwg
auto[2]: nwg: not found.
+ show int
auto[3]: show: not found.
auto[4]: Syntax error at line 4 : `|' is not expected.
Editing .profile file
Editing .profile file
The .profile file is run when a user logs in and is used to set environmental variables etc.
Eg.
NMSROOT=/opt/Cisco/CSCOcwsi_opt
Export NMSROOT
Redhat Linux Notes
Redhat Linux Notes
Cartman config: -
Display: -
X Display setup :- use Xconfigurator from root account-----> writes file /etc/x11/xf86config
Checkout: - /usr/X11R6/lib/X11/doc/README.Config
"ctrl, alt & +" - switches different screen fonts/resolutions
"ctrl, alt & Backspace" - exits
Disks: -
Device mount points: -
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda8 256667 63794 179621 27% /
/dev/sda1 23302 7825 14274 36% /boot
/dev/sda6 1778840 187132 1501344 12% /home
/dev/sda5 1778840 1360488 327988 81% /usr
/dev/sda7 256667 30671 212744 13% /var
AWK Script
AWK Script
#!/bin/sh
# +<<< Open source trace file >>>+
#
cat wkfile.txt | while read a
do
#
# +<<< Read source file a line at a time >>>+
#
w=`echo $a | awk '{print $1, $2}'`
#
if [ "$w" = "Protocol =" ]
then
pro=`echo $a | awk '{print $5}'`
string=$pro
#
elif [ "$w" = "Source Address" ]
then
sad1=`echo $a | awk -F. '{print $1}' | cut -c17-19`
sad2=`echo $a | awk -F. '{print $2}'`
sad3=`echo $a | awk -F. '{print $3}'`
sad4=`echo $a | awk -F. '{print $4}' | cut -c1-3`
sad="$sad1.$sad2.$sad3.$sad4"
string="$string,$sad"
#
elif [ "$w" = "Destination Address" ]
then
dad1=`echo $a | awk -F. '{print $1}' | cut -c22-24`
dad2=`echo $a | awk -F. '{print $2}'`
dad3=`echo $a | awk -F. '{print $3}'`
dad4=`echo $a | awk -F. '{print $4}' | cut -c1-3`
dad="$dad1.$dad2.$dad3.$dad4"
string="$string,$dad"
#
elif [ "$w" = "Source Port" ]
then
spo=`echo $a | awk '{print $4}'`
string="$string,$spo"
#
elif [ "$w" = "Destination Port" ]
then
dpo=`echo $a | awk '{print $4}'`
string="$string,$dpo"
#
# +<<< Display to screen >>>+
#
echo $string
#
fi
#
if [ "$dpo" != "" ]
then
echo $string >> convs
#
# +<<< Clear string values >>>+
#
dpo=""
spo=""
dad=""
sad=""
pro=""
#
fi
done
#
# +<<< Sort file to remove duplicates >>>+
#
cat convs | sort -u > convs_sorted
#
# +<<< Remove any spaces in data >>>+
#
tr -d [:blank:] < convs_sorted > data.txt
rm convs*
|