9

I had installed CentOS(CLI,minimal).it have no GUI.i want connect to WiFi but answers on askubuntu are not working.see this screenshot.I want to know following:-

  • How to turn WiFi on/off?
  • How to get list of available WiFi connections?
  • How to connect WiFi that i want to connect with?
12

The best and easy option I like to use with CentOS is nmtui. (Ref: Redhat)

THIS IS NOT GUI, IT IS TUI (TEXT USER INTERFACE)

First you have to install nmtui,

# yum install NetworkManager-tui

Then,

# nmtui

This will option up what you are after.

enter image description here

Now you can go to Edit connection and itwill list out all the available WiFi connections for you. Then you can select what you want and Activate/Deactivate what ever you want.

  • 2
    The question says CLI, no GUI. – G-Man Oct 14 '17 at 2:04
  • 1
    Yes. I know the question says it is CLI that's where nmtui comes handy. It is not a GUI it is TUI. (Text User Interface) this is a recommended method by Redhat. Look, there are two things we can think of. If the requirement is to configure Wifi manually using a command line this is the best and easiest option. Scripting is not possible with this though, I agree. – NIK Oct 14 '17 at 6:56
  • 5
    How can I install NetworkManager-tui without Wifi ?? – rahul Oct 18 '17 at 9:50
  • Correct this is the million dollar question. :) Again you have two options. Easy method is connecting your device to a wired network normally to a network port (RJ45) in your wifi router and do the configuration. ( I have written this here how to do this for Raspberry Pi namal.org. this is same for other devices as well). Second option is download the nmtui rpm and dependencies manually and install using RPM. If you can tell the device you are using and the exact centOS version probably I could tell you what exactly you have to do. – NIK Oct 18 '17 at 12:11
  • Thanks! I had an issue on CentOS7 where I couldn't activate (from a GUI) a second, duplicate Wi-Fi NIC because there were configuration conflicts somewhere along the way that prevented from connecting. I came across this suggested answer and this solution worked out most elegantly and allowed me to activate it from commandline. – Kārlis K. Jan 22 '18 at 17:59
10

To run the ifconfig ... command , you should install the net-tools package.

Because the net-tools is deprecated there is the ip and iw commands which answer your question:

How to turn WiFi on/off?

$ ip link set <interface> up
$ ip link set <interface> down

How to get list of available WiFi connections?

$ iw dev <interface> scan | grep SSID

How to connect WiFi that i want to connect with?

Create a wpa_supplicant configuration file with the following content:

ctrl_interface=/run/wpa_supplicant
update_config=1
ap_scan=1

To add the SSID and the password, run:

$ wpa_passphrase "YOUR-SSID" YOUR-PASSWD >> /etc/wpa_supplicant/wpa_supplicant.conf

To connect run:

$ wpa_supplicant -i <interface> -c /etc/wpa_supplicant/wpa_supplicant.conf -B
dhclient <interface>
  • +1 for mentioning net-tools deprecation. – Isius Aug 27 '18 at 15:24
  • I follow these steps and it works but I need to run dhclient wlo1 as a last step before I get a dhcp lease. I added scan_ssid=1 to /etc/wpa_supplicant/wpa_supplicant.conf. tks GAD3R! :) – chan fook sheng Oct 4 '18 at 16:58
3

You should be able to see if the drivers for the card are installed by using lspci -k

And then to know if your interface is correctly detected and named you can use ip link You can then try to bring up the interface with ifup

If the interface does not come up correctly it might be because you're missing a configuration file like /etc/sysconfig/network-scripts/ifcfg-<interface-name>

Another alternative solution if it's something you only want to bring up once you can input the following commands :

ip link set dev <interface-name> up
wpa_supplicant -B -i <interface-name> -c /etc/wpa_supplicant/wpa_supplicant.conf
dhcpcd <interface-name>
3

If you are running CentOS 7: You may want to check if NetworkManager is already there available for you to use:

chkconfig NetworkManager on

service NetworkManager start

Issue command: nmtui

Go directly to "Active a connection" to check if you already can see your wireless network/wi-fi. If so, input your password.

You can also Edit a profile for the wi-fi you want to connect.

NOTE: if you cannot active a wi-fi, try the following: After above steps: /etc/init.d/network restart OR REBOOT/RESTART your box.

0

Here is my experience, for the following reasons:

  1. If you got connected to Wifi network when you have installed CentOS 7.
  2. After CentOS 7 entering into sleep mode OR accidental shutdown due to power drainage OR you have restarted & logged into CentOS 7

and if your wifi not working.

Don't install extra kernel module/do any tweaks/install any new packages

Just shutdown and boot again in CentOS 7. Your wifi will start working again.

This is what I realised after 6 hours of tweaks and tried everything out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.