Cheatsheets
All posts tagged Cheatsheets
Today, was working on iptables, and accidently mistyped and typed in iptab
..well found a pretty nifty tool. Nothing fancy but should save me from using google to look up CIDR info
+———————————————-+
| addrs  bits  pref  class mask           |
+———————————————-+
|Â Â Â Â 1Â Â Â Â Â 0Â Â Â /32Â Â Â Â Â Â Â Â Â 255.255.255.255 |
|Â Â Â Â 2Â Â Â Â Â 1Â Â Â /31Â Â Â Â Â Â Â Â Â 255.255.255.254 |
|Â Â Â Â 4Â Â Â Â Â 2Â Â Â /30Â Â Â Â Â Â Â Â Â 255.255.255.252 |
|Â Â Â Â 8Â Â Â Â Â 3Â Â Â /29Â Â Â Â Â Â Â Â Â 255.255.255.248 |
|Â Â Â 16Â Â Â Â Â 4Â Â Â /28Â Â Â Â Â Â Â Â Â 255.255.255.240 |
|Â Â Â 32Â Â Â Â Â 5Â Â Â /27Â Â Â Â Â Â Â Â Â 255.255.255.224 |
|Â Â Â 64Â Â Â Â Â 6Â Â Â /26Â Â Â Â Â Â Â Â Â 255.255.255.192 |
|Â Â 128Â Â Â Â Â 7Â Â Â /25Â Â Â Â Â Â Â Â Â 255.255.255.128 |
|Â Â 256Â Â Â Â Â 8Â Â Â /24Â Â Â Â Â 1CÂ 255.255.255.0Â Â |
|Â Â 512Â Â Â Â Â 9Â Â Â /23Â Â Â Â Â 2CÂ 255.255.254.0Â Â |
|Â Â Â 1KÂ Â Â Â 10Â Â Â /22Â Â Â Â Â 4CÂ 255.255.252.0Â Â |
|Â Â Â 2KÂ Â Â Â 11Â Â Â /21Â Â Â Â Â 8CÂ 255.255.248.0Â Â |
|Â Â Â 4KÂ Â Â Â 12Â Â Â /20Â Â Â Â 16CÂ 255.255.240.0Â Â |
|Â Â Â 8KÂ Â Â Â 13Â Â Â /19Â Â Â Â 32CÂ 255.255.224.0Â Â |
|Â Â 16KÂ Â Â Â 14Â Â Â /18Â Â Â Â 64CÂ 255.255.192.0Â Â |
|Â Â 32KÂ Â Â Â 15Â Â Â /17Â Â Â 128CÂ 255.255.128.0Â Â |
|Â Â 64KÂ Â Â Â 16Â Â Â /16Â Â Â Â Â 1BÂ 255.255.0.0Â Â Â Â |
|Â 128KÂ Â Â Â 17Â Â Â /15Â Â Â Â Â 2BÂ 255.254.0.0Â Â Â Â |
|Â 256KÂ Â Â Â 18Â Â Â /14Â Â Â Â Â 4BÂ 255.252.0.0Â Â Â Â |
|Â 512KÂ Â Â Â 19Â Â Â /13Â Â Â Â Â 8BÂ 255.248.0.0Â Â Â Â |
|Â Â Â 1MÂ Â Â Â 20Â Â Â /12Â Â Â Â 16BÂ 255.240.0.0Â Â Â Â |
|Â Â Â 2MÂ Â Â Â 21Â Â Â /11Â Â Â Â 32BÂ 255.224.0.0Â Â Â Â |
|Â Â Â 4MÂ Â Â Â 22Â Â Â /10Â Â Â Â 64BÂ 255.192.0.0Â Â Â Â |
|Â Â Â 8MÂ Â Â Â 23Â Â Â Â /9Â Â Â 128BÂ 255.128.0.0Â Â Â Â |
|Â Â 16MÂ Â Â Â 24Â Â Â Â /8Â Â Â Â Â 1AÂ 255.0.0.0Â Â Â Â Â Â |
|Â Â 32MÂ Â Â Â 25Â Â Â Â /7Â Â Â Â Â 2AÂ 254.0.0.0Â Â Â Â Â Â |
|Â Â 64MÂ Â Â Â 26Â Â Â Â /6Â Â Â Â Â 4AÂ 252.0.0.0Â Â Â Â Â Â |
|Â 128MÂ Â Â Â 27Â Â Â Â /5Â Â Â Â Â 8AÂ 248.0.0.0Â Â Â Â Â Â |
|Â 256MÂ Â Â Â 28Â Â Â Â /4Â Â Â Â 16AÂ 240.0.0.0Â Â Â Â Â Â |
|Â 512MÂ Â Â Â 29Â Â Â Â /3Â Â Â Â 32AÂ 224.0.0.0Â Â Â Â Â Â |
| 1024MÂ Â Â Â 30Â Â Â Â /2Â Â Â Â 64AÂ 192.0.0.0Â Â Â Â Â Â |
| 2048MÂ Â Â Â 31Â Â Â Â /1Â Â Â 128AÂ 128.0.0.0Â Â Â Â Â Â |
| 4096MÂ Â Â Â 32Â Â Â Â /0Â Â Â 256AÂ 0.0.0.0Â Â Â Â Â Â Â Â |
+———————————————-+
To copy fields 3 and 7 from input to output (3 string, 7 float):
awk ‘{printf”%s\t%10.4f\n”, $3, $7}’ < input > output
———-
To add a column of numbers:
awk ‘{sum=sum+$1;printf(“sum: %d\n”, sum)}’ < input | tail -1
———-
To calc the average of numbers in a file:
egrep “^:2″ *out | egrep total | cut -c44- | \
awk ‘{sum += $1;total += 1;printf”avg = %.4f\n”, sum/total}’ | \
tail -1
———-
To find ‘word’ in files owned by ‘username’ from location ‘.’:
find . -user username -print -exec \grep word ‘{}’ \; > output &
———-
To find all files that do not end in ‘pdb’ in location ‘.’:
find . \( ! -name \*pdb \) -print
———-
To find all files that do not end in ‘pdb’ in location ‘.’ and execute a
command on each file found:
find . \( ! -name \*pdb \) -exec \anneal2pdb ‘{}’ \;
———-
To remove all files ‘garb’:
find ~ -name garb -print -exec \rm ‘{}’ \;
———-
To report the file size of all files bigger than 2 meg and older than 30
days.
find . -type f -size +4096 -atime +30 -exec \du -sk ‘{}’ \;
———-
To search with a wildcard:
find . -name goob\* -print
———-
To manually nudge NFS:
umount /iris1/a (or whatever)
mount -a -t nfs
exportfs -a -v
———-
To encrypt the file ‘input’ to a file ‘output’:
crypt < input > output
enter key: (enter a password)
To decrypt the file ‘output’ to a file ‘done’:
crypt < output > done
enter key: (enter the password used to encrypt ‘output’)
———-
To convert tabs to spaces:
expand -tabstop filename.in > filename.out
eg
expand -3 garb > garb.out
will convert tabs to three spaces
To convert spaces to tabs:
unexpand filename
———-
To check the print que:
lpq
To remove a print job:
lprm <job # from lpq>
To check the printer:
lpc
———-
To remove duplicate lines from a file:
uniq filename > out
———-
To mail to compuserve:
If the username is ‘70000,200’, mail to:
mail 70000.200@compuserve.com
note the period instead of the comma.
To mail from compuserve:
>INTERNET Loopy@cup.portal.com
———-
To create a text file from a manual page:
man command | expand > file
vi file
:1,$s/.^V^H//g
😡
———-
To compare two files:
Flags 1, 2, or 3 suppress printing of the corresponding column. Thus
comm -12 prints only the lines common to the two files; comm -23 prints
only lines in the first file but not in the second; comm -123 prints
nothing.
———-
To run a string of commands over and over:
csh> sh
$ while :
> do
> command
> command
> done
When done, ^C to quit. ^D to return to csh.
———-
To get a list of ‘fsu.edu’ machines:
UNIX> nslookup
> ls fsu.edu > file
> exit
———-
To get a machine name from an IP address:
UNIX> nslookup
> set type=ptr
> 34.12.186.128.in-addr.arpa
Server: magnet.fsu.edu
Address: 146.201.250.2
34.12.186.128.in-addr.arpa name = weirdscience.chem.fsu.edu
———-
To add line numbers to the beggining of a file:
grep -n . input > output
or
paste x y > z
———-
To move (or copy) a directory heirarchy:
cd fromdir
tar cf – . | (cd todir; tar xfBp -)
———-
To copy a directory heirarchy exactly:
cd fromdir; tar cBf – . | (cd todir; tar xpBf -)
———-
To restart the sendmail process:
kill the original process
/usr/lib/sendmail -bd -q1h
———-
To alias rm so that it lists the files to be removed and asks for
confirmation:
alias rm \
‘/bin/ls -AsF \!* && echo -n “Remove? ” && if ($< == y) /bin/rm -rf \!*’
———-
To remove blank lines from a file:
sed -e ‘/^$/d’ file.in > file.out
———-