Network Related Scripts

I know all the helpful members who try to diagnose/resolve network issues hang out here. I think I dreamt up a really useful network info command today. This command returns only the essential info and removes all the cruft from the super long hwinfo output.

hwinfo --netcard --wlan --bluetooth | grep -Ei "model\:|driver\:|status\:|cmd\:|file\:|detected\:" | grep -v "Config Status" 

Try it and give me some feedback.

Please feel free to use it if you like it.

Here are links to other useful scripts/commands that I added later on in this thread that are useful for troubleshooting network issues.

Command to search for recently updated components that can affect networking:

Command to install the linux-headers for every installed kernel:

Command to disable MAC Adress Randomization:

Command to automatically generate kernel boot parameters:

[john@Dell13LapTop ~]$ hwinfo --netcard --wlan --bluetooth | grep -Ei "model\:|driver\:|status\:|cmd\:|file:|detected\:" | grep -v "Config Status"
  Model: "Intel Wireless 3165"
  Driver: "iwlwifi"
  Device File: wlp1s0
  Link detected: yes
    Driver Status: iwlwifi is active
    Driver Activation Cmd: "modprobe iwlwifi"
  Model: "Intel Bluetooth Device"
  Driver: "btusb"
    Driver Status: btusb is active
    Driver Activation Cmd: "modprobe btusb"

@tbg Looks good to me

1 Like

Thanks. The thing I like the most is it includes the “Driver Activation Cmd” unlike inxi -Fxzc0. When you want to modprobe, sometimes the driver name is different than what is required in the modprobe command. With this output you’re not left guessing what the correct modprobe command is.

Gotta love those pipes :slight_smile:

I’m also happy to see this command returns no ‘sensitive’ information … unless someone considers a model sensitive.

1 Like

Try to remember that command, (hope your memories better than mine). :smile:

@tbg - that is what aliases are for!

Works well here.


Bookmark this - this could easily become one of the most linked posts in the (near) future!

Yes indeed. I will be adding this to my ever growing list of aliases shortly. I can never remember my wlan ID, as it’s such an obnoxious string of letters and numbers. Damn them for changing that.

Here’s my output. Notice the extra info for the r8168/9 drivers. You may also notice my WiFi driver and modprobe names are different. Very handy info to have.

Model: "Gigabyte Onboard Ethernet"
  Driver: "r8168"
  Device File: enp4s0
  Link detected: no
    Driver Status: r8169 is not active
    Driver Activation Cmd: "modprobe r8169"
    Driver Status: r8168 is active
    Driver Activation Cmd: "modprobe r8168"
  Model: "Realtek RTL8812AU 802.11a/b/g/n/ac WLAN Adapter"
  Driver: "rtl8812au"
  Device File: wlp0s26f7u4
  Link detected: yes
    Driver Status: 8812au is active
    Driver Activation Cmd: "modprobe 8812au"

Added this to my .bashrc

101 alias tbg='hwinfo --netcard --wlan --bluetooth | grep -Ei "model\:|driver\:|status\:|cmd\:|file:|detected\:" | gre    p -v "Config Status"'


here is my output:

[suchus@PSYCHO ~]$ tbg
  Model: "Marvell 88W8897 [AVASTAR] 802.11ac Wireless"
  Driver: "mwifiex_pcie"
  Device File: wlp1s0
  Link detected: yes
    Driver Status: mwifiex_pcie is active
    Driver Activation Cmd: "modprobe mwifiex_pcie"
  Model: "Marvell Bluetooth and Wireless LAN Composite Device"
  Driver: "btusb"
    Driver Status: btusb is active
    Driver Activation Cmd: "modprobe btusb"

Too funny. Thanks for the compliment. :blush:

Glad to see it’s popular.

1 Like

This is a neat script. Thanks !

1 Like
Thanks :-)

