Connect local port 9999
to 22
on 192.168.1.2
. More documentation
Recurring commands
Run in
Bridge two TCP ports
Connect local port 9999
to 22
on 192.168.1.2
. More documentation
socat tcp-listen:9999,reuseaddr,fork tcp-connect:192.168.1.2:22
Get certificate data from domain
DOMAIN=codigoparallevar.com
openssl s_client -connect $DOMAIN:443 </dev/null
Get certificate expiration date
DOMAIN=codigoparallevar.com
openssl s_client -connect $DOMAIN:443 </dev/null 2>/dev/null | openssl x509 -noout -dates
Get program progress reading a file
On post
Leer el progreso de lectura de un archivo
#!/usr/bin/env bash
# Check that we have at least a PID
if [ -z "$1" ];then
echo "$0 <PID> [<FD>]"
exit 1
fi
set -eu # Bail on any error
PID=$1
FD=${2:-} # Take FD if we have second parameter, else consider it empty
if [ -z "$FD" ];then
# Show the user the available file descriptors
echo "Select a file descriptor:"
for i in /proc/$PID/fd/*;do
printf " %s: " $(basename $i)
readlink $i
done
read -p "FD: " FD
fi
FSIZE=$(stat -L /proc/$PID/fd/$FD --printf=%s) # Read full file size
while [ 1 ];do
# Stop if the process has finished reading the file
if [ ! -f /proc/$PID/fdinfo/$FD ];then
break
fi
# Read position on file
x=$(cat "/proc/$PID/fdinfo/$FD"|grep pos: |cut -d: -f2|tr -d '\t ')
# Convert that position into a % of the file size
PER10000=$(( $x * 10000 / $FSIZE ))
if [ $PER10000 -le 100 ];then
# Less than 1%
printf " 0.%02i%%\n" $(( $PER10000 ));
else
# More than 1%
printf "%3i.%02i%%\n" $(( $PER10000 / 100 )) $(( $PER10000 % 100 ));
fi
# Wait for the next loop
sleep 1
done
Check webcam funcionality
From
List video devices
ls -ltr /dev/video*
See webcam
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30
Configure default browser
## Old style
# sudo update-alternatives --config x-www-browser
## New style
xdg-settings set default-web-browser <desktop file inside ~/.local/share/applications/>
Set timezone
See current timezone
timedatectl show|grep Timezone
: Timezone=Europe/Madrid
List timezones
timedatectl list-timezones | head
Africa/Abidjan |
Africa/Accra |
Africa/Addis_Ababa |
Africa/Algiers |
Africa/Asmara |
Africa/Asmera |
Africa/Bamako |
Africa/Bangui |
Africa/Banjul |
Africa/Bissau |
Set timezone
timedatectl set-timezone Europe/Madrid
Switch off screen