If you want to connect your device over wifi adb and access the shell, use below mentioned commands:
1. Check the IP address of the device, for this, make sure you have your device connected to the network, then go to Settings -> Network & Internet -> click on the connected network interface (Wifi/Ethernet) -> The device IP address will be displayed.
Or you can connect the device over USB cable and type,
$ adb shell
$ ifconfig
Write down the IP address and then exit from adb and remove the USB cable.
2. Now, connect over the network using IP address,
$ adb connect 192.168.0.104:5555 connected to 192.168.0.104:5555
$ adb shell
Sometimes, you may see an error as below,
$adb connect 192.168.0.104 unable to connect to 192.168.0.104:5555
For this, we need to restart the TCP port. Connect the device over USB cable and type:
$ adb tcpip 5555 restarting in TCP mode port: 5555
3. Now, you will be able to connect over the network
$ adb connect 192.168.0.104:5555 connected to 192.168.0.104:5555
If you have not removed the USB cable, you might see the same device as two devices:
$ adb devices List of devices attached B2NGAA8831702707 device 192.168.0.104:5555 device
$ adb -s 192.168.0.104:5555 shell B2N_sprout:/ $