The Cheatsheet

# Cambiar zona horaria Debian Wheezy
# ----------------------------------
Current default time zone: 'America/Argentina/Buenos_Aires'
Local time is now:      Thu Jun 27 09:13:54 ART 2013.
Universal Time is now:  Thu Jun 27 12:13:54 UTC 2013.
Run 'dpkg-reconfigure tzdata' if you wish to change it.


# Install perl module - Instalar modulo perl
# ---------------------------------------------------

http://www.cyberciti.biz/faq/how-do-i-install-a-perl-module/
http://www.thegeekstuff.com/2008/09/how-to-install-perl-modules-manually-and-using-cpan-command/

If you are using Red Hat Linux then use up2date command to install most common modules:

# up2date module-name

Use following command to list all supported modules:
# up2date --showall | grep -i 'perl'

OR use yum command under CentOS/RHEL 5/Fedora core:
# yum list available 'perl'

If you are using Debian Linux, try to use apt-get command to install common perl module. However following is the recommended way to install a perl module.

A) Start CPAN Shell:
# perl -MCPAN -e shell

B) Install a perl module:
At cpan> shell prompt install module using install module::Name command. For example install module called MIME::Lite:
# cpan> install MIME::Lite

Alternatively, try out the following command:
# cpan -i MIME::Lite
# ---------------------------------------------------


# Teclado español (ES. con tecla euro y LATAM sin tecla euro), agregar acentos
------------------------------------------------------------------------------

# Activa los acentos en la sesion, no hace falta reiniciar
sudo setxkbmap -layout 'es,es' -model pc105

# Cargar a xorg.conf para añadir soporte desde arranque previo a .xinitrc

Section “InputDevice”
Identifier “Generic Keyboard”
Driver “kbd”
Option “CoreKeyboard”
Option “XkbRules” “xorg”
Option “XkbModel” “pc105″
Option “XkbLayout” “es”
Option “XkbOptions” “lv3:ralt_switch”
EndSection

**** teclado latam (español sin tecla euro) *****
Option “XkbLayout” “latam”

# cargar a /etc/default/keyboard (son los mismos parametros, todos en mayusculas)
XKBMODEL="pc105"
XKBLAYOUT="es"
XKBVARIANT=""
XKBOPTIONS="lv3:ralt_switch"

**** teclado latam (español sin tecla euro) *****
XKBMODEL="pc105"
XKBLAYOUT="latam"


# NFS manejo/montaje básico (funciona para agregar datastore a ESXi 5.0)
------------------------------------------------------------------------
- /etc/exports
/var/nas/esx  192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash)

- Mostrar filesystems montados:
showmount -a

- Recargar exports
/etc/init.d/nfs-kernel-server reload

- Recargar exports
exportfs -a


# Ver uptime en Windows Server
------------------------------
net stats srv
systeminfo | find  "Up Time"
systeminfo | find  "Tiempo"


# Instalar LAMP en Debian Wheezy
-------------------------------------------------
apt-get install mysql-server
apt-get install apache2 apache2-mpm-prefork php5
apt-get install  phpmyadmin (instala php5-mysql!)
apt-get install  php5-mysqlnd (borra php5-mysqli y php5-mysql)
apt-get install  php-pear libgd-tools libmcrypt-dev mcrypt


# Configurar / Formartear discos/particiones a mano
--------------------------------------------------
fdisk /dev/sdb
cfdisk /dev/sdb - para crear partición
mkfs.ext4 /dev/sdb1 - para formatear partición


# Enviar mail de prueba desde consola (MTA configurado para envío)
------------------------------------------------------------------

mail -s “Testeando” tumail@algo.com

Press the “Return” key

Enter the body part of the email

Press ctrl + D

Enter a CC email if you would like (e.g. info2@test.com)

Press ctrl + D again

Then check the mail box to see if the mail has arrived.



Configurar postfix para enviar mails desde server (A GMAIL)
------------------------------------------------------------
apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

Main.cf:
--------
relayhost = [74.125.137.16]:587  # ip de server de Gmail - 2013-Mayo
smtp_use_tls = yes

#
# "cacert.pem" linkeado / volcado desde un cert bajados con apt-get ca-certificates
# y ubicado en /etc/ssl/certs
#
smtp_tls_CAfile = /etc/postfix/cacert.pem

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options = noanonymous

myhostname = localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mydestination = $mydomain,$myhostname,localhost,locahost.domain


/etc/postfix/sasl/passwd
--------------------------
[74.125.137.16]:587 tumailengmail@gmail.com:tupassword

Luego postmap passwd y postfix reload/restart para cargar todos los cambios.

If you need further debugging you can add these:

debug_peer_list=smtp.gmail.com
debug_peer_level=3



# Cambiar editor de texto en consola
------------------------------------
update-alternatives --config editor


# Chequear configuración apache
---------------------------------
apache2ctl -t - testear configuracion
apache2ctl -M - modulos cargados
apache2ctl -l - modulos compilados
apache2ctl -S - vhosts configurados

# Apache RLimitMem
-------------------
http://www.cyberciti.biz/tips/linux-apache-setting-perl-cgi-script-limits.html

# Apache - PHP Suhosin
-----------------------
> suhosin.memory_limit cambiado a 0 (cero), deshabilitandolo
/etc/php5/conf.d/suhosin.ini (y service apache2 restart)

# Apache - Modificando memory_limit de PHP para Apache de 128 a 256MB
----------------------------------------------------------------------
Modificar en /etc/php5/apache2/php.ini (y service apache2 restart)

