📜  raspian wifi config.txt - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:19:42.687000             🧑  作者: Mango

Introduction to Configuring WiFi on Raspberry Pi using Shell-Bash

In this guide, we will learn how to configure WiFi on a Raspberry Pi using the config.txt file in the Raspbian operating system. With this configuration, your Raspberry Pi can connect to a wireless network and access the internet.

Prerequisites
  • Raspberry Pi with Raspbian OS installed
  • Basic knowledge of Raspberry Pi commands and shell scripting
Procedure
  1. First, make sure your Raspberry Pi is powered on and connected to a monitor.

  2. Open the terminal on your Raspberry Pi or connect via SSH.

  3. Navigate to the directory where the config.txt file is located. Normally, it can be found in /boot directory.

    cd /boot
    
  4. Open the config.txt file using a text editor like nano or vim.

    nano config.txt
    
  5. Scroll down to the bottom of the file and look for the section marked with [all]. This is where the WiFi configuration parameters should be added.

    [all]
    
  6. Add the following lines to configure WiFi:

    # WiFi Configuration
    wifi_country=<Your Country Code>
    wifi_ssid=<Network SSID>
    wifi_password=<Network Password>
    

    Replace <Your Country Code> with the 2-letter country code of your location (e.g., US for United States).

    Replace <Network SSID> with the name (SSID) of your WiFi network.

    Replace <Network Password> with the password of your WiFi network.

  7. Save the changes and exit the text editor.

  8. Reboot your Raspberry Pi for the changes to take effect.

    sudo reboot
    

After your Raspberry Pi reboots, it should automatically connect to the configured WiFi network using the provided SSID and password. You can now access the internet and perform any tasks requiring an internet connection.

Note: Make sure your Raspberry Pi is in range of the WiFi network for a successful connection.

Remember to keep your config.txt file secure as it contains sensitive information (password). Avoid sharing it publicly or with untrusted sources.

That's it! You have successfully configured WiFi on a Raspberry Pi using the config.txt file.

Conclusion

In this guide, we learned how to configure WiFi on a Raspberry Pi using the config.txt file. This method provides a convenient way to set up wireless connectivity without the need for a graphical interface. Now you can enjoy wireless internet access on your Raspberry Pi projects!