First check if the Wi-Fi device is enabled or not:

$ nmcli radio wifi

If the output shows that the Wi-Fi is disabled, then it can be enabled with:

$ nmcli radio wifi on

If we already know the access point, then skip the following step. Otherwise, to identify the access points, run:

$ nmcli dev wifi list

Supposed we want to connect to the access point named ’totoro’, and the password is ’t0t0r02023’, we can connect to it by running the following command:

$ nmcli dev wifi connect totoro password 't0t0r02023'

Note the Wi-Fi’s password was provided in the command-line and will definitely stored in the command history. If this is something you want to avoid, then you can pass the option --ask to the the nmcli command as the following:

$ nmcli dev wifi connect totoro --ask

Reference: