Arquivo da categoria: Informática

substituir quebra de linhas com sed

dica do site:  https://unix.stackexchange.com/questions/114943/can-sed-replace-new-line-characters
substituir quebra de linhas por “,” e alterar no próprio arquivo
sed -i ':a;N;$!ba;s/\n/,/g' test.txt

substituir quebra de linhas por “,” e concatenar saída para outro arquivo
sed  ':a;N;$!ba;s/\n/,/g' test.txt > test2.txt

Anúncios

converter .mdb para .csv

dica do site: https://stackoverflow.com/questions/18370387/mdb-export-not-creating-csv-file

 

You first need to install mdb-tools (Ubuntu, Debian):

sudo apt install mdbtools

Then to list the tables do this:

mdb-tables database.mbd 

then with the desired table

mdb-export database.mdb table > table.csv

To export all the tables try this command:

mdb-tables -d ',' database.mdb | xargs -L1 -d',' -I{} bash -c 'mdb-export database.mdb "$1" >"$1".csv' -- {}

permissão para acessar pasta compartilha pelo virtualbox

fonte: https://ubuntuforum-br.org/index.php?topic=121191.0

essa dica resolveu meu problema:

sudo adduser username vboxsf

onde está “username” substitui pelo nome concreto do seu usuário no sistema, pedro, ana, fnorte, enfim, o que for realmente.

Reinicie a máquina virtual.

alterando o machine-id

dica do site: https://www.thegeekdiary.com/centos-rhel-7-how-to-change-the-machine-id/

 

What is machine-id

– The /etc/machine-id file contains the unique machine ID of the local system that is set during installation. The machine ID is a single newline-terminated, hexadecimal, 32-character, lowercase machine ID string. When decoded from hexadecimal, this corresponds to a 16-byte/128-bit string.
– The “machine-id” parameter is added from RHEL 7.1 to identify the machine in the network. Therefore this parameter must be unique.
– But when user clone the virtual machine that is installed RHEL 7.1, the cloned virtual machine’s “machine-id” is not changed, and some virtual machine may have the same “machine-id”.
– The user should change the “machine-id” of the cloned virtual machine for the server to be uniquely identifiable over the network.
– The machine-id is written into the file /etc/machine-id

# cat /etc/machine-id
daab00e07fed481d8ccf145b7affc0c5

Changing the machine-id

1. Clear the original “machine-id”
– The “machine-id” value is written in “/etc/machine-id”.
– We can either remove or empty the machine-id file to clear out the original value.

# rm /etc/machine-id

2. Create the new “machine-id” value
Generate a new machine-id by the “systemd-machine-id-setup” command which populates the remove file again with a new and unique machine-id value.

 

# systemd-machine-id-setup
Initializing machine ID from random generator.

3. Verify
Verify the new value of machine-id.

# cat /etc/machine-id
2175d9b2344a499abd87920c6f76f9a1
NOTE : This is applicable to CentOS / RHEL version 7.1 and above.

alterar resolução de ubuntu server com x11vnc e LXDE

tenho um ubuntu server 18.04.2 com o x11vnc instalando e ambiente gráfico LXDE

porém quando eu acesso via vnc a resolução da tela é muito pequena

mas neste link: https://wiki.ubuntu.com/X/Config/Resolution

o comando abaixo funcionou pra mim:
este comando deve ser exutado dentro do ambiente gráfico, não funciona pelo console remotamente.

xrandr --output VGA1 --rate 60 --mode 800x600 --fb 1850x950 --panning 1850x950

 

erro de conexão ao PostgreSQL

ao tentar o acesso remoto ao postgresql retorna os erros abaixo:


psql: FATAL: no pg_hba.conf entry for host "xxx.xxx.xxx.xxx", user "postgres", database "postgres", SSL on
FATAL: no pg_hba.conf entry for host "xxx.xxx.xxx.xxx", user "postgres", database "postgres", SSL off

mas essa dica deste site me ajudou a resolver o problema:
https://dba.stackexchange.com/questions/83984/connect-to-postgresql-server-fatal-no-pg-hba-conf-entry-for-host

 

The way I solved this was:

Added the line as below in pg_hba.conf:

hostnossl    all          all            0.0.0.0/0  trust        

and this was modified in postgresql.conf, as shown:

listen_addresses = '*'  

 

Add or edit the following line in your postgresql.conf :

listen_addresses = '*'

Add the following line as the first line of pg_hba.conf. It allows access to all databases for all users with an encrypted password:

# TYPE DATABASE USER CIDR-ADDRESS  METHOD
host  all  all 0.0.0.0/0 md5

Restart Postgresql after adding this with service postgresql restart or the equivalent command for your setup.

Erro “Connection refused” em conexão ssh

O ssh tava apresentando o erro abaixo:

ssh: connect to host 192.168.XXX.XXX port 22: Connection refused

 

até o passo 3, resolveu meu problema
  1. First check openssh-server installed in that system.
  2. check the status of ssh service, make ssh service start.
    sudo service ssh status    
    sudo service ssh start
    
  3. Check iptables in that system that port 22 is blocked. Just allow port in iptables and then check.
    sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
    
  4. Else change port number of ssh from 22 to 2222 by editing
    vi /etc/ssh/sshd_config    
    /etc/init.d/ssh restart.
    

pra mim, resolveu o problema em um ubuntu server 18.04.2