Enabling and disabling network card through commandline
Can anybody help me to how can I enable and disable network card through terminal?
23 Answers
Since ifconfig has been deprecated for many years now, you should probably use the ip command :
To list the interfaces:
ip linkor with the ip addresses:
ip aTo take one down:
if=eth0
sudo ip link set $if down 2 use ifconfig to view your ethernet or NIC ports (to get port names; eg. eth0 was the first port on my machine, next was eth1 etc)
to disable say port named eth0 use
sudo ifconfig eth0 down
to re-enable the port use
sudo ifconfig eth0 up
note: this disables (down) and enables (up) each port individually. if for example a NIC (network interface card) has four ports on a card, you need to enable/disable each port individually.
5To see list of network cards:
lshw -C networkYou will see all the network cards. Attention to logical name example:
logical name: wlp6s0
logical name: enp7s0So just use ifconfig to enable or disable it.
Examples:
- Enable
sudo ifconfig wlp6s0 up - Disable:
sudo ifconfig enp7s0 down