➜ ~ hwinfo --netcard --wlan --bluetooth | grep -Ei “model:|driver:|status:|cmd:|file:|detected:” | grep -v “Config Status” [255]
Model: “Broadcom BCM43228 802.11a/b/g/n”
Driver: “wl”
Device File: wlp12s0
Driver Status: bcma is not active
Driver Activation Cmd: “modprobe bcma”
Driver Status: wl is active
Driver Activation Cmd: “modprobe wl”
Model: “Intel 82579V Gigabit Network Connection”
Driver: “e1000e”
Device File: eno1
Link detected: yes
Driver Status: e1000e is active
Driver Activation Cmd: “modprobe e1000e”
Model: “Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller”
Driver: “r8168”
Device File: enp13s0
Link detected: no
Driver Status: r8169 is not active
Driver Activation Cmd: “modprobe r8169”
Driver Status: r8168 is active
Driver Activation Cmd: “modprobe r8168”

We have you to thank. :slight_smile:

1 Like

Wow, I just expanded your output and read it. Total shocker. This output is actually far more useful than I first realized. The output lists not only the driver modules that are installed and loaded, but also the unused kernel drivers and their modprobe command.

This will make troubleshooting so much easier, as I will no longer have to refer to the Archwiki to find the alternate drivers to use. I had no idea this extra benefit was hidden away inside the hwinfo command. That is just a total bonus. Thanks @SGS for posting your output. That just made my day. :smile: :clap: :star_struck: :exploding_head:


Congrats @tbg , very nice work!
One newbie qustion:
I noticed you “backslashed” : , all but file .
Was that intentional or just forgotten?
I tried it both with(out) and gives the same result, no errors…


That was simply an omission on my part. If it didn’t work as I added different search criteria I would have noticed it. As you say, it does work, so no harm no foul. Good pickup.

I will edit it for consistency.


When a new update breaks networking, users are often told to check /var/log/pacman.log to find which package may have caused the breakage. Unfortunately, the list can be very large at times and users may be confused as to what may have actually been responsible.

I have written a search string to narrow down the list of important packages that might have been responsible for the network breakage. This reduces the list to manageable size so that the offending package can hopefully be found easily.

If anyone can think of further important packages I might have missed from my search terms please pass them along so I can add them to the list.

I used this for the first time today on a support thread and it seemed to work very well. Test it out and see what you think of it. Any suggestions for improvement would be greatly appreciated.


Here is an updated version of my original command with more search parameters that may be preferable to my original version.

Search for recent updates that can affect connectivity.

The following command will search for recent updates that can affect connectivity:

cat /var/log/pacman.log | grep -i "d systemd (\|ed linux\|mware\|twork\|dkms ins\|a-nm\|nm-c\|ufw\|dhc\|dns\|wpa\|vnc" | grep -v "head\|nvidia"  | tail -n 30

Hopefully the output from that command may provide some inkling as to what updated package might have created the new problem.

Please post the output of the above command.


i cannot help you much with figuring out, which packages you should look for, but i can suggest improvements.

i have taken (with a small modification) your output and used “fzf” (this package needs to be installed on your system) to display it in an easily searchable and visually pleasing manner.

here is your “raw” data:

tail -5000 /var/log/pacman.log | grep -i "ed linux\|mware\|twork\|dkms ins\|a-nm\|nm-c\|ufw\|dhc\|dns\|wpa" | grep -v "head\|nvidia" | fzf -i --multi --exact --no-sort --select-1 --ansi --query="$argument_input" --cycle --tac --reverse --bind=right:half-page-down,left:half-page-up --margin="4%,1%,1%,2%" --inline-info --header='Use arrow key and PageUp/Down to navigate. Press ESC or CTRL+C to quit' --prompt=='Enter string to filter displayed list of recent Pacman changes > '

and here it is with some visual improvements:

tail -5000 /var/log/pacman.log | grep -i "ed linux\|mware\|twork\|dkms ins\|a-nm\|nm-c\|ufw\|dhc\|dns\|wpa" | grep -v "head\|nvidia" | awk '{ $3="" ; $5="\t\033[1m" $5 " \033[0m" ; print }' | fzf -i --multi --exact --no-sort --select-1 --ansi --query="$argument_input" --cycle --tac --reverse --bind=right:half-page-down,left:half-page-up --margin="4%,1%,1%,2%" --inline-info --header='Use arrow key and PageUp/Down to navigate. Press ESC or CTRL+C to quit' --prompt=='Start typing to filter list > '

