Simple bash scripts to automate restarting the NetworkManager and checking the network status on Linux π§.
On some Linux distributions, it's common to face random network issues, especially when dealing with proprietary drivers or certain Wi-Fi cards π‘. A usual quick fix is to manually run:
sudo systemctl restart NetworkManager
nmcli device status
But in the most part of the resets, you need to do this multiple times (at least at my case). Remembering these hard commands and doing multiple times becomes annoying.
I created small and handy scripts to automate this process, making it faster and easier π‘.
network-reset.sh
π β Automatically restarts the NetworkManager infinite times until you press Ctrl + C to stop when it works.
network-status.sh
π β Shows the current network status using nmcli infinite times until you press Ctrl + C to stop when you're done.
- Linux distro with systemd and NetworkManager π§;
- Bash or Zsh installed;
nmcli
installed (usually comes with NetworkManager).
- Normally, you should create a
bin/
directory in your $HOME for downloading the scripts. But this is optional; - Install the scripts;
- Go to the directory where the scripts were installed:
cd ~/bin/
(Or another directory)
- Allow execution of the scripts:
chmod +x network-reset-zsh.sh network-status-zsh.sh
5.1. Just run the scripts directly:
./network-reset.sh
./network-status.sh
5.2. Or, create aliases in your .zshrc
/ .bashrc
to make them even faster β‘:
alias net-r="$HOME/bin/network-reset-zsh.sh"
alias net-s="$HOME/bin/network-status-zsh.sh"