Blog de Abelardo Jara Berrocal: Ubuntu, electronica y software libre

Noviembre 27, 2007

Como realizar copias de seguridad con rsync

Archivado en: Linux Ubuntu Administracion — Abelardo Jara @ 9:26 pm

Acontinuación veremos como hacer copias de seguridad con la utilidad rsync con nuestro Ubuntu Gutsy o con Windows con un servidor SSH instalado bajo Cygwin.

Rsync permite la copia de archivos local o remotamente respetando los permisos, propietario, grupo, enlace o dispositivo.

Además permite comprimir los datos para que se puedan enviar o copiar de forma más rápida. Con el uso de rsync solamente se copiarán los datos que se diferencian del origen con la copia de destino, con lo cual se evita tener que copiar de nuevo datos duplicados.

Con rsync también es posible hacer copias a un servidor remoto utilizando el protocolo ssh o rsh. Para realizar esto será necesario que rsync esté instalado en ambas máquina, la local y la remota.

La sintaxis es:
rsync [opciones] origen destino

Veremos algunos ejemplos que nos pueden servir para entender el funcionamiento de rsync:

rsync -t *.doc servidor1:copias

Con esta orden copiaremos todos los archivos .doc al directorio copias en la máquina servidor1. Si ya existieran los archivos en copias, solamente se enviarían las diferencias existentes entre las dos copias.

rsync -avz servidor1:/copias/documentos desktop/documentacion

Con esta orden se copiarán los archivos de la carpeta documentos del servidor servidor1, en la carpeta desktop/documentacion de la máquina local.

Nota que se usa el parámetro archive (-a) lo cual indica que se respeten los nombres de usuario, permisos que pudiera tener documentos.

Los parámetros [opciones] que podemos usar con rsync son:

-n: Probar, no realiza nada solo muestra el resultado.
-a: Modo archivo. Respeta todos los permisos y propiedad del archivo. Igual que si se usaran los parámetros -rlptDg

-r: Recursivo
-l: Respeta enlaces blandos
-p: Respetar permisos
-t: Respetar fecha/hora
-g: Respetar grupo
-D: Respetar dispositivos (solamente con usuario root)
-v: Modo verboso, para mayor verbosidad usar -vv
-z: Comprimir en caso de que lo acepte el servidor
-C: Ignora archivos como hace CVS.
-u: Modo update, mantiene archivo en el destino si es posterior.
-b: backup renombrar archivos existentes a extensión.

Este proceso de copia lo podemos automatizar utilizando cron, para que se ejecute cada cierto tiempo.

Espero que os haya sido de utilidad.

Como usar SCP, el complemento de SSH para transmitir archivos y carpetas

Archivado en: Linux Ubuntu Administracion — Abelardo Jara @ 9:22 pm

Ahora les comentare como podemos usar una herramienta llamada SCP que viene junto con el SSH para transmitir archivos y directorios:SCP significa Secure CoPy es una pata más de SSH, que permite transferir archivos o carpetas entre computadores. La sintaxis es bien simple:

$ scp archivo usuario@servidor.com:ruta

Y para copiar a la inversa, desde el computador remoto al tuyo, simplemente tienes que invertir el orden de los elementos:

$ scp usuario@servidor.com:ruta/archivo ruta_local

O sea por ejemplo, si quisiéramos mandar algo al servidor:

$ scp hola.txt tomas@bootlog.cl:/www/sitio

Mandaría el archivo hola.txt y lo dejaría en la carpeta /www/sitio en el servidor bootlog.cl. También puedes mandar carpetas completas (con -r):

$ scp -r viajealsur/ tomas@bootlog.cl:/www/sitio/fotos

Así mandaría la carpeta /viajealsur completa a /www/sitio/fotos.

Ahora, el mismo proceso a la inversa sería:

$ scp -r tomas@bootlog.cl:/www/sitio/fotos/viajealsur ~

