jueves, 30 de abril de 2020

vim in nocompatible mode

If the arrow keys make a mess (like typing A, B, C or D) in insert mode, try the nocompatible mode (-N) (makes vim work "Not fully Vi compatible"):

vi -N test.txt  

sábado, 7 de diciembre de 2019

bash autocomplete

COMPLETE_OPTIONS="host1 host2"
function _ssh_complete {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  COMPREPLY=( $(compgen -W "${COMPLETE_OPTIONS}" -- ${cur}) )
}
complete -F _ssh_complete ssh

sábado, 17 de enero de 2015

ipfilter testing

add another port to sshd:
$ grep Port /etc/ssh/sshd_config
Port 22
Port 44444


test it works:
$ telnet 127.0.0.1 44444

block that port:
$ cat /etc/ipf/ipf.conf
set intercept_loopback true;
pass in all
pass out all
block in from any to any port = 44444
#pass in from 127.0.0.1 to any port = 44444


test it's blocked
$ telnet 127.0.0.1 44444

just in case we screw:
$ sudo crontab -l | tail -n1
* * * * * /usr/sbin/svcadm disable network/ipfilter

martes, 11 de noviembre de 2014

newline in sed or echo on Mac

$ echo hello | sed 's/hello/hello\'$'\nbye/'
hello
bye




$ echo hello | sed 's/hello/hello\'$'\n''bye1\'$'\nbye2/'
hello
bye1
bye2


$ sed -i '' 's/hello/hello\'$'\nbye/g' somefile.txt

martes, 10 de junio de 2014

Fast copy of directories using nc

receiving end (using port 10000):
nc -l 10000 | tar x

sending end:
cd parent_dir
tar cf - *hello* | nc receiving_hostname 10000

martes, 26 de noviembre de 2013