跳至主要内容

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

评论

此博客中的热门博文

go url encoding

func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

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

How can I create a Windows bootable USB stick using Ubuntu?

even other Linux distros as long as  GParted  and  GRUB  are installed. Install GParted and GRUB on Ubuntu with: sudo apt-get install gparted grub-pc-bin p7zip-full ntfs-3g For BIOS: MBR partition scheme Rewrite the partition table as  msdos  and format your USB drive as  NTFS  using GParted (and then "Manage flags" and add the  boot  flag). In GParted, right click the USB partition and select  Information . Copy the UUID somewhere as you will need it. Copy all files from mounted Windows ISO or DVD to USB drive using your favorite file manager. Go to USB drive and if the folder named  boot  has uppercase characters, make them all lowercase by renaming it. Install GRUB on USB: sudo grub-install --target=i386-pc --boot-directory="/<USB_mount_folder>/boot" /dev/sdX Create a GRUB config file in the USB drive folder  boot/grub  with the name  grub.cfg . Write this into the file: echo "If...