Esto copiaría la carpeta viajealsur/ del servidor a mi carpeta /home.

Ah, y a propósito de carpetas home, como en SCP (y en SSH) la ruta por defecto es tu carpeta de usuario, si quieres copiar algo hacia o desde ahí, puedes omitir la ruta:

$ scp cancion.mp3 bootlog.cl:

En este caso la sintaxis está bien, ya que mi usuario se llama ‘tomas’ en ambos lados, así que no tengo que escribirlo de nuevo, y como estoy copiando el archivo cancion.mp3 a mi carpeta de usuario, también puedo omitir la ruta.

Ahora llegó la hora de que tú hagas la prueba. Recuerda que tienes que instalar el paquete openssh-server en el PC remoto para poder conectarte.

Enviar puertos de un host remoto a traves de un tunel SSH

Archivado en: Linux Ubuntu Administracion — Abelardo Jara @ 9:20 pm

En algunas ocasiones debemos usar protocolos no seguros (que envían sus contraseñas y/o datos en texto plano) cuando no estamos en un entorno fiable. Esto es comun en servidor de correo POP que no permiten conexiones o seguras o administracion remota con VNC (que no encripta las contraseñas, se envian sobre la red como texto plano).

Para estas situaciones, los túneles SSH nos permiten establecer una comunicación segura, que además es independiente de firewalls y otros filtros.El esquema de utilización vendría a ser el siguiente: un usuario inicia una sesión desde el ordenador local al remoto. Al establecer esa conexión le indica que puertos serán tunelizados, de tal forma que cuando el usuario se conecte al puerto X de la máquina local, será como si se conectara al puerto Y de la máquina remota.

El comando para conectarnos es:

ssh -L puerto_local:maquina_remota:puerto_remoto usuario@maquina_remota

Imaginemos que deseamos conectarnos a un servicio Web (puerto 80) de la máquina remota que no estaría accesible en condiciones normales debido a un firewall. Lo que haremos es reflejar ese puerto 80 de la maquina remota en el puerto 11000 de nuestra computadora. Asi a partir de ese momento el puerto 11000 de nuestra computadora sera el puerto 80 del ordenador remoto (y ese tunel transmitira sus paquetes encriptados en el tunel SSH).

Deseamos usar el puerto 11000 en nuestro ordenador local asi que usaremos este comando:

  • ssh -L 11000:localhost:80

localhost es el nombre del ordenador remoto al que el servidor ssh debe conectarse. Lógicamente, localhost indica que es el mismo ordenador que corre el servicio. Con esto podríamos conectarnos a cualquier otro servicio que el servidor remoto tenga accesible (en el ejemplo, un servidor pop3):

  • ssh -L 11000:servidor-remoto-de-correo:110

Por otra parte, es posible también que en la red remota usen servicios solo accesibles desde nuestra red local, para ello bastaría con usar un ssh -R 11000:ordenadorlocal:6667.

Usando el truco con VNC

Este truco se usa mucho para conectarnos a una máquina con Linux que tiene un servidor VNC corriendo:

Para eso levantaremos el servidor de VNC en la estación con Linux tipeando en consola:

$vncserver —-> Iniciamos el servidor VNC

$vncpasswd ——> Para establecer el password del servidor VNC

Alli te dira que ha empezada el servidor con un número de DISPLAY. En general este DISPLAY no sera 0, ya que el DISPLAY 0 esta ocupado ya por nuestro escritorio Gnome que corre en Gutsy, asi que muy probable te de otro número como 1, 2,…

Esto provoca que el servidor escuche conexiones por los puertos 5901, 5902, 590x (x es el número de DISPLAY que se te asigno al ejecutar VNCSERVER).

Luego desde un cliente cualquiera (Linux, Windows, …) podemos llamar la conexion de tunel con:

ssh -L 5900:HOST_REMOTO:5901 tusuario@HOSTREMOTO

