Comandos Basicos Bash! =)
Montar uma imagem raw
# ver filesystem
sudo fdisk -ul file.img
# criar um loop device
sudo losetup -fs file.img -o $((START_SECTPR*512)) // depende do filesystem
# montar o loop device
sudo mount -o loop /dev/loop0 /mnt
Bloquear CTRL+C no Bash
#!/bin/bash
trap '' 2 # ou INT
echo "This is a test. Hit [Ctrl+C] to test it..."
sleep 20
trap 2
Converter um IPv4 inteiro em xxx.xxx.xxx.xxx
/* Código em C */
int i = 171485376;
printf("%d.%d.%d.%d\n", i & 0xff, (i>>8) & 0xff, (i>>16) & 0xff, i>>24);
/* 192.168.56.10 */
Substituir \n com o sed
$ sed ':a;N;$!ba;s/\n/NADA/g' teste
Deletar somente binários ELF
$ for i in *; do file "$i" | grep -Fqw "ELF" && rm "$i"; done
Configurar data e hora
# date -s MMDDHHmmAAAA
Via NTP:
# apt-get install ntpdate
# ntpdate ntp.cais.rnp.br
# ntpdate ntp.cais.rnp.br
Enviar a data e hora do sistema para o BIOS
# hwclock --systohc
Compartilhamento de conexão
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Redirecionamento para host
# iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 81 -j DNAT --to-destination 192.168.0.100
Redirecionamento de porta
# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
Backup de arquivo
$ cp arquivo.conf{,.old}
ou mesmo
$ cp arquivo.conf{,.`date +%Y%m%d`}
watch sem watch
$ while :; do netstat -na; sleep 2; done
Túnel SSH
ssh -ND 9999 usuario@host
-N -> não executa comandos remotos
-D 9999 -> porta do SOCKS local
É necessário configurar o browser para usar o SOCKS v5 localhost:9999.
Montar compartilhamento Windows
# mount -t smbfs //192.168.0.1/dados /mnt -o username=admin,password=1234
chmod em tipos de arquivo
$ find . -type d -exec chmod 755 {} \;
$ find . -type f -exec chmod 644 {} \;
$ find . -type f -name '*.htm*' -exec chmod 644 {} \;
$ find . -type f -exec chmod 644 {} \;
$ find . -type f -name '*.htm*' -exec chmod 644 {} \;
Testar SSLv2
$ openssl s_client -connect localhost:443 -ssl2
$ openssl ciphers -v 'HIGH'
$ openssl ciphers -v 'HIGH'
dos2unix sem dos2unix
$ cat -vet dos.txt | sed 's/\^M\$//g' > unix.txt
ou
$ tr -d '\r' < dosfile > unixfile
Renomear placas de rede em distros Debian-based
# vi /etc/udev/rules.d/70-persistent-net.rules
0 comentários:
Postar um comentário