Smartmon harddrive tools apt-get install smartmontools smartctl -i /dev/sda (check if it's supported) smartctl -s on /dev/sda (enable it) smartctl -t long /dev/sda (long test) smartctl -a -d ata /dev/sda (display results) badblocks -v /dev/sda1 > bad-blocks-result *************************************************************************************** MySql joins: An inner join retrieve the matched rows only. (requires condition: On clause) An outer join retrieve the matched rows from one table and all rows in other table A cross join matches every row from the first table with every row from the second table (does not allow conditions) Left: Matched rows in the right table and all rows in the left table Right: Matched rows in the left table and all rows in the right table or Full: All rows in all tables. It doesn't matter if there is a match or not ------------------------ A B - - 1 3 2 4 3 5 4 6 ------------------------ select * from a INNER JOIN b on a.a = b.b; select a.*,b.* from a,b where a.a = b.b; a | b --+-- 3 | 3 4 | 4 ------------------------ select * from a LEFT OUTER JOIN b on a.a = b.b; select a.*,b.* from a,b where a.a = b.b(+); a | b --+----- 1 | null 2 | null 3 | 3 4 | 4 ------------------------ select * from a RIGHT OUTER JOIN b on a.a = b.b; select a.*,b.* from a,b where a.a(+) = b.b; a | b -----+---- 3 | 3 4 | 4 null | 5 null | 6 ------------------------ select * from a FULL OUTER JOIN b on a.a = b.b; a | b -----+----- 1 | null 2 | null 3 | 3 4 | 4 null | 6 null | 5 ------------------------ tableA Cross Join tableB generates identical results to: tableA Inner Join tableB on 1 = 1 ------------------------ ------------------------ *************************************************************************************** to allow an ip in denied by fail2ban iptables -L -n -v --line-numbers (shows port#'s) chain fail2ban-ssh iptables -D fail2ban-ssh 1 fail2ban config = /etc/fail2ban/jail.conf email alerts sent to: destemail = root@localhost sendername = Fail2Ban mta = sendmail restart fail2ban= /etc/init.d/fail2ban restart *************************************************************************************** send a test email mail -s "Test Subject" grace@gmrbowden.com test body ctrl D echo "Test Body" | mailx -t "grace@gmrbowden.com" -s "Test subject" check file size of localmailboxes /var/spool/mail# ls -l tail -f /var/log/mail.log kill telnet window > ctrl ] > q *************************************************************************************** Pen Testing Kali / Security / Scan --------------------- **nikto -h IP-address --------------------- Metasploit commands: service postgresql start ss -ant msfdb init msfconsole db_status help show / help search db_nmap -v -sV IP-Address search type:exploit search CVE-XXXX-XXXX search cve:2014 search name:wordpress use exploit/path/to/exploit_name use exploit/multi/http/openx_backdoor_php use exploit/multi/http/php_utility_belt_rce use exploit/multi/http/phpmyadmin_3522_backdoor use exploit/multi/http/phpmyadmin_preg_replace use exploit/unix/webapp/php_eval use exploit/unix/webapp/php_include use exploit/unix/webapp/phpmyadmin_config use nop/php/generic use payload/php/exec use payload/php/reverse_php jobs -K (kills background jobs) show advanced show payloads show targets show options set RHOST 127.0.0.1 *check* run / exploit *************************************************************************************** netstat -lpn -- check listening ports netstat -apn -- check all ports Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 21148 2175K fail2ban-ssh tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22 1216 150K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 0 0 REJECT all -- * * 0.0.0.0/0 127.0.0.0/8 reject-with icmp-port-unreachable 1218K 140M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 11689 630K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 39168 2022K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 *************************************************************************************** To log into Perl: INBAND: Use fullnetwork-toi-v2vsd in intranet to get IP addresses and phone numbers. ssh (ip for box, and an ip for each serial port. 10.x.33.100- 103) username = Coleman pw is in userids.txt in Matrix or run OUTOFBAND: hyperterminal, putty or crt Dial the phone number using AT commands Same logins— SDS3M# (if no prompt, have customer unplug/re-plug RJ45 from Perle) ssh to IP (ADD PORT!) ssh 10.x.33.101 10001 ssh 10.x.33.102 10002 ssh 10.x.33.103 10003 to exit ctrl + A +enter *** Kill line X (x=serial line 1,2,or 3) hang up --- +++ then ATH *************************************************************************************** Bit Errors (since BERT started): 0 bits, Bits Received (since BERT started): 0 Kbits Bit Errors (since last sync): 0 bits Bits Received (since last sync): 0 Kbits errors are both equall which means that the smart jack has a problem if smartjack was working you would get bits recieved. TPAEAST01(config-controller)#do sh controllers t3 9/2/0/28 br T3 9/2/0 is up. Hardware is 4 ports CT3 SPA IO FPGA version: 0.0, HDLC Framer version: 0 T3/T1 Framer(1) version: 0, T3/T1 Framer(2) version: 0 SUBRATE FPGA version: 0.0 Applique type is Channelized T3/T1 No alarms detected. Framing is M23, Line Code is B3ZS, Clock Source is Line Equipment customer loopback T1 28 is down timeslots: 1-24 FDL per AT&T 54016 spec. Configured for FDL remotely line looped (bell) No alarms detected. Framing is ESF, Clock Source is Internal BERT test result (running) Test Pattern : 2^20-QRSS, Status : Not Sync, Sync Detected : 0 Interval : 5 minute(s), Time Remain : 1 minute(s) Bit Errors (since BERT started): 0 bits, Bits Received (since BERT started): 0 Kbits Bit Errors (since last sync): 0 bits Bits Received (since last sync): 0 Kbits TPAEAST01(config-controller)# Make sure to take the loop off the circuit when done!!! *************************************************************************************** sh protocols sh sessions sh process sh stacks TC413-1841#sh ip int br Interface IP-Address OK? Method Status Protocol FastEthernet0/0 10.192.113.3 YES NVRAM up up FastEthernet0/1 unassigned YES NVRAM up down FastEthernet0/1/0 unassigned YES unset up down FastEthernet0/1/1 unassigned YES unset up down FastEthernet0/1/2 unassigned YES unset down down FastEthernet0/1/3 unassigned YES unset up up Serial0/0/0 147.225.225.226 YES NVRAM down down Vlan1 10.255.240.98 YES NVRAM up up Loopback0 10.211.1.74 YES NVRAM up up Tunnel0 10.255.226.113 YES NVRAM up up TC413-2811#sh ip int br Interface IP-Address OK? Method Status Protocol FastEthernet0/0 10.192.113.2 YES NVRAM up up FastEthernet0/1 unassigned YES NVRAM administratively down down FastEthernet0/2/0 unassigned YES unset down down FastEthernet0/2/1 unassigned YES unset up down FastEthernet0/2/2 unassigned YES unset up down FastEthernet0/2/3 unassigned YES unset up down Serial0/0/0:0 68.139.80.58 YES manual up up Vlan1 unassigned YES NVRAM up down Loopback0 10.211.1.74 YES NVRAM up up *************************************************************************************** sh ver (look for) up time reg =0x2102 > if no DO NOT REBOOT sh hardware Cisco 2811 (revision 53.51) with 247808K/14336K bytes of memory. Processor board ID FHK0907F0DW 2 FastEthernet interfaces 1 Serial interface 1 Channelized T1/PRI port 1 Virtual Private Network (VPN) Module 4 Voice FXS interfaces DRAM configuration is 64 bits wide with parity enabled. 239K bytes of non-volatile configuration memory. 250880K bytes of ATA CompactFlash (Read/Write) sh int ser 0/0/0:0, MTU should = 1500 check counters at the bottom, should all be 0's if no > errors = prob w/ carrier clear counters if line up, protocol down > circuit is active but pvc’s are not (note which pvc’s, sh frame-relay pvc) sh controller t1, if output is blank = t1 serial card not found > reboot (sh ver-check 0x2102) counter errors = prob with Telco sh frame-relay pvc, if dialed into router and pvc’s are deleted > ATT changed config. active pvc’s are dlci’s #’s not in use deleted pvc’s are not setup on ATT’s side > notify ATT inactive pvc’s are unconfigured dlci’s from ATT > configs done by NOC tech’s check FECN and BECN, if this is not 0, this is telco/carrier issue sh frame-relay lmi if circuit is down router will send packets, but not receive > ATT problems with circuit config LMI Statistics for interface Serial0/0/0:0 (Frame Relay DTE) LMI TYPE = ANSI Invalid Unnumbered info 0 Invalid Prot Disc 0 Invalid dummy Call Ref 0 Invalid Msg Type 0 Invalid Status Message 0 Invalid Lock Shift 0 Invalid Information ID 0 Invalid Report IE Len 0 Invalid Report Request 0 Invalid Keep IE Len 0 Num Status Enq. Sent 582852 Num Status msgs Rcvd 582840 Num Update Status Rcvd 0 Num Status Timeouts 12 Last Full Status Req 00:00:34 Last Full Status Rcvd 00:00:34 sh voice call sum for Pilot, using 4 channels for Western Union machine(only uses one) 17,18,19,20 > should say em or fxsls onhook , if “park” state > phone is off hook and the line didn’t disconnect, or some other device is using the line. Have manager disconnect old equipment from router, check ports again. If they don’t clear reboot router > if still parked= wiring issue, assign to engineer. PORT CODEC VAD VTSP STATE VPM STATE ============== ======== === ==================== ====================== 0/0/0:1.17 - - - EM_ONHOOK 0/0/0:2.18 - - - EM_ONHOOK 0/0/0:3.19 - - - EM_ONHOOK 0/0/0:4.20 - - - EM_ONHOOK 0/1/0 - - - FXSLS_ONHOOK 0/1/1 - - - FXSLS_ONHOOK 0/1/2 - - - FXSLS_ONHOOK 0/1/3 - - - FXSLS_ONHOOK sh voice port sum should see dorm idle state unless call is in progress. if port says “seized” > problems with card or att have manager turn off router, reseat FXS card, power on router > if still seized, call att to check channels, if clear > bad card- cisco TAC PORT CH SIG-TYPE ADMIN OPER STATUS STATUS EC ============== == ============ ===== ==== ======== ======== == 0/0/0:1 17 e&m-imd up dorm idle idle y 0/0/0:2 18 e&m-imd up dorm idle idle y 0/0/0:3 19 e&m-imd up dorm idle idle y 0/0/0:4 20 e&m-imd up dorm idle idle y 0/1/0 -- fxs-ls up dorm on-hook idle y 0/1/1 -- fxs-ls up dorm on-hook idle y 0/1/2 -- fxs-ls up dorm on-hook idle y 0/1/3 -- fxs-ls up dorm on-hook idle y *************************************************************************************** clear counters sh int ser 0/0/0:0, check counters at the bottom, should all be 0's sh controller t1, check counters at the bottom, should all be 0's, if this is dirty and above is clean, problem with T1 card sh frame pvc, check FECN and BECN, if this is not 0, this is telco/carrier issue *************************************************************************************** CUCM Info and notes: info/facts *********************** originally developed for HP-UX, then Windows NT Windows 2000-based versions of CallManager 4.0, 4.1 and 4.2 CallManager 4.3 runs on Windows 2003 Cisco Unified CallManager 5.0 is Linux based Cisco Unified Communications Manager 6.0 merged linux and windows ************************ CUCM (Cisco Unified Communications Manager) tracks all active VoIP network components (phones). uses sccp to talk to phones. installed on mcs up to 12 for redundancy Cisco Unified Communications Manager Express (CUCME): Cisco IOS based IP-PBX call control and voice application features supports IP phones using SCCP and SIP PSTN connectivity options- digital and analog integrations with TAPI clients call distribution application Voicemail and Interactive voice response *********************** Skinny Client Control Protocol owned by cisco Examples of clients: Cisco 7900 series phones, and Cisco Unity voicemail server uses tcp/ip to/from ccm--- rtp/udp/ip to/from other clients. default name format for registered phones with CallManager is SEP -- (Selsius Ethernet Phone) -- followed by the MAC address. ************************ H.323 uses: ras - add resolution and admission control srv h.225 call signalling - establishes communication h245- opens and closes logical channels for audio, video, and data rtp- sending and receiving between devices. *********************** MGCP (Media Gateway Control Protocol): Call agent uses mgcp to tell gateway-- what events to report to call agent(off-hook or dialed numbers), how endpoints connect and what signals they use. Configured with list of Call agent (1 or 2 common) one main ca 2nd is backup. bkup ca reprograms mgcp *********************** snmpwalk -v2c -c public 192.168.10.4 .1.3.6.1.4.1.232.3.2.5 *********************** #!/bin/bash hosts=' 10.8.10.15 10.8.106.15 ... 10.8.82.15 10.8.96.15' for i in $hosts do echo "$i" >> lieberts.txt ping -c 1 $i | grep 100% >> lieberts.txt snmpwalk -v2c -c public $i system | grep sysName >> lieberts.txt echo "#########" >> lieberts.txt done *********************** #!/bin/bash airmon-ng stop ath0 wlanconfig ath create wlandev wifi0 ifconfig ath0 up *********************** #!/bin/bash USER="root" HOSTS=" 172.16.1.1 172.16.1.10 " getStats () { echo ssh $USER@$HOST "echo 'Server' && hostname && echo 'Disk space' && df -h | awk -F\" \" '{print \$5}' && echo 'Kernel' && uname -a | awk -F\" \" '{print\$3}' && echo 'Memory' && free -m | awk -F\" \" '{print \$2}'" } for HOST in $HOSTS do echo "*************************************************" echo "$(date)" echo "**************************************************" echo $HOST: $(getStats $HOST) echo "**************************************************" done #df -h | awk -F" " '{print $3,$5}' && uname -a | awk -F" " '{print $3}' *********************** #!/bin/bash function line(){ echo "*************************************************" } USER="root" HOSTS=" 172.16.1.51 " getStats () { ssh $HOST "rpm -qa | egrep '(openoffice|gimp)'" } for HOST in $HOSTS do line echo "$(date)" line echo $HOST: $(getStats $HOST) line done #df -h | awk -F" " '{print $3,$5}' && uname -a | awk -F" " '{print $3}' *********************** find . -type f -size +50000k | xargs du -sh *********************** #!/bin/bash USER="root" HOSTS=" 172.16.1.1 172.16.1.10 " getStats () { echo ssh $USER@$HOST "echo 'Server' && hostname && echo 'Disk space' && df -h | awk -F\" \" '{print \$5}' && echo 'Kernel' && uname -a | awk -F\" \" '{print\$3}' && echo 'Memory' && free -m | awk -F\" \" '{print \$2}'" } for HOST in $HOSTS do echo "*************************************************" echo "$(date)" echo "**************************************************" echo $HOST: $(getStats $HOST) echo "**************************************************" done #df -h | awk -F" " '{print $3,$5}' && uname -a | awk -F" " '{print $3}' *********************** mdadm -D /dev/md0 dmidecode //172.16.1.10/movies /movies cifs username=grace,password=***** 0 0 //172.16.1.10/grace /grace cifs username=grace,password=*****,uid=grace 0 0 *********************** voice codec-list CODECS codec g711alaw codec g711ulaw codec g729 inter fxs 0/4 voice user 9137358398 connect fxs 0/4 cos "global" password "*****" sip-identity 9137358398 T01 register auth-name "1- 6D3W0H" password "*******" sip-authentication password "****" modem-passthrough t38 t38 redundancy high-speed 3 t38 redundancy low-speed 2 codec-group CODECS improve call quality -change order of the codec -no echo cancelation (on voice user) -no modem-passthrough -impedance 600r (on fxs port) -remove T38 (from voice port) never use passthrough with this - also manually disable echo cancelation as well test sh voice quality-stats debug sip stack messages KJVFK-9YFC9-FD6D9-47H7H-6VBF4 Sip trunk user porting voice trunk T01 type sip sip-server primary 4.55.33.67 udp 5070 registrar primary 4.55.33.67 udp 5070 registrar expire-time 300 registrar max-concurrent-reg 2 conferencing-uri "t" domain "level3-voip.com" register 7192191505 auth-name "1-2VOTV" password encrypted "************************" register 7192191506 auth-name "1-2VOTV" password encrypted "************************" register 7192191507 auth-name "1-2VOTV" password encrypted "************************" register 7196333870 auth-name "1-2VOTV" password encrypted "************************" register 7199550237 auth-name "1-2VOTV" password encrypted "************************" register 7199550238 auth-name "1-2VOTV" password encrypted "************************" register 3038008052 auth-name "1-2VOTV" password encrypted "************************" codec-group CODECS default-ring-cadence internal tara forced a registration.... sip trunk force-reconnect or clear sip trunk will also clear the entire sip registration and let it come back this one is a pri handoff *********************** You enter history mode by typing ^r (hold control key and press the letter "r"). You will see something like this: (reverse-i-search)`': At this point, you type some part of the command you want to reuse. It doesn't have to be the first few letters either. If you recently edited your samba configuration file, try "smb" or "conf" to fetch the line from your history. The history feature will locate the most recent command in which that string was used. If the command found is more recent than the one you're looking for, just type ^r again. Repeat pressing ^r as needed. Once you find the command you're looking for, just press enter, just as you would is you were using the up arrow trick. Type ^c if you want to abandon the process altogether. If you want to repeat some part of a previous command, you can always up arrow back to a command and then backspace over the parts you don't want to repeat. If you want to reuse just the last part of a command -- say you recently edited a file and now you want to page through it to verify that you change the proper lines, you can reuse just the last argument more easily using the !$ trick. !$ represents the final (rightmost) string in the previously entered command. So, if you just edited /usr/local/etc/smb.conf, you can page through the file with "more !$". If you create a directory named /usr/local/scripts/bin, you can go to that directory by typing "cd !$". Other useful bash shortcuts include the following: ^a Return to the start of the command you're typing ^e Go to the end of the command you're typing ^u Cut everything before the cursor to a special clipboard ^k Cut everything after the cursor to a special clipboard ^y Paste from the special clipboard that Ctrl + u and Ctrl + k save their data to ^t Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!) ^w Delete the word / argument left of the cursor ^l Clear the screen With all the time you'll save, maybe you can get an early start on your holiday shopping! *********************** [root@aus-zenoss-master-01 ~]# su - zenoss [zenoss@aus-zenoss-master-01 ~]$ zendmd Welcome to the Zenoss dmd command shell! 'dmd' is bound to the DataRoot. 'zhelp()' to get a list of commands. >>> zhelp >>> zhelp() app cleandir commit devices dmd find grepdir login logout me pprint reindex socket sync zhelp zport >>> [1]+ Stopped zendmd [zenoss@aus-zenoss-master-01 ~]$ jobs [1]+ Stopped zendmd [zenoss@aus-zenoss-master-01 ~]$ jobs [1]+ Stopped zendmd [zenoss@aus-zenoss-master-01 ~]$ fg zendmd KeyboardInterrupt >>> quit 'Use Ctrl-D (i.e. EOF) to exit.' >>> *********************** SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS Commands marked with * may be preceded by a number, _N. Notes in parentheses indicate the behavior if _N is given. h H Display this help. q :q Q :Q ZZ Exit. --------------------------------------------------------------------------- MMOOVVIINNGG e ^E j ^N CR * Forward one line (or _N lines). y ^Y k ^K ^P * Backward one line (or _N lines). f ^F ^V SPACE * Forward one window (or _N lines). b ^B ESC-v * Backward one window (or _N lines). z * Forward one window (and set window to _N). w * Backward one window (and set window to _N). ESC-SPACE * Forward one window, but don't stop at end-of-file. d ^D * Forward one half-window (and set half-window to _N). u ^U * Backward one half-window (and set half-window to _N). ESC-) RightArrow * Left one half screen width (or _N positions). ESC-( LeftArrow * Right one half screen width (or _N positions). F Forward forever; like "tail -f". r ^R ^L Repaint screen. R Repaint screen, discarding buffered input. --------------------------------------------------- Default "window" is the screen height. Default "half-window" is half of the screen height. --------------------------------------------------------------------------- SSEEAARRCCHHIINNGG /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. n * Repeat previous search (for _N-th occurrence). N * Repeat previous search in reverse direction. ESC-n * Repeat previous search, spanning files. ESC-N * Repeat previous search, reverse dir. & spanning files. ESC-u Undo (toggle) search highlighting. &_p_a_t_t_e_r_n * Display only matching lines --------------------------------------------------- Search patterns may be modified by one or more of: ^N or ! Search for NON-matching lines. ^E or * Search multiple files (pass thru END OF FILE). ^F or @ Start search at FIRST file (for /) or last file (for ?). ^K Highlight matches, but don't move (KEEP position). ^R Don't use REGULAR EXPRESSIONS. --------------------------------------------------------------------------- JJUUMMPPIINNGG g < ESC-< * Go to first line in file (or line _N). G > ESC-> * Go to last line in file (or line _N). p % * Go to beginning of file (or _N percent into file). t * Go to the (_N-th) next tag. T * Go to the (_N-th) previous tag. { ( [ * Find close bracket } ) ]. } ) ] * Find open bracket { ( [. ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_> --------------------------------------------------- Each "find close bracket" command goes forward to the close bracket matching the (_N-th) open bracket in the top line. Each "find open bracket" command goes backward to the open bracket matching the (_N-th) close bracket in the bottom line. m_<_l_e_t_t_e_r_> Mark the current position with . '_<_l_e_t_t_e_r_> Go to a previously marked position. '' Go to the previous position. ^X^X Same as '. --------------------------------------------------- A mark is any upper-case or lower-case letter. Certain marks are predefined: ^ means beginning of the file $ means end of the file --------------------------------------------------------------------------- CCHHAANNGGIINNGG FFIILLEESS :e [_f_i_l_e] Examine a new file. ^X^V Same as :e. :n * Examine the (_N-th) next file from the command line. :p * Examine the (_N-th) previous file from the command line. :x * Examine the first (or _N-th) file from the command line. :d Delete the current file from the command line list. = ^G :f Print current file name. --------------------------------------------------------------------------- MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. --_<_n_a_m_e_> Toggle a command line option, by name. __<_f_l_a_g_> Display the setting of a command line option. ___<_n_a_m_e_> Display the setting of an option, by name. +_c_m_d Execute the less cmd each time a new file is examined. !_c_o_m_m_a_n_d Execute the shell command with $SHELL. |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. v Edit the current file with $VISUAL or $EDITOR. V Print version number of "less". --------------------------------------------------------------------------- OOPPTTIIOONNSS Most options may be changed either on the command line, or from within less by using the - or -- command. Options may be given in one of two forms: either a single character preceded by a -, or a name preceeded by --. -? ........ --help Display help (from command line). -a ........ --search-skip-screen Forward search skips current screen. -b [_N] .... --buffers=[_N] Number of buffers. -B ........ --auto-buffers Don't automatically allocate buffers for pipes. -c ........ --clear-screen Repaint by clearing rather than scrolling. -d ........ --dumb Dumb terminal. -D [_x_n_._n] . --color=_x_n_._n Set screen colors. (MS-DOS only) -e -E .... --quit-at-eof --QUIT-AT-EOF Quit at end of file. -f ........ --force Force open non-regular files. -F ........ --quit-if-one-screen Quit if entire file fits on first screen. -g ........ --hilite-search Highlight only last match for searches. -G ........ --HILITE-SEARCH Don't highlight any matches for searches. -h [_N] .... --max-back-scroll=[_N] Backward scroll limit. -i ........ --ignore-case Ignore case in searches that do not contain uppercase. -I ........ --IGNORE-CASE Ignore case in all searches. -j [_N] .... --jump-target=[_N] Screen position of target lines. -J ........ --status-column Display a status column at left edge of screen. -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] Use a lesskey file. -L ........ --no-lessopen Ignore the LESSOPEN environment variable. -m -M .... --long-prompt --LONG-PROMPT Set prompt style. -n -N .... --line-numbers --LINE-NUMBERS Don't use line numbers. -o [_f_i_l_e] . --log-file=[_f_i_l_e] Copy to log file (standard input only). -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] Copy to log file (unconditionally overwrite). -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] Start at pattern (from command line). -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] Define new prompt. -q -Q .... --quiet --QUIET --silent --SILENT Quiet the terminal bell. -r -R .... --raw-control-chars --RAW-CONTROL-CHARS Output "raw" control characters. -s ........ --squeeze-blank-lines Squeeze multiple blank lines. -S ........ --chop-long-lines Chop long lines. -t [_t_a_g] .. --tag=[_t_a_g] Find a tag. -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] Use an alternate tags file. -u -U .... --underline-special --UNDERLINE-SPECIAL Change handling of backspaces. -V ........ --version Display the version number of "less". -w ........ --hilite-unread Highlight first new line after forward-screen. -W ........ --HILITE-UNREAD Highlight first new line after any forward movement. -x [_N[,...]] --tabs=[_N[,...]] Set tab stops. -X ........ --no-init Don't use termcap init/deinit strings. --no-keypad Don't use termcap keypad init/deinit strings. -y [_N] .... --max-forw-scroll=[_N] Forward scroll limit. -z [_N] .... --window=[_N] Set size of window. -" [_c[_c]] . --quotes=[_c[_c]] Set shell quote characters. -~ ........ --tilde Don't display tildes after end of file. -# [_N] .... --shift=[_N] Horizontal scroll amount (0 = one half screen width) --------------------------------------------------------------------------- LLIINNEE EEDDIITTIINNGG These keys can be used to edit text being entered on the "command line" at the bottom of the screen. RightArrow ESC-l Move cursor right one character. LeftArrow ESC-h Move cursor left one character. CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word. CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word. HOME ESC-0 Move cursor to start of line. END ESC-$ Move cursor to end of line. BACKSPACE Delete char to left of cursor. DELETE ESC-x Delete char under cursor. CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor. CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor. CNTL-U ESC (MS-DOS only) Delete entire line. UpArrow ESC-k Retrieve previous command line. DownArrow ESC-j Retrieve next command line. TAB Complete filename & cycle. SHIFT-TAB ESC-TAB Complete filename & reverse cycle. CNTL-L Complete filename, list all. *********************** VB Mystery Icon thingys: https://msdn.microsoft.com/en-us/library/y47ychfe.aspx VB commands **********************************************************************************************************88 **********************************************************************************************************88 'variable declarations Dim as bytInches = 26 shrtFeet = 32767 intMiles = 2100432877 lngNationalDebt = 4000000000001 sngTemperature = 98.6 dblWindSpeed = 35.373659262 decBankBalance = 1234567890.1234567890123456789D intVariable = 20 (integer literal) or 'On the right side of the operator, you can put a literal, another variable, or a mathematical expression intVariable = intVariable 'to assign a character literal to a Char variable chrLetter = "A"c 'variable = thing clb is the prefix for checked list boxes Dim strName As String strName = "Jose Gonzalez" 'implicit type conversion Dim sngNumber As Single = 5 'The following statement does not compile with Option Strictset to On: Dim intCount As Integer = "abc123" 'Constants Const decADULT_FEE As Decimal = 40D **********************************************************************************************************88 **********************************************************************************************************88 'Conversion functions CDate(expr) Converts a String expression containing a valid date, such as "10/14/2013 1:30:00 PM", to a Date. Input can also be a Date literal, such as #10/14/2013 1:30:00 PM#. CDbl( expr) Converts an expression to a Double. If the input expression is a String, a leading currency symbol ($) is permitted, as are commas. The decimal point is optional. CDec( expr) Converts an expression to a Decimal. If the input expression is a String, a leading currency symbol ($) is permitted, as are commas. The decimal point is optional. CInt( expr) Converts an expression to an Integer. If the input expression is a String, a leading currency symbol ($) is permitted, as are commas. The decimal point is optional, as are digits after the decimal point. CStr( expr) Converts an expression to a String. Input can be a mathematical expression, a Boolean value, a date, or any numeric data type. intWholeNumber = CInt(dblRealNumber) intHoursWorked = CInt(txtHoursWorked.Text) Dim decAccountBalance As Decimal = CDec(txtAccountBalance.Text) Dim dblAmount As Double = 3.4 // Dim intAmount As Integer = CInt(dblAmount) Dim intNumber As Integer = 123 // lblNumber.Text = intNumber.ToString() **********************************************************************************************************88 **********************************************************************************************************88 'Format Strings strResult = dblSample.ToString("c") Dim strResult As String = dtmSample.ToString("d") N or n Number format F or f Fixed-point scientific format E or e Exponential scientific format C or c Currency format P or p Percent format 'Operators Operator Operation + -Addition – -Subtraction * -Multiplication / -Floating-point division \ -Integer division MOD -Modulus (remainder from integer division) ^ -Exponentiation (x^y= xy) intC = intA * intB 'Relational Operator Meaning > Greater than < Less than = Equal to <> Not equal to >= Greater than or equal to <= Less than or equal to **********************************************************************************************************88 **********************************************************************************************************88 'Date and Time Functions Now =current date and time from the system TimeOfDay =current time from the system, without the date Today =current date from the system, without the time Dim dtmSystemDate As Date dtmSystemDate = Now lblDateToday.Text = Now.ToString("D") 'Math Orders of Operations (5 + 2) * 4 =28 10 / (5 - 3) =5 8 + 12 * (6 - 2) =56 (6 - 3) * (2 + 7) / 3 =9 6B = 6 * B (3)(12) = 3 * 12 4xy = 4 * x * y **********************************************************************************************************88 **********************************************************************************************************88 'text alignment example lblReportTitle.TextAlign = ContentAlignment.MiddleCenter **********************************************************************************************************88 **********************************************************************************************************88 'Display popup MessageBox.Show("Hello World!") MessageBox.Show(intValue.ToString()) Dim strUsername As String strUsername = InputBox("Enter your username.", "Input Needed") MessageBox.Show(strUsername.ToString) **********************************************************************************************************88 **********************************************************************************************************88 ' Give the focus to txtDayOfWeek. txtDayOfWeek.Focus() ' Clear the Text Boxes and lblDateString txtDayOfWeek.Clear() lblDateString.Text = String.Empty **********************************************************************************************************88 **********************************************************************************************************88 'Error Checking Try ' Get the annual salary and number of pay periods. decAnnualSalary = CDec(txtAnnualSalary.Text) Try ' Get the number of pay periods. intPayPeriods = CInt(txtPayPeriods.Text) Try ' Calculate the salary per pay period. decSalary = decAnnualSalary / intPayPeriods ' Display the salary per pay period. lblSalary.Text = decSalary.ToString("c") Catch ' Error message for division-by-zero. lblStatus.Text = "Pay periods cannot be zero." End Try Catch ' Error message for invalid pay periods. lblStatus.Text = "Pay periods must be an integer." End Try Catch ' Error message for invalid salary. lblStatus.Text = "Enter a numeric value for salary." End Try **********************************************************************************************************88 **********************************************************************************************************88 'Load Event 'Double click form Private Sub Form1_Load(...) Handles MyBase.Load MessageBox.Show("Prepare to see the form!") End Sub **********************************************************************************************************88 **********************************************************************************************************88 'Debug Stuff Debug > Start Debugging (F5) > test a field > Step Into (F8-for the next line) (yellow highlight line is what will run NEXT **********************************************************************************************************88 **********************************************************************************************************88 'IF / THEN's tryparse takes user input and see's if it can be made into an (int, dec, bln, etc) if yes then true - below example put's it into dest(var) if it works, if conversion fails, then stick error in a label AND set's a varible to false to be used later If Integer.TryParse(source, destination(variable)) = False Then lable, button, thing = "Months must be an integer." blnVariable = False End If ' Validate the number of months. If intMonths < 1 Or intMonths > 24 Then lblStatus.Text = "Months must be in the range 1 - 24." blnVariable = False End If If blnVariable = True Then If radAdult.Checked = True Then decBaseFee = decADULT_FEE ElseIf radChild.Checked = True Then decBaseFee = decCHILD_FEE End If **********************************************************************************************************88 **********************************************************************************************************88 'Input Box InputBox(Prompt [,Title] [, Default]) Dim strUsername As String strUsername = InputBox("Enter your username.", "Input Needed") **********************************************************************************************************88 **********************************************************************************************************88 'List Boxes If intIndex >= 0 And intIndex < lstMonths.Items.Count Then strInput = lstMonths.Items(intIndex).ToString() Else MessageBox.Show("Index is out of range: " & intIndex) End If **********************************************************************************************************88 **********************************************************************************************************88 'Loops Do While intCount < 10 lstOutput.Items.Add("Hello") intCount += 1 Loop Do MessageBox.Show("Hello World!") intCount += 1 Loop While intCount < 10 Do Until intCount > intNumScores strInput = InputBox("Enter test score " & intCount.ToString()) If Double.TryParse(strInput, dblTestScore) Then dblTotal += dblTestScore intCount += 1 Else MessageBox.Show("Enter a numeric test score.") End If Loop For CounterVariable= StartValue ToEndValue[StepIncrement] statement Next [CounterVariable] ie: For intCount = 1 To 10 MessageBox.Show("Hello") Next For intCount = 0 To 100 Step 10 MessageBox.Show(intCount.ToString()) Next 'Nexted Loops For intX = 1 To 2 For intY = 1 To 3 MessageBox.Show("this is intY " & intY.ToString()) Next Next **********************************************************************************************************88 **********************************************************************************************************88 'Checked list boxes Dim intIndex As Integer ' List box index For intIndex = 0 To clbCities.Items.Count - 1 If clbCities.GetItemChecked(intIndex) = True Then lstChecked.Items.Add(clbCities.Items(intIndex)) End If Next **********************************************************************************************************88 **********************************************************************************************************88 Random Numbers / Next / NextDoubles Dim intNum As Integer Dim rand As New Random 'The expression New Randomcreates a Randomobject in memory. intNum = rand.Next() intNum = rand.Next(100) 'value assigned to intNumis somewhere between 0 and 99 intNum = rand.Next(10) + 1 ' the number assigned to intNumwill be somewhere in the range of 1 through 10 intNum = rand.Next(100) - 50 ' assigns a random integer to intNum between –50 and +49: You can call a Randomobject’s NextDoublemethodto get a random floating-point number between 0.0 and 1.0 (not including 1.0). The following code shows an example: Dim dblNum As Double Dim rand As New Random dblNum = rand.NextDouble() The following statement assigns a random number between 0.0 and 500.0 to dblNum: dblNum = rand.NextDouble() * 500.0 The following statement generates a random number between 100.0 and 600.0: dblNum = (rand.NextDouble() * 500.0) + 100.0 Dim rand As New Random(1000) intNum = rand.Next(4230) + 5250 ' Gives a random number between 5250 - 9480 (take 9840-5250=4230) -- default range of NEXT method is 0 and 2,147,483,647) **********************************************************************************************************88 **********************************************************************************************************88 End With With txtName .Clear() .ForeColor = Color.Blue .BackColor = Color.Yellow .BorderStyle = BorderStyle.Fixed3D End With **********************************************************************************************************88 **********************************************************************************************************88 Built in Payment Functions Pmt(PeriodicInterestRate, NumberOfPeriods, –LoanAmount) dblPayment = Pmt(dblAnnInt / 12, 24, -5000) IPmt(PeriodicInterestRate, Period, NumberOfPeriods, –LoanAmount) dblInterest = IPmt(dblAnnInt / 12, 6, 24, -5000) PPmt(PeriodicInterestRate, Period, NumberOfPeriods, –LoanAmount) dblPrincipal = PPmt(dblAnnInt / 12, 6, 24, -5000) **********************************************************************************************************88 **********************************************************************************************************88 lblAnswer.Text = intX.ToString() 'intx | tostring > lblAnswer.Text *************************************************************************** Procedure calls: [AccessSpecifier] SubProcedureName([ParameterList]) ' Call the DisplayMessage procedure. DisplayMessage() ***program stuff*** Sub DisplayMessage() ' This procedure displays a message in the list box. lstOutput.Items.Add("") lstOutput.Items.Add("Hello from the DisplayMessage procedure.") lstOutput.Items.Add("") End Sub ************************************************************************* Declaring a function: [AccessSpecifier] Function FunctionName([ParameterList]) As DataType ie: Function Sum(ByVal dblNum1 As Double, ByVal dblNum2 As Double) As Double Dim dblResult As Double dblResult = dblNum1 + dblNum2 Return dblResult End Function *********************** #!/bin/sh df -HP | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do echo $output usage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usage -ge 90 ] then echo "Running out of space \"$partition ($usage%)\" on $(hostname) as of $(date)" fi done *********************** *********************** *********************** *********************** *********************** *********************** *********************** ***********************