Can anybody help me to how can I enable and disable network card through terminal?
3 Answers
Since ifconfig
has been deprecated for many years now, you should probably use the ip
command :
To list the interfaces:
ip link
or with the ip addresses:
ip a
To 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.
-
2
-
It pulls the interface down/up as the machine is running, but on reboot, or a restart of networking [service] the NIC status will return to default.– guivercJun 14, 2019 at 9:01
-
What do you mean by "port"? I don't see any port number specified in your commands. May 23, 2020 at 9:58
-
The port used in that example was eth0, for my current workstation there is no eth0, but it would be enp0s25 (I'm using a later kernel which uses a different naming technique)– guivercMay 23, 2020 at 10:13
-
There must be another command to toggle the wifi card with fn+f8 - network symbol on my laptop. This is also possible from cmd. The cmd is something with list.– TimoApr 28 at 18:53
To see list of network cards:
lshw -C network
You will see all the network cards. Attention to logical name example:
logical name: wlp6s0
logical name: enp7s0
So just use ifconfig
to enable or disable it.
Examples:
- Enable
sudo ifconfig wlp6s0 up
- Disable:
sudo ifconfig enp7s0 down
-
1I don't see any logical name while running "lshw -C network". Do we have way to find location name? Mar 27, 2019 at 19:47
-
eth0
(ethernet port), you cansudo ifconfig eth0 down
which will disable (down) the port. changing down to up will re-enable it. useifconfig
to view your ports. this works on a port basis; so a nic (network interface card) with four ports will require each port to be disabled individually.