Mostrando postagens com marcador terminal. Mostrar todas as postagens
Mostrando postagens com marcador terminal. Mostrar todas as postagens

quinta-feira, 19 de janeiro de 2023

Exportar o serverX ao trocar de usuário no terminal

Executar os comandos abaixo e guardar as respectivas respostas

$ xauth list $DISPLAY
<output1>
$ echo $DISPLAY
<outoput2>


Efetuar a troca do usuário

$ su - <usuario>


Criar, caso não exista, o Xauthority

$ touch $HOME/.Xauthority


Executar os comandos abaixo com as respectivas saídas dos primeiros comandos

$ xauth add <output1> 
$ export DISPLAY=<output2>

Fonte : https://unix.stackexchange.com/questions/476290/x11-forwarding-does-not-work-if-su-to-another-user

sexta-feira, 6 de fevereiro de 2015

Desvinculando processos e jobs do terminal

Processo que prende o terminal

exec command
[user@localhost ~]$ system-config-users

ctrl + z para parar o processo
^Z
[1]+  Stopped                 system-config-users

bg para colocar ele em segundo plano
[user@localhost ~]$ bg
[1]+ system-config-users &

use o jobs para verificar os processos
[user@localhost ~]$ jobs
[1]+  Running                 system-config-users &

user o disown %<process number> para desvincular do terminal
[smart@localhost ~]$ disown %1


Processo direto desvinculado

execute o comando com o nohup e o "&" no final para colocar em segundo plano
[user@localhost ~]$ nohup system-config-users &


Processo já em andamento

Use o ps para localizar o PID
[user@localhost ~]$ ps ax | grep system-config-user
 4019 pts/2    Sl     0:00 /usr/bin/python /usr/share/system-config-users/system-config-users.py
 4092 pts/2    S+     0:00 grep --color=auto system-config-user

execute um kill -18 <PID> para desvincular ele da sessão do terminal
[user@localhost ~]$ kill -18 4019

quinta-feira, 14 de agosto de 2014

Mensagem de alerta para os terminais linux

echo -e " \e[41;1;37m Fundo Vermelho \e[0m" > /dev/pts/4

echo  imprime textos no prompt

-e desativa o ignore dos scapes

\e Caracter scape que será enterpretado pelo echo dentro da string