here is the output on my system:

simply modify the first part (before “fzf” or “awk”) in order to experiment with it.

feel free to use my code in any way you want.


Thank you so much. That was very nice of you.

Much appreciated.

This is my output as it is currently formatted:

$ cat /var/log/pacman.log | grep -i "ed linux\|mware\|twork\|dkms ins\|a-nm\|nm-c\|ufw\|dhc\|dns\|wpa" | grep -v "head\|nvidia"  | tail -n 30
[2018-10-19 12:08] [PACMAN] Running 'pacman -Rns zd1211-firmware'
[2018-10-19 12:08] [ALPM] removed zd1211-firmware (1.5-1)
[2018-10-27 10:29] [PACMAN] Running 'pacman -U'
[2018-10-27 10:30] [ALPM] upgraded linux-firmware (20180825.fea76a0-1 -> 20181026.1cb4e51-0.1)
[2018-10-27 11:02] [ALPM] upgraded glib-networking (2.56.1-1 -> 2.58.0-1)
[2018-10-27 11:03] [ALPM] upgraded dnsmasq (2.79-1 -> 2.80-1)
[2018-10-27 11:03] [ALPM] upgraded dnssec-anchors (20170711-1 -> 20181003-1)
[2018-10-27 11:03] [ALPM] upgraded kdnssd (5.50.0-1 -> 5.51.0-1)
[2018-10-27 11:03] [ALPM] upgraded gufw (18.04.0-2 -> 18.10.0-1)
[2018-10-27 11:03] [ALPM] upgraded kdenetwork-filesharing (18.08.1-1 -> 18.08.2-1)
[2018-10-27 11:04] [ALPM] upgraded linux414 (4.14.71-1 -> 4.14.78-1)
[2018-10-27 11:04] [ALPM] upgraded linux414-r8168 (8.045.08-47 -> 8.045.08-51)
[2018-10-27 11:04] [ALPM] upgraded linux418 (4.18.9-1 -> 4.18.16-1)
[2018-10-27 11:05] [ALPM] upgraded linux418-r8168 (8.045.08-5 -> 8.045.08-10)
[2018-10-27 11:05] [ALPM] upgraded linux44 (4.4.157-1 -> 4.4.162-1)
[2018-10-27 11:05] [ALPM] upgraded linux44-r8168 (8.045.08-32 -> 8.045.08-36)
[2018-10-27 11:05] [ALPM] upgraded linux49 (4.9.128-1 -> 4.9.135-1)
[2018-10-27 11:06] [ALPM] upgraded linux49-r8168 (8.045.08-36 -> 8.045.08-41)
[2018-10-27 11:06] [ALPM] upgraded networkmanager (1.12.3dev+1+g0a3755c17-1 -> 1.14.4-1)
[2018-10-27 11:06] [ALPM] upgraded networkmanager-openvpn (1.8.4-1 -> 1.8.8-1)
[2018-10-27 11:06] [ALPM] upgraded networkmanager-pptp (1.2.6-1 -> 1.2.8-1)
[2018-10-27 11:06] [ALPM] upgraded networkmanager-qt (5.50.0-1 -> 5.51.0-1)
[2018-10-27 11:06] [ALPM] upgraded plasma-nm (5.13.5-1 -> 5.14.2-1)
[2018-10-27 11:07] [ALPM-SCRIPTLET] ==> dkms install rtl8812au/5.2.20.r9.gaca1e06 -k 4.14.78-1-MANJARO
[2018-10-27 11:09] [ALPM-SCRIPTLET] ==> dkms install rtl8812au/5.2.20.r9.gaca1e06 -k 4.18.16-1-MANJARO
[2018-10-27 11:10] [ALPM-SCRIPTLET] ==> dkms install rtl8812au/5.2.20.r9.gaca1e06 -k 4.9.135-1-MANJARO
[2018-10-27 11:12] [ALPM-SCRIPTLET] ==> dkms install rtl8812au/5.2.20.r9.gaca1e06 -k 4.4.162-1-MANJARO
[2018-10-27 11:26] [ALPM] installed linux419 (4.19.0-2)
[2018-10-27 11:26] [ALPM] installed linux419-r8168 (8.045.08-0.29)
[2018-10-27 11:27] [ALPM-SCRIPTLET] ==> dkms install rtl8812au/5.2.20.r9.gaca1e06 -k 4.19.0-2-MANJARO
1 Like

