How to use ctags
A. build ctags
$ctags -R
B. tag search from vim
go to tag definition ctrl-]
go back to tag ctrl-t
list all definitions of a tag :ts <tag>
Screen advanced commands
ctrl a S -> create horizonally split screen
ctrl a | -> create horizonally split screen
ctrl a TAB -> switch between split screens
ctrl a Q -> Kill all regions but the current one
ctrl a X -> remove active window from split screen
iperf for throughput tests at varying packet rate/ size
https://iperf.fr/iperf-doc.php
$iperf --version
iperf version 2.0.13 (21 Jan 2019) pthreads
SERVER:
$ iperf -s -u -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 100.0.0.2 port 5001 connected with 100.0.0.1 port 60808
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 1.40 MBytes 11.8 Mbits/sec 0.002 ms 0/ 1000 (0%)
[ 3] 1.0- 2.0 sec 1.40 MBytes 11.8 Mbits/sec 0.012 ms 0/ 1000 (0%)
...
[ 3] 0.0-30.0 sec 42.1 MBytes 11.8 Mbits/sec 0.002 ms 0/30001 (0%)
CLIENT:
$ iperf -c 100.0.0.2 -u -b 1000pps -t 30
------------------------------------------------------------
Client connecting to 100.0.0.2, UDP port 5001
Sending 1470 byte datagrams, IPG target: 1000.00 us (kalman adjust)
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 100.0.0.1 port 60808 connected with 100.0.0.2 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-30.0 sec 42.1 MBytes 11.8 Mbits/sec
[ 3] Sent 30001 datagrams
[ 3] Server Report:
[ 3] 0.0-30.0 sec 42.1 MBytes 11.8 Mbits/sec 0.001 ms 0/30001 (0%)
netcat (nc) for TCP/ UDP traffic
http://linux.die.net/man/1/nc
Client side
nc -vn -s <local IP> <server IP> <server port>
e.g.
$ nc -vn -s 10.205.29.47 10.200.117.103 12345
(UNKNOWN) [10.200.117.103] 12345 (?) open
^C
Server side
nc -v -l –p <server port>
e.g.
$ nc -v -l -p 12345
listening on [any] 12345 ...
connect to [10.200.117.103] from client_FQDN [10.205.29.47] 55772
$
Mount file systems
Do following as super user:
1. edit /etc/fstab to add entries
2. do mount -a to have filesystems mentioned in fstab mounted
Do following for temporarily mounting a file system
mount -t cifs //ntserver/share /mnt/localdir -o "ro"
Creating a bootable USB Drive from ISO on Linux
1. Plug your USB drive into an available USB port on your system
2. Now run fdisk to see USB device and partitions. Be careful in identifying the USB device path. Otherwise a wrong device e.g. local hard disk might be overwritten! You can run the same fdisk command before inserting USB device to know pre-existing devices and and omit the old ones.
$sudo fdisk -l
<snip>
Disk /dev/sdc: 7.5 GiB, 8006901760 bytes, 15638480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2 15638479 15638478 7.5G b W95 FAT32
$
It will shows partition(s) of the device e.g. /dev/sdc1 is the only partition of device /dev/sdc.
3. Now run dd command to convert ISO to bootable
$sudo dd if=/home/regress/VMware-VMvisor-Installer-6.0.0-2494585.x86_64.iso of=/dev/sdc
713484+0 records in
713484+0 records out
365303808 bytes (365 MB) copied, 987.005 s, 370 kB/s
$
Note that the device path (dev/sdc) is given and not the partition path (/dev/sdc1). Also be patient because imaging the drive takes time. As the output above shows, it can take over ten minutes or more.
Compare kernel versions in a Linux shell script
Following script verifies if current kernel version is >= 3.10.
ker_ver_min=3.10
ker_ver_cur=$( uname -r )
ker_ver_max=$( echo -e "$ker_ver_min\n$ker_ver_cur" | sort -V | tail -n 1 )
if [ $ker_ver_cur -eq $ker_ver_max ]; then
echo "current version $ker_ver_cur is equal to or higher than expected version $ker_ver_min"
fi
Packet crafting tool based on python