Ahora el puerto 5901 de la maquina remota esta transmitiendo sobre el puerto 5900 de la maquina local. Solo queda conectarse con el vncviewer al localhost:0

NOTA: este truco debe ser solo usado para conexiones puntuales… para comunicar dos redes de forma segura y transparente a través de Internet hay soluciones mejores, como las VPN (redes privadas virtuales)

Otra gran importancia de este truco es que nuestro firewall puede tener solo abierto el puerto 22 del SSH, y todo servicio es enviado mediante un tunel a traves de SSH. Sin embargo esto hace las conexiones mas lentas.

Adicionando alias a mi Bash de Cygwin

Archivado en: Programacion C++ en Windows, Programacion del Bash — Abelardo Jara @ 6:54 pm

Acabo de instalar Cygwin en mi Windows XP, las instrucciones las doy en otro post, pero para hacer mas comoda mi consola de comandos Bash, he puesto algunas lineas al final del archivo .bashrc que se encuentra en /home/pintuco (bueno pintuco es mi nombre de usuario)

Aqui van: pueden editar .bashrc con el notepad de Windows o con nano o vi si lo instalaron como parte del Cygwin

set -o notify
export HISTCONTROL=ignoredups
alias less=’less -r’
alias rm=’rm -i’
alias whence=’type -a’
alias ls=’ls -F –color=tty’
alias dir=’ls –color=auto –format=vertical’
alias vdir=’ls –color=auto –format=long’
alias ll=’ls -l’
alias la=’ls -A’
alias l=’ls -CF’

#and here are a several more to add:

alias cp=’cp -i’
alias mv=’mv -i’
alias c:=’cd /cygdrive/c’
alias x:=’cd /cygdrive/x’
alias z:=’cd /cygdrive/z’
alias grep=’grep –color’
alias vi=’vim’
alias cls=’clear’

#A function to pipe any command to less:
function so {
eval “$@” |less -I~
}

Preguntas en entrevistas de trabajo para VLSI Analogico en EEUU

Archivado en: Temas Ingenieria de Computadoras y Electronica — Abelardo Jara @ 3:38 pm

