how to connect to hidden network using command line

It’s completely possible to connect to the network using only the command line, by just using the nmtui command.

However, how can we connect to a hidden network, as there are a field device that is needed to be filled?

First, you will need to create a new connection using nmtui edit, then choose Add.

Fill your hidden network information (Profile name, SSID, Security, …).

Once you are done, you only need to call nmcli con up your_network_name, and voila, you are now connected to your hidden network!

You can get the device name by using:

$ ifconfig
...
wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xx.xx  netmask 255.255.255.0  broadcast 192.168.xx.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        ether ab:cd:ef:gh:ij:kl  txqueuelen 1000  (Ethernet)
        RX packets 1585646  bytes 1997071905 (1.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 343046  bytes 85501055 (81.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The wifi device is wlo1 (ab:cd:ef:gh:ij:kl), so copy it, then edit the Wifi network using nmtui and fill the Device field.