I know there are some real pros when it comes to scripting on the forum. My scripting skills are rather pitiful, but I’m trying to improve. I’ve been playing around with trying to fully automate restarting all wifi components via a script. I wanted to accomplish this without having to know the module name and adapter ID in advance. I wanted to be able to have a user run the script without having to manually edit in the missing info. This will hopefully come in handy on wifi troubleshooting threads because most new users barely know the difference between a module and an adapter. Hopefully a script will make things easier for troubleshooting.

I think the script is working properly, but I don’t have an Intel adapter using the iwlwifi module to fully test its effectiveness. The iwlwifi module must have any dependent modules rmmoded before iwlwifi can be unloaded. The script should detect the presence of the iwlwifi module and unload it correctly. If the iwlwifi module is not present, the script should simply unload any other wifi module in the normal manner.

sudo systemctl stop NetworkManager
sleep 2
DEVICE=$(hwinfo --wlan | grep "Device File" | cut -d " " -f5) 
sudo ip link set $DEVICE down
sleep 2
hwinfo --wlan | grep "Driver Modules" | cut -d " " -f5 | tr -d '"' > ~/module.txt
if [ MODULE=$(hwinfo --wlan | grep "Driver Modules" | cut -d " " -f5 | tr -d '"') = iwlwifi ]
        sudo lsmod | grep -o -e ^iwlmvm -e ^iwldvm -e ^iwlwifi | xargs sudo rmmod
MODULE=$(hwinfo --wlan | grep "Driver Modules" | cut -d " " -f5 | tr -d '"')
sudo modprobe -r $MODULE
sudo rfkill unblock wifi
sleep 2
MODULE=$(cat ~/module.txt)
sudo modprobe $MODULE
sleep 2
DEVICE=$(ip link show | grep wl | cut -d " " -f2 | tr -d ":") 
sudo ip link set $DEVICE up
sleep 2
sudo systemctl start NetworkManager
sleep 2
sudo rfkill unblock wifi
/usr/bin/nmcli r wifi off 
sleep 2 
/usr/bin/nmcli r wifi on

You can either run all the commands in terminal (minus the shebang), or create a script (be sure to make it executable). If pasting the commands into the terminal it works better as su, rather than sudo. If using sudo you might have to paste the commands in twice.

Please give me some feedback.


Those who suffer from a flaky wifi connection can use the above script and a desktop launcher to automatically refresh your network connection (rather than rebooting). To have the above script launch in the background (not in a visible terminal window) you must first install a small terminal multiplexer called “tmux”. As the script must be launched as root a small pkexec confirmation window will still pop up asking for the sudo password. There are other methods of refreshing your wifi connection that don’t require root permission, but they are often not as effective as this method. This will allow you to automatically restart your wifi connection from a handy desktop launcher.

Restart your WiFi connection with a Desktop Launcher

Create a file named “wifi-restart.desktop” with a text editor to start your WiFi connection.

Note: You must edit the “Exec” line in the desktop file to reflect the correct path to the “” script in your system.

The desktop file should have the following contents:

[Desktop Entry]
Comment=Restart WiFi
Exec=pkexec tmux -c /path/to/script/; sleep2 & exit
GenericName=Root Required
Name=Restart WiFi

Be sure to make the desktop file you created executable.

The desktop file can be placed in your start menu, taskbar, or on your desktop to conveniently restart your wifi connection.


Forum kindly sponsored by