Cheat Sheet
VI
Cursor movement
h - move left j - move down k - move up l - move right w - jump by start of words (punctuation considered words) W - jump by words (spaces separate words) e - jump to end of words (punctuation considered words) E - jump to end of words (no punctuation) b - jump backward by words (punctuation considered words) B - jump backward by words (no punctuation) 0 - (zero) start of line ^ - first non-blank character of line $ - end of line G - Go To command (prefix with number - 5G goes to line 5) Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
Insert Mode – Inserting/Appending text
i - start insert mode at cursor I - insert at the beginning of the line a - append after the cursor A - append at the end of the line o - open (append) blank line below current line (no need to press return) O - open blank line above current line ea - append at end of word Esc - exit insert mode
Editing
r - replace a single character (does not use insert mode) J - join line below to the current one cc - change (replace) an entire line cw - change (replace) to the end of word c$ - change (replace) to the end of line s - delete character at cursor and subsitute text S - delete line at cursor and substitute text (same as cc) xp - transpose two letters (delete and paste, technically) u - undo . - repeat last command
Marking text (visual mode)
v - start visual mode, mark lines, then do command (such as y-yank) V - start Linewise visual mode o - move to other end of marked area Ctrl+v - start visual block mode O - move to Other corner of block aw - mark a word ab - a () block (with braces) aB - a {} block (with brackets) ib - inner () block iB - inner {} block Esc - exit visual mode
Visual commands
> - shift right < - shift left y - yank (copy) marked text d - delete marked text ~ - switch case
Cut and Paste
yy - yank (copy) a line 2yy - yank 2 lines yw - yank word y$ - yank to end of line p - put (paste) the clipboard after cursor P - put (paste) before cursor dd - delete (cut) a line dw - delete (cut) the current word x - delete (cut) current character
Exiting
:w - write (save) the file, but don't exit :wq - write (save) and quit :q - quit (fails if anything has changed) :q! - quit and throw away changes
Search/Replace
/pattern - search for pattern ?pattern - search backward for pattern n - repeat search in same direction N - repeat search in opposite direction :%s/old/new/g - replace all old with new throughout file :%s/old/new/gc - replace all old with new throughout file with confirmations
Working with multiple files
:e filename - Edit a file in a new buffer :bnext (or :bn) - go to next buffer :bprev (of :bp) - go to previous buffer :bd - delete a buffer (close a file) :sp filename - Open a file in a new buffer and split window ctrl+ws - Split windows ctrl+ww - switch between windows ctrl+wq - Quit a window ctrl+wv - Split windows vertically
Line Numbers
:set number
Networking/Subnetting
Netmask Netmask (binary) CIDR Notes _____________________________________________________________________________ 255.255.255.255 11111111.11111111.11111111.11111111 /32 Host (single addr) 255.255.255.254 11111111.11111111.11111111.11111110 /31 Unuseable 255.255.255.252 11111111.11111111.11111111.11111100 /30 2 useable 255.255.255.248 11111111.11111111.11111111.11111000 /29 6 useable 255.255.255.240 11111111.11111111.11111111.11110000 /28 14 useable 255.255.255.224 11111111.11111111.11111111.11100000 /27 30 useable 255.255.255.192 11111111.11111111.11111111.11000000 /26 62 useable 255.255.255.128 11111111.11111111.11111111.10000000 /25 126 useable 255.255.255.0 11111111.11111111.11111111.00000000 /24 "Class C" 254 useable 255.255.254.0 11111111.11111111.11111110.00000000 /23 2 Class C's 255.255.252.0 11111111.11111111.11111100.00000000 /22 4 Class C's 255.255.248.0 11111111.11111111.11111000.00000000 /21 8 Class C's 255.255.240.0 11111111.11111111.11110000.00000000 /20 16 Class C's 255.255.224.0 11111111.11111111.11100000.00000000 /19 32 Class C's 255.255.192.0 11111111.11111111.11000000.00000000 /18 64 Class C's 255.255.128.0 11111111.11111111.10000000.00000000 /17 128 Class C's 255.255.0.0 11111111.11111111.00000000.00000000 /16 "Class B" 255.254.0.0 11111111.11111110.00000000.00000000 /15 2 Class B's 255.252.0.0 11111111.11111100.00000000.00000000 /14 4 Class B's 255.248.0.0 11111111.11111000.00000000.00000000 /13 8 Class B's 255.240.0.0 11111111.11110000.00000000.00000000 /12 16 Class B's 255.224.0.0 11111111.11100000.00000000.00000000 /11 32 Class B's 255.192.0.0 11111111.11000000.00000000.00000000 /10 64 Class B's 255.128.0.0 11111111.10000000.00000000.00000000 /9 128 Class B's 255.0.0.0 11111111.00000000.00000000.00000000 /8 "Class A" 254.0.0.0 11111110.00000000.00000000.00000000 /7 252.0.0.0 11111100.00000000.00000000.00000000 /6 248.0.0.0 11111000.00000000.00000000.00000000 /5 240.0.0.0 11110000.00000000.00000000.00000000 /4 224.0.0.0 11100000.00000000.00000000.00000000 /3 192.0.0.0 11000000.00000000.00000000.00000000 /2 128.0.0.0 10000000.00000000.00000000.00000000 /1 0.0.0.0 00000000.00000000.00000000.00000000 /0 IP space Net Host Total Net Addr Addr Addr Number Class Range NetMask Bits Bits of hosts ---------------------------------------------------------- A 0-127 255.0.0.0 8 24 16777216 (i.e. 114.0.0.0) B 128-191 255.255.0.0 16 16 65536 (i.e. 150.0.0.0) C 192-254 255.255.255.0 24 8 256 (i.e. 199.0.0.0) D 224-239 (multicast) E 240-255 (reserved) F 208-215 255.255.255.240 28 4 16 G 216/8 ARIN - North America G 217/8 RIPE NCC - Europe G 218-219/8 APNIC H 220-221 255.255.255.248 29 3 8 (reserved) K 222-223 255.255.255.254 31 1 2 (reserved)
(ref: RFC1375 & http://www.iana.org/assignments/ipv4-address-space )
( http://www.iana.org/numbers.htm )
———————————————————-
The current list of special use prefixes:
0.0.0.0/8 127.0.0.0/8 192.0.2.0/24 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 169.254.0.0/16 all D/E space
(ref: RFC1918 http://www.rfc-editor.org/rfc/rfc1918.txt )
( or ftp://ftp.isi.edu/in-notes/rfc1918.txt )
(rfc search: http://www.rfc-editor.org/rfcsearch.html )
( http://www.ietf.org/ietf/1id-abstracts.txt )
( http://www.ietf.org/shadow.html )
Martians:
(updates at: http://www.iana.org/assignments/ipv4-address-space )
no ip source-route
access-list 100 deny ip host 0.0.0.0 any deny ip 0.0.0.0 0.255.255.255 any log ! antispoof deny ip 0.0.0.0 0.255.255.255 0.0.0.0 255.255.255.255 ! antispoof deny ip any 255.255.255.128 0.0.0.127 ! antispoof deny ip host 0.0.0.0 any log ! antispoof deny ip host [router intf] [router intf] ! antispoof deny ip xxx.xxx.xxx.0 0.0.0.255 any log ! lan area deny ip 0/8 0.255.255.255 any log ! IANA - Reserved deny ip 1/8 0.255.255.255 any log ! IANA - Reserved deny ip 2/8 0.255.255.255 any log ! IANA - Reserved deny ip 5/8 0.255.255.255 any log ! IANA - Reserved deny ip 7/8 0.255.255.255 any log ! IANA - Reserved deny ip 10.0.0.0 0.255.255.255 any log ! IANA - Private Use deny ip 23/8 0.255.255.255 any log ! IANA - Reserved deny ip 27/8 0.255.255.255 any log ! IANA - Reserved deny ip 31/8 0.255.255.255 any log ! IANA - Reserved deny ip 36-37/8 0.255.255.255 any log ! IANA - Reserved deny ip 39/8 0.255.255.255 any log ! IANA - Reserved deny ip 41-42/8 0.255.255.255 any log ! IANA - Reserved deny ip 50/8 0.255.255.255 any log ! IANA - Reserved deny ip 58-60/8 0.255.255.255 any log ! IANA - Reserved deny ip 69-79/8 0.255.255.255 any log ! IANA - Reserved deny ip 82-95/8 0.255.255.255 any log ! IANA - Reserved deny ip 96-126/8 0.255.255.255 any log ! IANA - Reserved deny ip 127/8 0.255.255.255 any log ! IANA - Reserved deny ip 169.254.0.0 0.0.255.255 any log ! link-local network deny ip 172.16.0.0 0.15.255.255 any log ! reserved deny ip 192.168.0.0 0.0.255.255 any log ! reserved deny ip 192.0.2.0 0.0.0.255 any log ! test network deny ip 197/8 0.255.255.255 any log ! IANA - Reserved deny ip 220/8 0.255.255.255 any log ! IANA - Reserved deny ip 222-223/8 0.255.255.255 any log ! IANA - Reserved deny ip 224.0.0.0 31.255.255.255 any log ! multicast deny ip 224.0.0.0 15.255.255.255 any log ! unless MBGP-learned routes deny ip 224-239/8 0.255.255.255 any log ! IANA - Multicast deny ip 240-255/8 0.255.255.255 any log ! IANA - Reserved
filtered source addresses
0/8 ! broadcast 10/8 ! RFC 1918 private 127/8 ! loopback 169.254.0/16 ! link local 172.16.0.0/12 ! RFC 1918 private 192.0.2.0/24 ! TEST-NET 192.168.0/16 ! RFC 1918 private 224.0.0.0/4 ! class D multicast 240.0.0.0/5 ! class E reserved 248.0.0.0/5 ! reserved 255.255.255.255/32 ! broadcast
ARIN administrated blocks:
(http://www.arin.net/regserv/IPStats.html)
24.0.0.0/8 (portions of) 63.0.0.0/8 64.0.0.0/8 65.0.0.0/8 66.0.0.0/8 196.0.0.0/8 198.0.0.0/8 199.0.0.0/8 200.0.0.0/8 204.0.0.0/8 205.0.0.0/8 206.0.0.0/8 207.0.0.0/8 208.0.0.0/8 209.0.0.0/8 216.0.0.0/8
well known ports:
(rfc1700.txt)
http://www.iana.org/assignments/port-numbers
protocol numbers:
http://www.iana.org/assignments/protocol-numbers
http://www.iana.org/numbers.htm
ICMP(Types/Codes)
Testing Destination Reachability & Status
(0/0) Echo-Reply (8/0) Echo
Unreachable Destinations
(3/0) Network Unreachable (3/1) Host Unreachable (3/2) Protocol Unreachable (3/3) Port Unreachable (3/4) Fragmentaion Needed and DF set (Pkt too big) (3/5) Source Route Failed (3/6) Network Unknown (3/7) Host Unknown (3/9) DOD Net Prohibited (3/10) DOD Host Prohibited (3/11) Net TOS Unreachable (3/12) Host TOS Unreachable (3/13) Administratively Prohibited (3/14) Host Precedence Unreachable (3/15) Precedence Unreachable
Flow Control
(4/0) Source-Quench [RFC 1016]
Route Change Requests from Gateways
(5/0) Redirect Datagrams for the Net (5/1) Redirect Datagrams for the Host (5/2) Redirect Datagrams for the TOS and Net (5/3) Redirect Datagrams for the TOS and Host
Router
(6/-) Alternate-Address (9/0) Router-Advertisement (10/0) Router-Solicitation
Detecting Circular or Excessively Long Routes
(11/0) Time to Live Count Exceeded (11/1) Fragment Reassembly Time Exceeded
Reporting Incorrect Datagram Headers
(12/0) Parameter-Problem (12/1) Option Missing (12/2) No Room for Option
Clock Synchronization and Transit Time Estimation
(13/0) Timestamp-Request (14/0) Timestamp-Reply
Obtaining a Network Address (RARP Alternative)
(15/0) Information-Request (16/0) Information-Reply
Obtaining a Subnet Mask [RFC 950]
(17/0) Address Mask-Request (18/0) Address Mask-Reply
Other
(30/0) Traceroute (31/0) Conversion-Error (32/0) Mobile-Redirect
Ref: [RFC 792] [RFC 896] [RFC 950] [RFC 1016]
http://www.cisco.com/univercd/cc/td/doc/product/lan/cat6000/sw_5_3/cofigide/qos.htm#19774
Decimal system Prefixes
Factor Exponent Prefix --------------------------------------------------- 1 000 000 000 000 000 000 000 000...10^24....yotta 1 000 000 000 000 000 000 000...10^21....zetta 1 000 000 000 000 000 000...10^18....exa 1 000 000 000 000 000...10^15....peta 1 000 000 000 000...10^12....tera 1 000 000 000...10^9.....giga 1 000 000...10^6.....mega 1 000...10^3.....kilo 100...10^2.....hecto 10...10^1.....deka 0.1...10^-1....deci 0.01...10^-2....centi 0.001...10^-3....milli 0.000 001...10^-6....micro 0.000 000 001...10^-9....nano 0.000 000 000 001...10^-12...pico 0.000 000 000 000 001...10^-15...femto 0.000 000 000 000 000 001...10^-18...atto 0.000 000 000 000 000 000 001...10^-21...zepto 0.000 000 000 000 000 000 000 001...10^-24...yocto ---------------------------------------------------
Convert Fahrenheit <> Celsius:
Celsius = (Fahrenheit - 32) / 1.8 Fahrenheit = (Celsius * 1.8) + 32
Basic Command Line Editing
You can use the following key combinations to edit and recall commands:
CTRL + L : Clear the screen. CTRL + W : Delete the word starting at cursor. CTRL + U : Clear the line i.e. Delete the all words from command line. Up and Down arrow keys : Recall commands (see command history). Tab : Auto-complete files, directory, command names and much more. CTRL + R : Search through previously used commands (see command history) CTRL + C : Cancel currently running commands. CTRL + T : Swap the last two characters before the cursor. ESC + T : Swap the last two words before the cursor.
Console Cheating
TAR
Einen Tarball erzeugen
tar -cvf /xxxxxxxxx.tar /pfad/pfad
Einen Tarball erzeugen und auch z.B. .htaccess mitnehmen
cd /geh/da/hin/wo/das/zeug/liegt tar -cvf ./xxxxxxxxx.tar . # ja, ein Punkt wegen der Shell Variablen Expansion
SCP
Viele rekursiv von REMOTE nach LOKAL
scp -r user@hostname:/pfad/pfad/ ./
Eine Datei von LOKAL auf VIELE REMOTE
for i in 1994 1985 1986 1987 ; do scp ./DATEINAME USERNAME@hostname$i:/tmp/; done;
VIELE Dateien von LOKAL nach REMOTE
scp ./datei1.tar ./datei2.tar username@host:/tmp/
Paketverteilung
Ein Verzeichnis auf vielen Hosts erstellen
for i in 1976 1977 1978 1979 ... 1997; do ssh username@xhost$i '[ -d /tmp/20130917 ] || mkdir -p /tmp/20130917 ]'; done;
TARGETHOSTS="2568 2569"; USERNAME="xxxxxx"; HOSTPART1="xxxx"; FILENAME="86xxx_xxxx_xxxx_V2.00.22_20131029.tar.gz"; DATEOFNOW=`date +%Y%m%d`; for i in ${TARGETHOSTS}; do ssh ${USERNAME}@${HOSTPART1}${i} '[ -d /tmp/${DATEOFNOW} ] || mkdir -p /tmp/${DATEOFNOW} ]'; done; for c in ${TARGETHOSTS}; do scp ./${FILENAME} ${USERNAME}@${HOSTPART1}${c}:/tmp/${DATEOFNOW}/; done;
Mehrere LOKALE pakete auf mehrere hosts
for i in XXXX1980 xxxx1984 xxxx1981 xxxx1985; do scp ./86024_xxxx_xxxx-xxxx.tar.gz ./86005_xxxx_xxxx-xxxx.tar.gz ./86008_xxxx_xxxx-xxxx.tar.gz ./86007_xxxx_xxxx-xxxx.tar.gz ./86006_xxxx_xxxx.tar.gz username@$i:/tmp/20130917; done;
Abholen und Auspacken der Pakete
cd /var/swdepot; [ -d /var/swdepot/Deployment_KW38 ] || mkdir -p /var/swdepot/Deployment_KW38 ]; cd /var/swdepot/Deployment_KW38; mv /tmp/20130917/*.gz /var/swdepot/Deployment_KW38; for f in *.tar.gz; do tar xzvf ./$f; done; rm -rf /tmp/20130917;
Schleifen über files und mit seq
cd /etc/init.d/; for file in tomcat7_8??_mbb?-?; do ./${file} "status"; done;
for I in $(seq 18611 3 18620); do lynx --dump http://localhost:$I/mon/health.html; done;
Lynx
lynx --dump http://localhost:PORT/eventlocations/check.jsp
for i in 2546 2550 2554 2538 2542 2558 2570 2562 2632 2574 2566 2628 2652 2648 2656 2582 2644 2578 2640 2636 ; do lynx --dump http://web$i/monitor/healthcheck_ung.html; done;
Softlinks for sure!
Das Kommando:
ln -s 8XXXX_XXXX_cityev/ ./8XXXX_XXXX_CITYEV
erzeugt einen Link namens 8XXXX_XXXX_CITYEV, der auf 8XXXX_XXXX_cityev zeigt:
[root@XXXXXX XXXXXX]# ll total 44 drwxr-xr-x 5 r2XXXX g4XXXX 4096 Jun 13 16:18 8XXXX_XXXX_cityev lrwxrwxrwx 1 root root 18 Jun 18 10:42 8XXXX_XXXX_CITYEV -> 8XXXX_XXXX_cityev/
egrep
egrep -vi "info|success" ./install-dingens.log | less
Diffing the Dirs
diff -i -r ./8XX_XXXX-1 ./8XX_XXXX-1-BACKUP/
wenn keine Ausgabe erfolgt, sind die Verzeichnisse identisch.
- -i – ignoriert Gross-/Kleinschreibung
- -r – rekursiv
- dann die Verzeichnisnamen.
sed
Schießt aus einer Datei alle Vorkommnisse von AAAA raus und ersetzt sie durch BBBB
sed -i "s/AAAA/BBBB/g" ./Pfad/Datei
z.B.:
sed -i "s/XXXX2568/XXXX2569/g" ./log4j.xml
Matchende Zeilen aus einer Datei herausschiessen:
sed -i '/MATCHSTRING/d' ./datei.txt
Die Anzahl von files in zwei Verzeichnissen ermitteln
Mit locate (da sind die Verzeichnisse in der Ausgabe mit dabei)
updatedb locate /pfad/zu/verzeichnis1 | wc -l locate /pfad/zu/verzeichnis2 | wc -l
Mit find
find /pfad/zu/verzeichnis1 -type f | wc -l find /pfad/zu/verzeichnis2 -type f | wc -l
RTD-Sheet Cheats
Mehrere Tomcats gleichzeitig starten/stoppen
cd /etc/init.d/; for file in tomcat7_8XX_XXXX-*; do ./${file} "status"; done;
Die Response von mehreren healthcheck_ung.htmls mit einem Einzeiler einsammeln
- Version A:
PORTlist="18601 18604 18607 18610 18613 18616 18619 18622 18625 18628"; for I in $PORTlist; do lynx --dump http://localhost:$I/tc_mon/healthcheck_ung.html; done;
- Version B:
for I in $(seq 0 3 10); do lynx --dump http://localhost:$I/tc_mon/healthcheck_ung.html; done;
SSL-certificates for mailservers
Basic check of SSL-certificate
echo 00000001 LOGOUT | openssl s_client -connect mx.xxxxxxxxxx.de:993 2>&1
Checking for expiration date of a SSL-certificate
echo 00000001 LOGOUT | openssl s_client -connect mx.xxxxxxxxxx.de:993 > cert openssl x509 -in cert -noout -enddate
How to generate SSL-certificates
- http://www.howtoforge.com/virtual-users-and-domains-with-postfix-courier-mysql-and-squirrelmail-debian-wheezy-p2
generate SSL-certificate for postfix
cd /etc/postfix openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509
generate SSL-certificates for Courier
cd /etc/courier rm -f /etc/courier/imapd.pem rm -f /etc/courier/pop3d.pem
then change the hostname in impad.cnf and pop3d.cnf
vi /etc/courier/imapd.cnf vi /etc/courier/pop3d.cnf
then recreate the certificates
mkimapdcert mkpop3dcert
and restart courier
/etc/init.d/courier-authdaemon restart /etc/init.d/courier-imap restart /etc/init.d/courier-imap-ssl restart /etc/init.d/courier-pop restart /etc/init.d/courier-pop-ssl restart
Basic Hardening
Creating default users
adduser –m –G wheel -s /bin/bash adminuser passwd adminuser
[password]
adduser –m –G wheel -s /bin/bash anotheradmin passwd anotheradmin
[password]
Limit “su to root” to members of group “wheel” via PAM
To prevent users, which are not members of the “wheel”-group, to become “root” enable the option “auth required pam_wheel.so use_uid”.
vi /etc/pam.d/su
Uncomment line number 7.
1 #%PAM-1.0 2 auth sufficient pam_rootok.so 3 # Uncomment the following line to implicitly trust users in the "wheel" 4 group. 5 #auth sufficient pam_wheel.so trust use_uid 6 # Uncomment the following line to require a user to be in the "wheel" group. 7 auth required pam_wheel.so use_uid 8 auth include system-auth 9 account sufficient pam_succeed_if.so uid = 0 use_uid quiet 10 account include system-auth 11 password include system-auth 12 session include system-auth 13 session optional pam_xauth.so
securetty
To further narrow down where “root” can log in, delete lines 2 to 12.
sed -i".whatever.bak" '2,12d' /etc/securetty
1 console 2 vc/1 3 vc/2 4 vc/3 5 vc/4 6 vc/5 7 vc/6 8 vc/7 9 vc/8 10 vc/9 11 vc/10 12 vc/11 13 tty1 14 tty2 15 tty3 16 tty4 17 tty5 18 tty6 19 tty7 20 tty8 21 tty9 22 tty10 23 tty11
Configure SSHd to prevent direct root-logins
To prevent sshd from accepting root-logins you have to edit “/etc/ssh/sshd_config”. Enable the option “#PermitRootLogin” in the “Authentication”-section and set it to “no”
sed -i 's/^\#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config /etc/init.d/sshd restart
HP-UX
autocompletion
AUtocompletion von Verzeichnis- oder Filenamen
[ESC][ESC]
Delete Taste
stty erase ^?
Mails von der Kommandozeile schicken
mailx
mailx -v -s "SUBJECT" -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp=smtp.gmail.com:587 -S from=$MAILFR -S smtp-auth-user=$MAILTO -S smtp-auth-password="$SMTPPASS" $MAILTO < $STATUS 2>"$ERR"
msmtp
File msmtp-conf:
# Example for a user configuration file # Set default values for all following accounts. defaults tls on # tls_trust_file /etc/ssl/certs/ca-certificates.crt tls_certcheck off logfile /path/to/log/msmtp.log # The SMTP server of the provider. account ACCOUNT1 host host.example.com from user@example.com auth on user username@example.com # passwordeval gpg -d ~/.msmtp.password.gpg password YOURSUPERSECUREPASSWORD # Set a default account account default : ACCOUNT1
function sendanemail () { if [ "$MSMTPDEBUG" != "no" ] then echo -e $3 | msmtp --debug -C $1 $2; else echo -e $3 | msmtp -C $1 $2; fi } if [ "$SENDMAILIFGOOD" == "yes" ] || [ "$SENDMAILIFBAD" == "yes" ] then # Ermitteln des Datums SENDDATE=$(date -R) SUBJECTDATE=$(makeadate) # Bauen des Subjects abhaengig vom Fehlerstatus MAILSUBJECT="[${SUBJECTHOSTNAME}]: ${SUBJECTDATE} - " if [ "$ERRORSTATUSSTRING" = "" ] then MAILSUBJECT+="${SUBJECTSTATEGOOD}" else MAILSUBJECT+="${SUBJECTSTATEBAD}" fi # Bauen des E-Mail-Headers MAILHEADER+="To: ${MAILRECEIVER}\n" MAILHEADER+="From: ${MAILSENDER}\n" MAILHEADER+="Date: ${SENDDATE}\n" MAILHEADER+="Subject: ${MAILSUBJECT}\n" # Bauen des Mail-Bodies abhaengig vom Fehlerstatus if [ "$ERRORSTATUSSTRING" = "" ] then MAILBODY+="Das Backup der VM ${VMNAME} am ${SUBJECTDATE} auf ${BACKUPSERVERFQDN} war erfolgreich.\n" else MAILBODY+="Das Backup der VM ${VMNAME} am ${SUBJECTDATE} auf ${BACKUPSERVERFQDN} schlug fehl.\n" MAILBODY+="\n" MAILBODY+="Folgende Fehler sind aufgetreten:\n" MAILBODY+="==========================================================================================\n" MAILBODY+="${ERRORSTATUSSTRING}" MAILBODY+="==========================================================================================\n" fi # Mailheader und Mailbody zusammenfuehren EMAILTEXT=${MAILHEADER}${MAILBODY} # Senden der E-Mail sendanemail "$MSMTPCONFIG" "$MAILRECEIVER" "$EMAILTEXT" && notify "Die Email wurde gesendet." || error "Die Mail konnte nicht gesendet werden."; fi
o2-cheats
./configure --help make clean make distclean ld -lexpat --verbose ldd svn LDFLAGS="-L/opt/app/bicapp1d/tools/software/apr-util-1.5.3/lib/" ./configure --prefix=/opt/app/bic/software/serf-1.2.1 --with-apr=/opt/app/bic/software/apr-1.5.0/ --with-apr-util=/opt/app/bic/software/apr-util-1.5.3/
Die LDFLAGS muss man setzen weil der linker sonst die libexpat nicht findet. Es muss die libexpat in apr-util sein!
./configure --enable-all-static --prefix=/opt/app/bic/software/subversion-1.8.8 --with-apr=/opt/app/bic/software/apr-1.5.0/ --with-apr-util=/opt/app/bic/software/apr-util-1.5.3/ --with-serf=/opt/app/bic/software/serf-1.2.1/
monit
monit docu
https://mmonit.com/monit/documentation/
make monit use an external smtpserver
Make monit (>=4.10) send out mails via an external mailserserver.
set mailserver smtp.example.com port 587 username "username@example.com" password "password" using tlsv1 with timeout 30 seconds
virsh/KVM
virsh console <host> nutzbar machen
file: /etc/inittab:
# /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ # The default runlevel. id:2:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/init.d/rcS # What to do in single-user mode. ~~:S:wait:/sbin/sulogin # /etc/init.d executes the S and K scripts upon change # of runlevel. # # Runlevel 0 is halt. # Runlevel 1 is single-user. # Runlevels 2-5 are multi-user. # Runlevel 6 is reboot. l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin # What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now # Action on special keypress (ALT-UpArrow). #kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." # What to do when the power fails/returns. pf::powerwait:/etc/init.d/powerfail start pn::powerfailnow:/etc/init.d/powerfail now po::powerokwait:/etc/init.d/powerfail stop # /sbin/getty invocations for the runlevels. # # The "id" field MUST be the same as the last # characters of the device (after "tty"). # # Format: # ::: # # Note that on most Debian systems tty7 is used by the X Window System, # so if you want to add more getty's go ahead but skip tty7 if you run X. # 1:2345:respawn:/sbin/getty 38400 tty1 2:23:respawn:/sbin/getty 38400 tty2 3:23:respawn:/sbin/getty 38400 tty3 4:23:respawn:/sbin/getty 38400 tty4 5:23:respawn:/sbin/getty 38400 tty5 6:23:respawn:/sbin/getty 38400 tty6 # Example how to put a getty on a serial line (for a terminal) # T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 # <<<<<<< THIS IS WHERE THE MAGIC HAPPENS! #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 # Example how to put a getty on a modem line. # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 #-- runit begin #-- runit end
storeBackup
recovery
http://www.nongnu.org/storebackup/de/node29.html
storeBackupRecover.pl -r restore [-b root] -t targetDir [--flat] [-o] [--tmpdir] [--noHardLinks] [-p number] [-v] [-n] [--cpIsGnu] [--noGnuCp] [-s] e.g. storeBackupRecover /ext-backup/set/ /var/data/set/
Lidl Cheating
create all server list
cat ??? | sort -u >/etc/dsh/group/ALL_SERVER_LIST
SSH-Key-verteilung
Einfache Methode um den SSH-Key auf alle Systeme zu verteilen (inkl Check ob der Key dort schon vorhanden ist):
for i in $(cat /etc/dsh/group/ALL_HOSTNAMES_LIST); do ssh-copy-id -i ~/.ssh/id_rsa.pub root@$i; done;