
입력하면 다음과 같은 정보가 출력되는 명령이 있습니까?
- 네트워크 연결이 유선 또는 무선인 경우
- 무선 네트워크인 경우 무선 네트워크 이름
- 신호가 얼마나 강한지
답변1
터미널 'iw'를 입력하고 키를 누르면 무선 인터넷과 관련된 모든 항목이 Tab표시되고 신호 및 네트워크 인터페이스에 대한 통계를 표시해 봅니다.iw iw iwconfig iwevent iwgetid iwlist iwpriv iwspy
iwconfig
답변2
첫 번째 질문에 대한 쉘 스크립트를 만들 수 있습니다.
#!/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
이를 ~/scripts/gatewayinfo.sh 등으로 저장하고, 를 통해 실행 가능하게 만들고 chmod a+x ~/scripts/gatewayinfo.sh
별칭 정의(예: )를 만들어 쉽게 호출할 수 있습니다 ~/.alias
.alias inetinfo="~/scripts/gatewayinfo.sh"