[41;1;37m Cor do fundo, estilo da fonte, col da letra

Fundo Vermelho texto a ser apresentado

\e[0m - retorna a configuracao original

> /dev/ptd/4  terminal para onde a mensagem será direcionada

  • 40: Black background
  • 41: Red background
  • 42: Green background
  • 43: Yellow background
  • 44: Blue background
  • 45: Purple background
  • 46: Cyan background
  • 47: White background
  • 0: Normal text
  • 1: Bold or light, depending on terminal
  • 4: Underline text
  • 30: Black
  • 31: Red
  • 32: Green
  • 33: Yellow
  • 34: Blue
  • 35: Purple
  • 36: Cyan
  • 37: White
[root@localhost dev]# echo rodrigo > /dev/tty1
[root@localhost dev]# echo rodrigo > /dev/tty2
[root@localhost dev]# echo rodrigo > /dev/tty3
[root@localhost dev]# echo rodrigo > /dev/tty4
[root@localhost dev]# echo rodrigo > /dev/tty5
[root@localhost dev]# echo rodrigo > /dev/tty6


for i in $(who | awk '{print $2}'); do echo -e " \033[41;1;37m Fundo Vermelho \033[0m" > /dev/$i; done;


#!/bin/bash

# variaveis
corPadrao="\033[0m"
preto="\033[0;30m"
vermelho="\033[0;31m"
verde="\033[0;32m"
marrom="\033[0;33m"
azul="\033[0;34m"
purple="\033[0;35m"
cyan="\033[0;36m"
cinzaClaro="\033[0;37m"
pretoCinza="\033[1;30m"
vermelhoClaro="\033[1;31m"
verdeClaro="\033[1;32m"
amarelo="\033[1;33m"
azulClaro="\033[1;34m"
purpleClaro="\033[1;35m"
cyanClaro="\033[1;36m"
branco="\033[1;37m"

echo "Imprimindo cores"

echo -e " \033[0;30m Preto  \033[0m             --> 0;30 "
echo -e " \033[0;31m Vermelho  \033[0m          --> 0;31 "
echo -e " \033[0;32m Verde  \033[0m             --> 0;32 "
echo -e " \033[0;33m Marrom  \033[0m            --> 0;33 "
echo -e " \033[0;34m Azul  \033[0m              --> 0;34 "
echo -e " \033[0;35m Purple  \033[0m            --> 0;35 "
echo -e " \033[0;36m Cyan  \033[0m              --> 0;36 "
echo -e " \033[0;37m Cinza Claro  \033[0m       --> 0;37 "
echo -e " \033[1;30m Preto Acinzentado \033[0m  --> 1;30 "
echo -e " \033[1;31m Vermelho Claro  \033[0m    --> 1;31 "
echo -e " \033[1;32m Verde Claro  \033[0m       --> 1;32 "
echo -e " \033[1;33m Amarelo \033[0m            --> 1;33 "
echo -e " \033[1;34m Azul  Claro \033[0m        --> 1;34 "
echo -e " \033[1;35m Purple Claro  \033[0m      --> 1;35 "
echo -e " \033[1;36m Cyan  Claro \033[0m        --> 1;36 "
echo -e " \033[1;37m Branco  \033[0m            --> 1;37 "

echo -e " \033[40;1;37m Fundo Preto    \033[0m     --> 40;?;? "
echo -e " \033[41;1;37m Fundo Vermelho \033[0m     --> 41;?;? "
echo -e " \033[42;1;37m Fundo Verde    \033[0m     --> 42;?;? "
echo -e " \033[43;1;37m Fundo Marrom   \033[0m     --> 43;?;? "
echo -e " \033[44;1;37m Fundo Azul     \033[0m     --> 44;?;? "
echo -e " \033[45;1;37m Fundo Purple   \033[0m     --> 45;?;? "
echo -e " \033[46;1;37m Fundo Cyan     \033[0m     --> 46;?;? "
echo -e " \033[47;1;37m Fundo Cinza    \033[0m     --> 47;?;? "

echo -e " \033[4;30m Sublinhado  \033[0m        --> 4;? "
echo -e " \033[5;30m Piscando    \033[0m        --> 5;? "
echo -e " \033[7;30m Invertido   \033[0m        --> 7;? "
echo -e " \033[8;30m Concealed   \033[0m        --> 8;? "


fonte: 
https://www.digitalocean.com/community/tutorials/how-to-customize-your-bash-prompt-on-a-linux-vps


quarta-feira, 11 de junho de 2014

Trocar nome da interface de rede de P8p1 para ETH0

Primeiro, acrecente o parametro biosdevname=0 no grub.conf na linha de load do kernel:
title Fedora (2.6.40.4-5.fc15.x86_64)
 root (hd0,0)
 kernel /boot/vmlinuz-2.6.40.4-5.fc15.x86_64 ro root=/dev/md0 SYSFONT=latarcyrheb-sun16 KEYTABLE=us biosdevname=0 quiet LANG=en_US.UTF-8
 initrd /boot/initramfs-2.6.40.4-5.fc15.x86_64.img
Abra / Crie o arquivo /etc/udev/rules.d/70-persistent-net.rules e utilize o modelo abaixo para definir o nome da interface
Lembre-se de definir corretamente o mac address
# Be sure to put your MAC addresses in the fields below
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:10", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:11", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
depois basta criar um arquivo ifcfg-ethX em /etc/sysconfig/network-scripts/ lembrando de acertar o mac address, pode-se utilizar o anterior p8p1 como exemplo.
...
HWADDR=00:11:22:33:44:10
...
Reinicie a máquina e pronto.

quarta-feira, 26 de março de 2014

Resolvendo problemas de permissão do Policykit / Packagekit para a role update-package

Acrescentar a action abaixo no arquivo

# yum install PackageKit
# vim /usr/share/polkit-1/actions/org.freedesktop.packagekit.policy

...
  <action id="org.freedesktop.packagekit.update-package">
    <description>Update foreign package</description>
    <description xml:lang="pt_BR">Atualiza pacote externo</description>
    <message>Authentication is required to update a package that was not started by yourself</message>
    <message xml:lang="pt_BR">É necessário autenticar para atualizar um pacote que não foi iniciada por você</message>
    <icon_name>package-x-generic</icon_name>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
  </action>
...

quarta-feira, 13 de novembro de 2013

Como determinar varios ips para a mesma placa de rede fedora


Criando ip na rede temporariamente

ifconfig eth0:1 10.151.22.34 up

Creating Virtual Interface and Assign Multiple IP Addresses

Here I have an interface called “ifcfg-eth0“, the default interface for the Ethernet device. If you’ve attached second Ethernet device, then there would be an “ifcfg-eth1” device and so on for each device you’ve attached. These device network files are located in “/etc/sysconfig/network-scripts/” directory. Navigate to the directory and do “ls -l” to list all devices.
# cd /etc/sysconfig/network-scripts/
# ls -l
Sample Output
ifcfg-eth0   ifdown-isdn    ifup-aliases  ifup-plusb     init.ipv6-global
ifcfg-lo     ifdown-post    ifup-bnep     ifup-post      net.hotplug
ifdown       ifdown-ppp     ifup-eth      ifup-ppp       network-functions
ifdown-bnep  ifdown-routes  ifup-ippp     ifup-routes    network-functions-ipv6
ifdown-eth   ifdown-sit     ifup-ipv6     ifup-sit
ifdown-ippp  ifdown-tunnel  ifup-isdn     ifup-tunnel
ifdown-ipv6  ifup           ifup-plip     ifup-wireless
Let’s assume that we want to create three additional virtual interfaces to bind three IP addresses (172.16.16.126172.16.16.127, and 172.16.16.128) to the NIC. So, we need to create three additional alias files, while “ifcfg-eth0” keeps the same primary IP address. This is how we moving forward to setup three aliases to bind the following IP addresses.
Adapter            IP Address                Type
-------------------------------------------------
eth0              172.16.16.25            Primary
eth0:0            172.16.16.26            Alias 1
eth0:1            172.16.16.27            Alias 2
eth0:2            172.16.16.28            Alias 3
Where “:X” is the device (interface) number to create the aliases for interface eth0. For each alias you must assign a number sequentially. For example, we copying existing parameters of interface “ifcfg-eth0” in virtual interfaces called ifcfg-eth0:0ifcfg-eth0:1 and ifcfg-eth0:2. Go into the network directory and create the files as shown below.
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth0:0
# cp ifcfg-eth0 ifcfg-eth0:1
# cp ifcfg-eth0 ifcfg-eth0:2
Open a file “ifcfg-eth0” and view the contents.
[root@tecmint network-scripts]# vi ifcfg-eth0

DEVICE="eth0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.125
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
Here we only need two parameters (DEVICE and IPADDR). So, open each file with VI editor and rename the DEVICE name to its corresponding alias and change the IPADDR address. For example, open files “ifcfg-eth0:0“, “ifcfg-eth0:1” and “ifcfg-eth0:2” using VI editor and change both the parameters. Finally it will look similar to below.
ifcfg-eth0:0
DEVICE="eth0:0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.126
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
ifcfg-eth0:1
DEVICE="eth0:1"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.127
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
ifcfg-eth0:2
DEVICE="eth0:2"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.128
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
Once, you’ve made all changes, save all your changes and restart/start the network service for the changes to reflect.
[root@tecmint network-scripts]# /etc/init.d/network restart
To verify all the aliases (virtual interface) are up and running, you can use “ifconfig” or “ip” command.
[root@tecmint network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.125  Bcast:172.16.16.100  Mask:255.255.255.224
          inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:237 errors:0 dropped:0 overruns:0 frame:0
          TX packets:198 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25429 (24.8 KiB)  TX bytes:26910 (26.2 KiB)
          Interrupt:18 Base address:0x2000

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.126  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.127  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.128  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000
Ping each of them from different machine. If everything setup correctly, you will get a ping response from each of them.
ping 172.16.16.126
ping 172.16.16.127
ping 172.16.16.128
Sample Output
[root@tecmint ~]# ping 172.16.16.126
PING 172.16.16.126 (172.16.16.126) 56(84) bytes of data.
64 bytes from 172.16.16.126: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.126: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.126: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.126 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms

[root@tecmint ~]# ping 172.16.16.127
PING 172.16.16.127 (172.16.16.127) 56(84) bytes of data.
64 bytes from 172.16.16.127: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.127: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.127: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.127 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms

[root@tecmint ~]# ping 172.16.16.128
PING 172.16.16.128 (172.16.16.128) 56(84) bytes of data.
64 bytes from 172.16.16.128: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.128: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.128: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.128 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms
Seems everything working smoothly, With these new IPs’ you can setup virtual sites in Apache,FTP accounts and many other things.

Assign Multiple IP Address Range

If you would like to create a range of Multiple IP Addresses to a particular interface called “ifcfg-eth0“, we use “ifcfg-eth0-range0” and copy the contains of ifcfg-eth0 on it as shown below.
[root@tecmint network-scripts]# cd /etc/sysconfig/network-scripts/
[root@tecmint network-scripts]# cp -p ifcfg-eth0 ifcfg-eth0-range0
Now open “ifcfg-eth0-range0” file and add “IPADDR_START” and “IPADDR_END” IP address range as shown below.
[root@tecmint network-scripts]# vi ifcfg-eth0-range0

#DEVICE="eth0"
#BOOTPROTO=none
#NM_CONTROLLED="yes"
#ONBOOT=yes
TYPE="Ethernet"
IPADDR_START=172.16.16.126
IPADDR_END=172.16.16.130
IPV6INIT=no
#GATEWAY=172.16.16.100
Save it and restart/start network service
[root@tecmint network-scripts]# /etc/init.d/network restart
Verify that virtual interfaces are created with IP Address.
[root@tecmint network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.125  Bcast:172.16.16.100  Mask:255.255.255.224
          inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:127317 (124.3 KiB)  TX bytes:200787 (196.0 KiB)
          Interrupt:18 Base address:0x2000

eth0:0     Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.126  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.127  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.128  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:3    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.129  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:4    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.130  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

quarta-feira, 16 de outubro de 2013

Enviando Email com comando mailx usando o smtp do Gmail


Tudo em um comando

Para utilizar tudo através de um comando só ....
mailx -v -s "$EMAIL_SUBJECT"
-S smtp-use-starttls
-S ssl-verify=ignore
-S smtp-auth=login
-S smtp=smtp://smtp.gmail.com:587
-S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)"
-S smtp-auth-user=$FROM_EMAIL_ADDRESS
-S smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD
-S ssl-verify=ignore
-S nss-config-dir=~/.mozilla/firefox/yyyyyyyy.default/
$TO_EMAIL_ADDRESS
OBS: trocar yyyyyyyy para uma string de um profile que se encontra dento do diretório do firefox
Este comando irá perguntar pelo conteúdo do email, Digite-o e quando termina-lo, use o “Ctrl+d” para avisar ao mailx que você já terminou. E o seu email será enviado utilizando o smtp do google. pode-se simplificar o processo utilizando o pipe:
echo "The mail content" | mail -v -s ...

Usando um arquivo de configuração

Vocês acharam que tem muitos parametros no comando acima? Sim, são muitos mesmo. Entaum iremos escrever um arquivo de configuração em  ~/.mailrc
set smtp-use-starttls
set nss-config-dir=~/.mozilla/firefox/yyyyyyyy.default/
set ssl-verify=ignore
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=$FROM_EMAIL_ADDRESS
set smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD
set from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)"
Mude o  yyyyyyyy para os seus respectivos valore. Agora podemos enviar o email com o seguinte comando:
$ mailx -v -s "$EMAIL_SUBJECT" $TO_EMAIL_ADDRESS
E zaz ....

segunda-feira, 11 de março de 2013

Monitoramento de pacotes

sudo tcpdump -w test.pcap -i eth1 tcp port 6881 or udp \( 33210 or 33220 \)

fonte: http://linux.byexamples.com/archives/283/simple-usage-of-tcpdump/

Consultando a versão do jboss

Dentro do diretório Lib do jboss...

$unzip -x jboss-main.jar org/jboss/version.properties -d /tmp/
$cat /tmp/org/jboss/version.properties

### =========================================================###
##                                                            ##
##  Holds version properties for JBoss.                       ##
##                                                            ##
### =========================================================###

### $Id: version.properties 101006 2010-02-16 02:34:52Z bstansberry@jboss.com $ ###

# The version of the server
version.major=6
version.minor=0
version.revision=0
version.tag=Final
version.name=Neo
version.cvstag=JBoss_6_0_0_Final

# Build identifiers
build.number=r110228
build.id=r110228
build.date=December 28, 2010 8:08:33 AM EST
build.time=December 28, 2010 8:08:33 AM EST
build.day=December 28, 2010 8:08:33 AM EST

# Information about Java version used to compile
java.version=1.6.0_21
java.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.version=17.0-b16
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vm.info=mixed mode
java.specification.version=1.6
java.class.version=50.0

# Information about the OS the server was compiled on
os.name=Linux
os.arch=amd64
os.version=2.6.32-63.el6.x86_64