# Reseteo de reglas iptables
----------------------------
#!/bin/sh
#------------------------------------------------------------------------------------
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

# Setting default filter policy
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT

echo "Listo - Reglas reseteadas"
exit 0
#------------------------------------------------------------------------------------


# Convertir logs Squid estándar para tener los horarios human readable
-------------------------------------------------------------------
$ perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e' < access.log > access.log.h


# Configuración OpenNMS - Envío de Alertas por mail a Gmail
----------------------------------------------------------
http://www.opennms.org/wiki/Gmail_example_javamail-configuration.properties


org.opennms.core.utils.useJMTA=false
org.opennms.core.utils.transport=smtp
org.opennms.core.utils.mailHost=smtp.gmail.com
org.opennms.core.utils.smtpport=587
org.opennms.core.utils.smtpssl.enable=false
org.opennms.core.utils.authenticate=true
org.opennms.core.utils.authenticateUser=foo@gmail.com
org.opennms.core.utils.authenticatePassword=pass4foo
org.opennms.core.utils.starttls.enable=true
org.opennms.core.utils.messageContentType=text/html
org.opennms.core.utils.charset=UTF-8
Note:

This works as of 5/7/2008 and is different than the settings in etc/examples/javamail-configuration.properties as of build 1.5.91-SNAPSHOT.
These lines are found in etc/examples/javamail-configuration.properties for a gmail account, but are modified above:
org.opennms.core.utils.transport=smtps
org.opennms.core.utils.smtpport=465
org.opennms.core.utils.smtpssl.enable=true


# Testear mail y alertas en OpenNMS
----------------------------------
* ir /usr/share/opennms/bin

./send-event.pl --interface 192.168.1.10(una ip) uei.opennms.org/nodes/nodeDown


# Configurar agentes SNMP - Vmware ESXi 5.0
----------------------------------------------------------------
VMware vSphere Command Line Interface (vCLI)
* VMware vSphere PowerCLI

SNMP Agentes
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx --show
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx -c public

Trapping
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx -t 192.168.1.25@162/public

Polling
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx -p 161

IPMI sensors
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx -y sensors

CIM indications
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx -y indications


Activar
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx --enable

Testear
vicfg-snmp.pl --server 192.168.1.10 --username root --password pass-del-root-esx --test


# How to disable ESXi firewall
-----------------------------
esxcli network firewall set --enabled false


# Ver programas conectados a Internet
---------------------------------
lsof -nPi


# Short Tip: egrep – using grep with more than one expression
-------------------------------------------------------------
The multiple arguments you are searching for a passed to egrep separated by pipes. For example, if you want to grep the output of lspci for all audio and video controllers, the correct command is:

Tip: Usando egrep con más de una expresión


A veces necesitamos filtrar más de una expresión en un output y el filtrado con grep nos va pedir que corramos el comando más de una vez para ver todos los resultados, así:

lspci | grep -i audio
lspci | grep -i vga

Se puede ver todos los resultados de una sola vez con egrep, así:

lspci | egrep -i 'audio|vga'
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 12)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 06)

El parámetro "-i" es para que egrep busque sin distinguir mayúsculas.


Claro, es más escalable, ya que podemos buscar una gran cantidad de patrones simultáneamente:

lspci | egrep -i 'audio|vga|ethernet|network'
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 12)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 06)
03:00.0 Network controller: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller (rev 01)
04:00.0 Ethernet controller: Atheros Communications Inc. AR8152 v1.1 Fast Ethernet (rev c1)


# Cómo lograr las fuentes de Gnome en KDE
----------------------------------------------------------
1) Ver la config de Gnome (en consola)

[yaco@wintermute ~]$ xrdb -query | grep Xft
Xft.antialias:  1
Xft.dpi:        96
Xft.hinting:    1
Xft.hintstyle:  hintslight
Xft.lcdfilter:  lcddefault
Xft.rgba:       rgb



2) [yaco@wintermute ~]$ cd $HOME; vi .Xresources
Xft.antialias:  1
Xft.dpi:        96
Xft.hinting:    1
Xft.hintstyle:  hintslight
Xft.lcdfilter:  lcddefault
Xft.rgba:       rgb

ESC + : + qw (para grabar)

3) En el Centro de Control de KDE:
>Apariencia de las Aplicaciones > Tipos de Letra > Usar el Suavizado de bordes a "Preferencias del Sistema"

Aceptar, y reiniciar la sesión para ver los cambios.


# Borrar pass de pdf
---------------------------------------
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf


# Instalar Vmware Tools en Debian
 ----------------------------------------------------
1) Try the following commands (as root) before installing the tools:
apt-get install gcc make linux-headers-$(uname -r)


apt-get update
apt-get upgrade -y
apt-get install gcc make linux-headers-$(uname -r)


2) Elige la opción Install VMtools y luego desde la VM los siguientes pasos:

mount /dev/cdrom /mnt
cd /tmp
tar xzf /mnt/PONER_VM_TOOLS
cd DIRECTORIO_VMTOOLS
./FICHERO_DE_INSTALACION
Déjalo todo de forma predeterminada, limítate a darle al enter.


# Borrar llaverito con live-cd opensuse
----------------------------------------------------
su -
cfdisk /dev/sdg
# now create a new partition table and new partition
# for example a fat32
mkdosfs -n llaverito -v /dev/sdb1

mkdosfs -n llaverito -v /dev/sdb1
mkfs.vfat /dev/sdb1
sync

http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/467985-how-remove-opensuse-live-cd-kde-partition-usb-stick.html


No hay comentarios: