quarta-feira, 26 de junho de 2013

CentOS – descobrindo qual pacote contém determinado arquivo [Linux]

No CentOS, as vezes necessitamos descobrir qual pacote fornece um determinado arquivo. Para isso, basta usar o comando yum whatprovides …

Por exemplo, para saber qual pacote fornece o arquivo libstdc++.so.5, execute

# yum whatprovides libstdc++.so.5

O resultado deve ser parecido com

Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirror.gtdinternet.com
* extras: mirror.gtdinternet.com
* rpmforge: mirror.awanti.com
* updates: mirror.gtdinternet.com
compat-libstdc++-33-3.2.3-61.i386 : Compatibility standard C++ libraries
Repo : base
Matched from:
Other : libstdc++.so.5

No caso acima, o pacote é compat-libstdc++-33-3.2.3-61.i386. Basta agora instalar o pacote com o comando

# yum install compat-libstdc++-33-3.2.3-61.i386

Os comandos acima foram testados no CentOS 5.4
(joaomedeiros.net)

Tmux gerenciador de Janelas SSH [Linux]

Centos install:

#yum install tmux.x86_64 (para versões x64)
#yum install tmux.i386     (para versões x32)

Ubuntu:

#apt-get update && apt-get install tmux

Comandos:

Lista janelas ssh abertas
#tmux ls

Recuperar janela:
#tmux attach -t id_janela
ou
#tmux a -t id_janela

Desconectar janela:
#CTRL + B e depois D

Criar frame vertical:
#CTRL + B e depois %

Criar frame horizontal:
#CTRL + B e depois "

Mudar cursor entre frames:
#CTRL + B <-- ou -->

####

tmux new -d -s decoder3 #Cria janela em dettach
tmux send -t decoder3 ls ENTER #Envia comando para janela em dettach

Reverse SSH Tunneling [Linux]

Have you ever wanted to ssh to your Linux box that sits behind NAT? Now you can with reverse SSH tunneling. This document will show you step by step how to set up reverse SSH tunneling. The reverse SSH tunneling should work fine with Unix like systems.

Let's assume that Destination's IP is 192.168.20.55 (Linux box that you want to access).

You want to access from Linux client with IP 138.47.99.99.

Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99)

1. SSH from the destination to the source (with public ip) using command below:

ssh -R 19999:localhost:22 sourceuser@138.47.99.99

* port 19999 can be any unused port.

2. Now you can SSH from source to destination through SSH tuneling:

ssh localhost -p 19999

3. 3rd party servers can also access 192.168.20.55 through Destination (138.47.99.99).

Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99) <- Bob's server

3.1 From Bob's server:

ssh sourceuser@138.47.99.99

3.2 After the sucessful login to Source:

ssh localhost -p 19999

* the connection between destination and source must be alive at all time.


segunda-feira, 24 de junho de 2013

Installing JRE 1.7 in Centos 6.4 and Chrome [Linux]

1. Download the latest RPM version from Oracle download page

2. Go to the folder where you have saved the file:

cd ~/Downloads

3. Install the package using the following command:

yum localinstall jre-7-linux-x64.rpm

4. Now, install Java plugin in Chrome using:

For x64
ln -s /usr/java/default/lib/amd64/libnpjp2.so /opt/google/chrome/plugins

For x86
ln -s /usr/java/default/lib/i386/libnpjp2.so /opt/google/chrome/plugins

5. If you do not have the folder /opt/google/chrome/plugins, just create it using:

mkdir -p /opt/google/chrome/plugins

6. Test it at Java Test Page.

Enjoy!

sexta-feira, 21 de junho de 2013

dpkg missing dependencies [Linux]

In case "dpkg" indicates missing dependencies, complete the installation by executing the following command:


  • sudo apt-get install -f

Screen gerenciador de Janelas SSH [Linux]

Centos install:

#yum install screen.x86_64 (para versões x64)
#yum install screen.i386     (para versões x32)

Ubuntu:

#apt-get update && apt-get install screen


Comandos:

Lista janelas ssh abertas
#screen -ls

Recuperar janela:
#screen -xr iddajanela

Criar janela com alias:
#screen -S nomejanela

Desconectar janela:
#CTRL + A e depois D

Para capturar janelas de outros usuários, deve iniciar o processo adicionando
o screen na última linha do bash_profile do usuário.

#echo screen >> ~root/.bash_profile