1) How does a Mosfet works.
2) what are different types of BJT configurations and when do we use them.
3) what is the difference between TTL and CMOS ( even others also like ECL etc).
4) What is noise margin.
5) Which is the most important pin the microcontroller.
6) Explain about Ground Bounce and Vcc Sag.
7) what is EMI and what are different types of it.
8) one question on any kind of sensors you are aware of Ex: hall sensor etc.
9) what is LVDT.
10) how do we select the correct value of decoupling capacitor (or) what is the purpose of using a decoupling capacitor.
11) what is parasitic capacitance & what are the effects of it.
12) what is the difference between microprocessor and micro controller.
13) what are different types of micro processor architectures
14) difference between by pass capacitor and decoupling capacitor
15) how do you select an op amp ( this can apply to other components also)
16) Single ended and Differential signals.
17) How do you decide the layer stack up on PCB.
18) Filter Design : Analog and Digital Filters, different types of filters.
19) what is signal integrity.
20) what is meta stability.
21) Difference between CPLD and FPGA
22) Difference between DDR and DDR2 RAM.
23) what is termination. what are the different types of terminations.
24) When do you need to use an heat sink and how do you decide on that.
25) what is the difference between clock buffer and clock driver.
26) What is Jitter.
27) what is gain bandwidth product
28) Define settling time of op amp.
29) what is slew rate of op amp, define common mode rejection ratio and input offset voltage.
30) what is the difference between static response and dynamic response.
31) what is an integrator and differentiator.
32) define the parameters of an ADC or types of ADC etc.
33) what is sample and hold circuit.
34) what is a comparator.( some questions related to schmitt trigger or positive feed back of op amp)
35) what is Fan Out.
36) Different types of Voltage regulators. ( Linear, Switching etc..)
37) How do you create a basic delay circuit.
38) what is characteristic impedance.
39) what is ringing, undershoot and overshoot of a signal why do they occur and how to reduce them.
40) what is latch up.
41) what are the parameters to be taken into consideration while selecting a mosfet.
42) what are the different modes of operation of mosfet and BJT ( Linear & Switching and Cut off)
43) how do you implement a current source using BJT or MOSFET.
44) what is hysteresis. and what are the advantages and disadvantages of it.
45) what are the effects of vias on PCB.
46) how do you design a voltage to frequency converter.
47) 8051 architecture.
48) Ethernet communication
49) Different types of serial communications ex. I2C
50) Different types of memory devices ( ROM, RAM,SRAM and EEPROM etc)
51) How to select an Opto coupler.
52) what is the main advantage of using a bridge rectifier rather than using a full wave rectifier.
53) what are the applications of zener diode.
54) what are the applications of schottky diode.
55) why do we need a Gate Driver for Mosfet in Switching operations.
56) what is pulse width modulation. give any examples.
57) how does SMPS ( Switch mode power supply works)
58) what does it mean by PID control.
59) what are different types of Flip flops.
60) what is meant by quiescent current and what is the significance of it.
61) How does an instrumentation amplifier differs from normal operational amplifier
62) What are snubbers and how does they protect switching circuits.
63) What is sampling time and how to fix it.
64) What is Rogowski coil and what are its advantages over normal current transformer.
65) What is Ringing, Overshoot and Undershoot how to reduce them.
66) what is a relaxation oscillator.
67) what is hysteresis.
68) what are the different applications of comparators.
69) how does a Unijunction Transistor works.
70) how does programable unijunction transistor works.
71) what are the differences between ASIC, FPGA and CPLD.
72) how to select a network processor.
73) what is the difference between radiated emissions and conducted emissions how to detect and reduce them.
74) what are the different types of negative resistance devices and what are their applications.
75) What is the major application of Zener Diode.
76) When do we use Schottky diode.
77) what are the different types of flip flops.
78) what is the difference between flip flop and latch.
79) what are the types of errors in ADC and DAC’s.
80) what is Setup and Hold time of flip flop.
81) what is Race condition in flip flops.
82) What is the difference between RISC and CISC processors.
83) What is tri-state logic.
84) What is the difference between Hardware reset and Software reset.
85) How do you determine the response time of any circuit.[loop response]
86) What is an integrator how do design it.
87) What is a Differentiator design it.
88) What factors will impact the characteristic impedance of the PCB (Dielectric property of insulating material, Seperation between the planes, thickness of the trace.)
89) What are the advantages of using differential signal routing in PCB.
90) How do we make sure that the impedance matching between driver and reciever are maintained.
91) Different types of terminations and their advantages and disadvantages.
92) What is meant by microstip and stripline.
93) How do you decide the placement of components on PCB. i.e. where to route power signals, where to route clock signals, how to route digital signals and analog signals.
94) Why do we need a tie.
95) If suppose you have designed a PCB in which you have selected BGA components what is the care you take when routing. (hint:- Connect all ground pins of BGA IC through thermal Pad).
96) If you have decided to go for only two layer board how do you route power, signal and ground layers.
97) why do we need to route gnd in planes rather than a trace.
98) If we have both analog and digital circuitary on PCB what care we will take while grounding.(How doe we connect those grounds.i.e.through Ferrite bead or Jumper)
99) what does it mean by positive layer and negative layer.
100) What is meant by Solder Mask and Solder Paste.
101) How to decide on what components should be present in top layer and what compnents should be place in bottom layer.
102) what is meant by Reflow Soldering and when do we perform it.
103) what is meant by Wave Soldering what are the advantages and disadvantages of it.
104) what are different types of connectors.(i mean through hole and SMD and what care you need to take while placing them. usually place near to the end of PCB and never route any power signals below it.)
105) what are different types of gerbers.( Hint:-Basic gerber and Extended gerber the difference is in basic gerber all apertures are linked in different files where in in extended gerber all apertures are linked in a single file.)
106) On which side of the board soldering should be done first.
107) what are the different types of dielectric material used in PCB.( Hint:- FR4,HFR4).
108) different kinds of Vias in PCB ( normal via,blind via and burried via).
109) what is pulse width modulation and give some examples where we can use that concept.
110) what are different types of filters(single ended and differential filters you can also think in the way like low pass,high pass, band pass and band reject filters).
111) how does impedance mismatch in signal path effect.
114) why we should not route right angled traces.(right angled traces will act as antenna)
115) why do we call BJT as current controlled device and MOSFET as voltage controlled device.
116) what are active and passive devices.117) what are the differences between positive and negative feed back in amplifiers.
118) what are the advantages of using darlington pair of transistors.
119) what does it mean by light pipes give some examples where they can be used.
120) what are the different types of semiconductors (Hint:-direct band gap and indirect band gap)
121) what is thyrister and what are the applications of it.
122) Can you explain the applications of Zener diode, Tunnel diode, Schottky diodes.
123) what is the advantge of bridge rectifer when compared to full wave rectifier.(Hint:- The ouput polarity of bridge rectifier is always same irrespective of input polarity, hence when ever we change the supply polarity by mistake the output circuitary will not get effected)
124) what is Clipping and Clamping design a circuit which does the same.
125) why do we need to use heat sinks on certain components. what is the criterion to select a heat sink. (Hint:- Power dissipation is the main culprit)
126) why do we operate a MOSFET or BJT in saturation when we use them for switching purpose.
127) what is quiscent current.
128) what are the different types of oscillators.
129) what is thermal run away.
130) can you exaplain briefly on different types of packages of ICs. ( Ex: TO-92 etc..)
131) what is IGBT and what are the advantages of it.
132) what are different types of MOSFETs ( Hint:- Depletion type and Enhancement type)
133) How do we overcome common mode noise.( explain any preventive measures to be taken to avoid it)
134) what are the different types of noise.
135) What are buffers. what is the importance of using bufferes in any circuit. ( Hint:- Buffers usually will have high input impedance and low output impedance hence it will support to connect more loads at the output and it maintains the input voltage)
136) what are the different types of Analog to Ditial Converters.
137) what are the different types of Digital to Analog Converters.
138) what are the applications of unijunction transistor.
139) Can you give some examples of Voltage to Current converters.
140) What is offset voltage and why do we need to care about it while selecting an Op Amp.
141) What is meant by Thermocouple and how do what are the cares we need to take while carpturing the output of thermocouple and processing it.
142) what are different types of power supplies. (Hint:- Unregulated, regulated,linear, ripple regulated and switching).
143) What is Power Budgeting and How do we perform it. What are the things we will take into consideration while performing power budgeting.
144) what is PLL. Did you any time worked on Voltage controlled oscillators.
145) What is the most important Pin in any microcontroller. (Hint:- reset)
146) what is the difference between serial and parallel communication.
147) what is the difference between RS-232,RS-485 etc…
148) what care you should take while interfacing any microprocessor to memory.
149) what are different types of memory. ( Hint:-Static, dynamic etc.)
150) How do you select a SDRAM.
151) what is EEPROM.
153) Can you explain in brief about the difference between Switches and Bridges. and what are the advantages of each and when to use them.
154) What is JTAG. Did use any time used JTAG to debug any circuit and how it is useful.
155) Did you use any kind of Isolation Amplifiers.
156) How do you generate square wave from sine wave.
157) do you know what is mono stable multi vibrator and astable multi vibrator.
158) How do you provide transient voltage suppression.
159) Did you any time used digital or analog multiplexer.
160) how do you convert serial data to parallel data and vice versa.
161) What do you mean by Charge Pump.
162) what are the considerations to be taken while selecting a micro controller for a specific application.
163) How unity power factor circuit works.
164) what are the different grounding methods available in PCBs.
165) what is space vector control method. how is it different from pulse width modulation.
166) How is schmitt trigger comparator circuit is better than normal comparator circuit.
167) What is the difference between Hardware, Software and Firmware for particular application.
168) What is thermostat and its applications.
169) How to select magnetic shielding for particular components and why do you need shielding.
170) What is feed forward method and how is it helpful in predictive control circuits.
171) What are the different types of switched mode power supplies and what are their power ratings.
172) Why we should sepearte digital and analog grounds in a PCB.
173) How a MOV (metal oxide varistor) or TVS helps in protecting circuits.
174) How do you design sample EMI Filters.
175) What are the major causes for Radiated Emission. (Hint:- clock harmonics, improper terminations etc..)
176) What is wetting voltage.
177) What is dry contact.
178) what happens when a solder is dry solder.
179) what is a chattering contact.
180) What is the difference between hardware reset and software reset.
181) how to you implement line monitoring in any circuit.
182) what are the advantages/dis advantages of using NAND/NOR Flash.
183) What is the difference between SDRAM and DDR RAM.
184) What is memory banking.
185) How to set gain of an amplifier what are the parameters you need to consider while deciding gain.
186) How do you determine the stability of any system.(Hint:- Pole,zero etc..)
187) what is lead/ lag compensation.
188)How to improve/decrease the slew rate of OpAmp.
189) what are the different types of processor architectures (Hint:-Von neumann,Harvard )
190) what is the difference between 8085 and 8086. what are the major changes done to 8086.
191) what is miller effect.

Unir varios PDFs en Ubuntu

Archivado en: Linux Ubuntu Administracion, Linux Ubuntu Basico — Abelardo Jara @ 1:06 pm

Muchas veces queremos unir varios PDFs en un solo documento, en Linux Ubuntu tenemos un comando que nos permitira hacer esto muy facilmente. Este post lo he tomado de:

http://linuxesmas.blogspot.com/2007/10/leccin-manipular-pdfs.html

En primer lugar necesitaremos el programa pdftk y para ello pondremos:

$ sudo apt-get install pdftk

Esto no es un manual completo. Son los ejemplos más prácticos. Para ver el manual del comando pdftk pondremos:

$ man pdftk

Una vez instalado, y dependiendo lo que queramos hacer procederemos:
Las opciones más importantes son: cat (unir), burst (hace un archivo para cada página), background (le pone un fondo a partir de otro pdf pero el documento de entrada debe tener transparencia, es decir, no ser una imagen sino texto), stamp (pone marca de agua sobre el documento). Otras opciones a utilizar son allow (para dar permisos), input_pw, owner_pw, user_pw (para especificar contraseñas).

Quitar contraseña: pdftk secured.pdf input_pw contraseña output unsecured.pdf

Unir in1.pdf y in2.pdf en un nuevo PDF llamado out.pdf :

pdftk in1.pdf in2.pdf cat output out1.pdf
o (usando abreviaturas):
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
o (usando asteriscos):
pdftk *.pdf cat output combined.pdf

Quitar página 13 de in1.pdf al crear out1.pdf:
pdftk in.pdf cat 1-12 14-end output out1.pdf
o
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

Unir dos archivos, uno de los cuales tiene contraseña:
pdftk A=secured.pdf 2.pdf input_pw A=contraseña cat output 3.pdf

Se ha de tener en cuenta que el archivo de salida no tendrá contraseña si no se especifica una. Que poner cualquier cifrado al documento quita todos los permisos del archivo de salida (serán ‘none’) a no ser que se especifiquen. Se pueden dar (o quitar) permisos si el documento está encriptado, o tiene contraseña del autor o del usuario. Si no está cifrado tendrá libertad de copiar e imprimir.

Blog de WordPress.com.