跳至主要内容

linux 在命令行中管理 Wifi 连接

pacman -S   dialog   wifi-menu

wifi-menu


























查看网卡信息:
iwconfig

无线网卡一般是wlan0
# ifconfig wlan0 up #启用无线网卡

查看附近可用的无线接入点(AP)
iwlist wlan0 scan

让无线网卡接入WEP无线网络:

# iwconfig wlan0 ESSID "linkname" KEY "password" open





WPA/WPA2无线网络 :

vim /etc/network/interfaces
===================
auto wlan0 
iface wlan0 inet dhcp
     #if it's a hidden wifi,add 2 lines below
     #wpa-ap-scan   1
     #wpa-scan-ssid 1
     wpa-ssid       x
     wpa-psk        zhaohuandabaojian!



Wifi Hotspot :



# apt-get install hostapd
Edit /etc/default/hostapd, enter:
# vi /etc/default/hostapd
Add a line :
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Next create a text file called /etc/hostapd/hostapd.conf, enter:
Set interface name:
### Wireless network name ###
interface=wlan0
 
### Set your bridge name ###
bridge=br0
Set driver name:
driver=nl80211
Set country name code in ISO/IEC 3166-1 format. This is used to set regulatory domain. Set as needed to indicate country in which device is operating. This can limit available channels and transmit power.
### (IN == INDIA, UK == United Kingdom, US == United Stats and so on ) ###
country_code=IN
Set your SSID:
ssid=nixcraft
Set operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g)
hw_mode=g
Set channel number (some driver will only use 0 as value)
channel=6
Set wpa mode to 2:
wpa=2
Set your passphrase (WiFi password):
wpa_passphrase=MyWiFiPassword
Set key and auth optionsmanagement for WPA2:
## Key management algorithms ##
wpa_key_mgmt=WPA-PSK
 
## Set cipher suites (encryption algorithms) ##
## TKIP = Temporal Key Integrity Protocol
## CCMP = AES in Counter mode with CBC-MAC
wpa_pairwise=TKIP
rsn_pairwise=CCMP
 
## Shared Key Authentication ##
auth_algs=1
 
## Accept all MAC address ###
macaddr_acl=0
Save and close the file.

How Do I start / stop / restart AP?

Use the following commands:
# /etc/init.d/hostapd start
# /etc/init.d/hostapd stop
# /etc/init.d/hostapd restart

评论

此博客中的热门博文

onsen ui example splitter side menu swipe

<!DOCTYPE html> <html> <head> <title>TheyTube - Watch free video online</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">   <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>   <script type="text/javascript">   ons.platform.select('android')   </script> </head> <body> <ons-splitter>   <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>     <ons-page>       <ons-list>         <ons-list-item onclick="fn.load('home.html')" tappable>           Home         </ons-list-item>         <ons-list-item onclick="fn.load('settings.html')" tappable>           Setti

go golang get disk usage free space remain info

package main import ( "fmt" "syscall" ) func main() { fmt.Println(DiskUsage("./")) } func DiskUsage(path string) uint64 { fs := syscall.Statfs_t{} err := syscall.Statfs(path, &fs) if err != nil { return 0 } return fs.Bfree * uint64(fs.Bsize) } //All space   = fs.Blocks * uint64(fs.Bsize) //Free space = fs.Bfree * uint64(fs.Bsize) //Used space= fs.All - disk.Free