
Existe um comando onde, quando inserido, gera informações como:
- Se a conexão de rede for com ou sem fio
- se for uma rede sem fio, o nome da rede sem fio
- Quão forte é o sinal
Responder1
Basta digitar no terminal 'iw' e pressionar Tabe você verá algo como
iw iw iwconfig iwevent iwgetid iwlist iwpriv iwspy
todos aqueles relacionados à internet sem fio, tente iwconfig
mostrar estatísticas sobre sinal e interface de rede.
Responder2
Você pode transformar isso em um script de shell para a primeira pergunta:
#!/bin/bash
if ! /bin/ip route | grep -q ^default; then
echo "No Internet connection"
echo
exit 0
fi
if="$(/bin/ip route |
awk '$1 == "default" {for (i=2;i<=NF;i++) if ($i == "dev") { i++;print $i; exit}}')"
if [ -z "$if" -o \! -e /sys/class/net/"$if" ]; then
echo "Sorry, some error, aborting."
echo
exit 1
fi
if /usr/sbin/iw dev "$if" info &>/dev/null; then
echo "The Internet connection is wireless."
echo
# uncomment the next line to start iwconfig
# iwconfig
else
echo "The Internet connection is wired."
echo
fi
Você pode salvá-lo como, por exemplo, ~/scripts/gatewayinfo.sh, torná-lo executável chmod a+x ~/scripts/gatewayinfo.sh
e chamá-lo facilmente criando uma definição de alias (por exemplo ~/.alias
, ):alias inetinfo="~/scripts/gatewayinfo.sh"