πΎ Archived View for gmi.osiux.com βΊ dame-una-consola.gmi captured on 2024-06-16 at 12:22:51. Gemini links have been rewritten to link to archived content
β¬ οΈ Previous capture (2023-09-28)
-=-=-=-=-=-=-
En sistemas `*nix` todo es un archivo, es decir todos los dispositivos, las particiones de disco, CDs, diskettes, tarjeta de sonido, video, etc.
r = read 4 w = write 2 x = execute 1
# usuario y grupo todo, el resto nada. 770 rwxrwx-- # solo dueΓ±o y grupo leer y ejecutar. 550 r-xr-x-- # solo dueΓ±o tiene escritura, todos pueden leer. 644 rw--r--r
βββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ β β β βββββββββββͺββββββββββββββββββββββββββββββββββββββββ‘ β `man` β leer el manual, es el mas importante! β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `echo` β eco, imprime texto en pantalla β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `ls` β listar archivos y directorios β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `pwd` β mostrar directorio actual β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `cd` β cambiar directorio β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `cp` β copiar β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `rm` β borrar β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `mv` β mover β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `mkdir` β crear directorio β βββββββββββΌββββββββββββββββββββββββββββββββββββββββ€ β `cat` β muestra contenido de un archivo β βββββββββββ΄ββββββββββββββββββββββββββββββββββββββββ
βββββββββββ¬ββββββββββββββββββββββββββββββββββββββ β β β βββββββββββͺββββββββββββββββββββββββββββββββββββββ‘ β `more` β pagina la salida de un archivo β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `sort` β ordena β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `wc` β cuenta cantidad lΓneas y palabaras β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `grep` β filtra un texto β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `sed` β editor de texto en lΓnea β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `awk` β procesa texto β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `find` β busca archivos β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `chmod` β cambia permisos β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `chown` β cambia el propietario de un archivo β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `alias` β define un alias para un comando β βββββββββββΌββββββββββββββββββββββββββββββββββββββ€ β `ps` β muestra procesos en ejecucion β βββββββββββ΄ββββββββββββββββββββββββββββββββββββββ
En lugar de tipear podemos enviar un archivo como la entrada estandard de un comando:
mail osiux@osiux.com.ar < archivo.txt
Podemos almacenar en un archivo el resultado de la ejecuciΓ³n de un comando:
# sobreescribe ls *.png >lista.txt # agrega ls *.txt >>lista.txt
Convertir la salida standard de un comando en la entrada standard de otro comando permite conectar procesos:
ls | sort
βββββββββββ¬ββββββββββββββββββββββββββββββββ β β β βββββββββββͺββββββββββββββββββββββββββββββββ‘ β `[a-z]` β rango de la **a** a la **z** β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `[A-Z]` β rango de la **A** a la **Z** β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `[0-9]` β rango de 0 a 9 β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `[^..]` β negaciΓ³n β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `^` β principio de lΓnea β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `gemini - kennedy.gemi.dev β fin de lΓnea β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `.` β cualquier caracter β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `?` β cero o una apariciΓ³n β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `*` β ninguna o muchas repeticiones β βββββββββββΌββββββββββββββββββββββββββββββββ€ β `+` β una o mas repeticiones β βββββββββββ΄ββββββββββββββββββββββββββββββββ
mutt, pine, fetchmail reminder, wyrd vim, emacs, joe, nano, mcedit, vim-outliner w3m, lynx, elinks, rtorrent, newsbeuter freetalk, cabber, irssi, weechat, center-im moc, rippit, aumix, alsamixer ftp, ncftp, wget, httrack mc, rsync, rdiff-backup vlc, mplayer
ssh, telnet, screen, ajaxterm tig, git, svn, bzr, mercurial mysql, msqldump python, ipython, bpython graphviz, imagemagick, gnuplot parted, testdisk, dd, partimage gnupg, dmsetup, bcrypt, truecrypt htop, ethtool, netcat, nmap, wicd-curses diff, patch, make, base64, vim-diff vnstat, iftop, nload, wicd-curses pdf2text, html2text, python-docutils, rst2pdf
# cuΓ‘l es mi ip? ip r | grep -o src.[0-9.]+ | awk '{print $2}' # cuΓ‘l es mi mac? ifconfig eth0 | grep HWaddr | awk '{print $5}' # sΓ© la mac, pero cΓΊal es la ip? tcpdump -ennqti eth0 \( arp or 600pxp \) | grep "48:5b:39:6e:f4:d4" # encender la compu remotamente wakeonlan 48:5b:39:6e:f4:d4 # quΓen estΓ‘ consumiendo todo el ancho de banda? iftop -i eth0 # ips entregadas por dhcp? egrep -o "[0-9]+>[0-9]+>[0-9]+>[0-9]+" dhcpd.leases | uniq | wc -l # obtener una lΓnea especΓfica de un archivo head -30 /var/log/messages | tail -1 # reemplazar texto en varios archivos find -name '*.php' | while read i;do cat $i | \ sed s/GNU/GPL/g >$i.tmp;cat $i.tmp>$i;done
# buscar en el contenido de una web w3m -dump http://barrapunto.com | grep -i -C2 android w3m -dump http://debian.gmi/News | grep -i squeeze | grep frozen >/tmp/debian # notificar estado baterΓa if [ "$BAT_STATUS" = "Discharging" ];then \ if [ $BAT_PERCENT -le 25 ];then \ notify-send -u critical "$MSG" "$BAT_PERCENT";fi else;notify-send "$MSG";fi
βββββββββ¬ββββββββββββββββββββββββββββββββ β β β βββββββββͺββββββββββββββββββββββββββββββββ‘ β `Esc` β cambia a modo visual β βββββββββΌββββββββββββββββββββββββββββββββ€ β `a` β agregar texto posiciΓ³n actual β βββββββββΌββββββββββββββββββββββββββββββββ€ β `A` β agregar texto al final lΓnea β βββββββββΌββββββββββββββββββββββββββββββββ€ β `i` β inserta en la posiciΓ³n actual β βββββββββΌββββββββββββββββββββββββββββββββ€ β `I` β inserta al inicio de la lΓnea β βββββββββΌββββββββββββββββββββββββββββββββ€ β `r` β reemplazar un caracter β βββββββββΌββββββββββββββββββββββββββββββββ€ β `R` β modo reemplazar β βββββββββΌββββββββββββββββββββββββββββββββ€ β `x` β borra caracter a la derecha β βββββββββΌββββββββββββββββββββββββββββββββ€ β `X` β borra caracter a la izquierda β βββββββββΌββββββββββββββββββββββββββββββββ€ β `y` β copiar β βββββββββΌββββββββββββββββββββββββββββββββ€ β `p` β pegar β βββββββββ΄ββββββββββββββββββββββββββββββββ
βββββββββββ¬βββββββββββββββββββββββββββββββββ β β β βββββββββββͺβββββββββββββββββββββββββββββββββ‘ β `d` β eliminar β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `.` β repite ΓΊltima funciΓ³n β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:` β cambia a modo comando β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:q` β salir si no hubo cambios β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:q!` β salir sin guardar cambios β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:wq` β guardar y salir β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:e` β editar archivo β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:.` β lΓnea actual β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:1,.` β desde primer lΓnea a la actual β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:.,gemini - kennedy.gemi.dev β desde lΓnea actual a la ΓΊltima β βββββββββββΌβββββββββββββββββββββββββββββββββ€ β `:5,15` β desde lΓnea 5 a la nΓΊmero 15 β βββββββββββ΄βββββββββββββββββββββββββββββββββ
telnet localhost 25 HELO branca.osiux.com.ar MAIL FROM: osiris@branca.osiux.com.ar RCPT TO: osiux@branca.osiux.com.ar DATA Subject: prueba correo local usando telnet nero cuando nos tomamos unos fernets? . 250 2.0.0 Ok: queued as 6626586DE6 QUIT
telnet google.com 80 Trying 209.85.195.104... Connected to google.com. GET / HTTP/1.0 302 Found Location: http://www.google.com.ar/ Content-Type: text/html; charset=UTF-8 <HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1>The document has moved <A HREF="http://www.google.com.ar/">here</A>. </BODY></HTML> Connection closed by foreign host.
# Definir Alias set alias sugar='mysql --default-character-set=utf8 -u sugar -psugar -B sugar' # Ejecutar consulta echo "SELECT user_name FROM users WHERE is_admin = 1;" | sugar # Listado de Tablas set alias tablas='echo "show tables" | sugar | grep -v Tables_in | sort -u' # Listado Tabla Campo set alias tablacampos='echo "show tables" | sugar | grep -v Tables_in | \ while read t; do d=$(echo "desc "$t";" | cct15 | grep -v Field | awk1); \ for c in $d;do echo $t"__"$c;done ;done' # Vaciar todas las tablas que contengan la palabra *calls* sugar < $(echo "show tables" | sugar | grep calls | \ while read t;do echo "TRUNCATE table $t;";done)
ConexiΓ³n en `.vimrc`
command -range=% Q :<line1>,<line2>w !mysql -u sugar -psugar -B sugar -t -v -v -v
Ejecutar todo el archivo
:Q
Ejecutar la lΓnea actual
:. Q
Ejecutar un rango de lΓneas
:3,8 Q
Ejecutar desde lΓnea actual hasta el final
:.,$ Q
Usar diccionarios `CTRL-X CTRL-K`
:set dictionary=tablas, tablacampo
c=0;ls | grep jpg | while read f; \ do mv -v $f monte-hermoso-2010-'$c .jpg'; \ c=$[$c+1];done for i in *.jpg do convert -filter cubic -resize 640 $i 640-$i done
digraph topology { "10.4.14.225" [color=red]; "10.4.14.33" [color=orange]; "10.4.14.161" [color=yellow]; "172.16.169.52" [color=red]; "172.16.169.55" [color=orange]; "10.4.14.34" [color=yellow]; "172.16.169.52" [color=red]; "10.4.10.1" [color=orange]; "10.4.14.225" -> "10.4.14.33"[label="1.08", style=solid]; "10.4.14.225" -> "10.4.14.161"[label="1.20", style=solid]; "10.4.14.225" -> "172.16.169.52"[label="1.37", style=solid]; "10.4.14.225" -> "172.16.169.55"[label="1.26", style=solid]; "10.4.14.225" -> "10.4.14.34"[label="1.11", style=solid]; "10.4.10.1" -> "10.4.14.34"[label="1.07"]; "172.16.169.52" -> "10.4.14.225"[label="1.36"]; "172.16.169.52" -> "10.4.14.161"[label="1.00"]; "172.16.169.52" -> "172.16.169.55"[label="1.11"]; "10.4.14.161" -> "172.16.169.52"[label="1.00"]; "10.4.14.161" -> "172.16.169.55"[label="1.00"]; "10.4.14.161" -> "10.4.14.188"[label="1.00"]; "10.4.14.161" -> "10.4.14.225"[label="1.23"]; "10.4.14.33" -> "10.4.12.161"[label="4.18"]; "10.4.14.33" -> "10.4.14.225"[label="1.08"]; "10.4.14.33" -> "10.4.14.34"[label="1.00"]; }
dot -Tpng grafo.dot >grafo.png
ping -c10 google.com | grep 600pxp_seq" \ | tr "=" " " | awk '{print $7,$11}' >ping.dat echo 'set title "ping" \ set xlabel "milisegundos" \ set ylabel "secuencia" \ set term png \ set output "ping.png" \ plot "ping.dat" using 1:2 with lines \ quit ' >ping.plt gnuplot ping.plt
+---------------------+ +---+ | malbec c978 | | S | +---------------------+ +-------------------+ | W |<-->| eth0 192.168.10.5 | +------+ | syrah cDBF | | I | | | +------+ | cYEL | +-------------------+ | T | | ppp0 186.109.85.126 |<-->| ADSL |<->| INET | | eth0 192.168.10.4 |<->| C | | | +------+ | {o} | +-------------------+ | H |<-+ | eth2 192.168.20.3 |<-+ +------+ ^ +---+ | +---------------------+ | | | | v | | /---------\ | | | HP 4200 | | +---------------------+ | | c897 | +---+ | | torrontes c789 | | \---------/ | S |<-+ +---------------------+ | | W |<-->| eth0 192.168.10.5 | | | I | | | | | T | | eth1 192.168.20.5 |<-+ | C | +---------------------+ | H |<-+ +---+ |
rst2pdf dame-una-consola.txt rst2pdf -s style -b 1 dame-una-consola.txt
1: http://pub.osiux.com/charlas
2: https://pub.osiux.com/charlas/dame-una-consola-slides.pdf
4: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/e46ec52748a7ecc60f09c3b95e363e92eaa0bebc
5: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/5c8643b83930c6269569c76602608bd33f93008b
6: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/bbc3bbc728f2a3eeb4fe2e0a012ee5d8d613e3ef
7: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/74165280ffad770d1f8b8acbfa7f22b95459b52a
8: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/5ad3755a3df07cdfbdc75d56cae06db2fee4b5f2
9: https://gitlab.com/osiux/osiux.gitlab.io/-/commit/e4dc30e2a202e7ad44bddc761065e9aeb0a31bd3