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, 13 de agosto de 2014

Criando usuario com grants no mysql


Forma 1

sudo grep 'temporary password' /var/log/mysqld.log

2016-11-29T17:41:59.782183Z 1 [Note] A temporary password is generated for root@localhost: *ZxXXOm>,y:y3!Z

copie a senha temporaria 

mysql -u root -p

Enter password: <<infomre a senha temporaria>>

ALTER USER 'root'@'localhost' IDENTIFIED BY 'nova senha';

flush privileges;

turn off password validation

  1. Login to the mysql server as root mysql -h localhost -u root -p
  2. Run the following sql command: uninstall plugin validate_password;

Forma 2

Login in mysql using:
$ mysql -u root -p
First create a database using:

mysql> create database dbname;
Query OK, 1 row affected (0.00 sec)

Then in mysql shell create new user using:

mysql> create user 'username'@'localhost' IDENTiFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on dbname.* to 'username'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)

Or you can use ‘%’ wildcard if you want to connect mysql from any host:

mysql> create user 'username'@'%' IDENTiFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on dbname.* to 'username'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)

fonte: http://abhinavkush.wordpress.com/2011/02/21/create-new-mysql-user-with-grant-option/