1.開啟ssh連接
首先在tf卡中保存一個ssh的空文
件,為了打開ssh功能。
2.設置無線網連接
設置上網,在tf卡也就是當前的boot盤新建一個wpa_supplicant.conf的文件,寫入上網配置命令:
country=CN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="wifiname" psk="password" key_mgmt=WPA-PSK priority=1 }
說明:key_mgmt=WPA-PSK為WiFi安全機制,priority為優先級別
wpa的常用操作
wpa_supplicant是一個連接、配置WIFI的工具,它主要包含wpa_supplicant與wpa_cli兩個程序. 可以通過wpa_cli來進行WIFI的配置與連接,前提要保證wpa_supplicant正常啟動
啟動wpa_supplicant應用
wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
-D 驅動程序名稱(可以是多個驅動程序:nl80211,wext)
-i 接口名稱
-c 配置文件
-B 在后台運行守護進程
啟動wpa_cli
wpa_cli -i wlan0 scan //搜索附件wifi熱點
wpa_cli -i wlan0 scan_result //顯示搜索wifi熱點
wpa_cli -i wlan0 status //當前WPA/EAPOL/EAP通訊狀態
wpa_cli -i wlan0 ping //pings wpa_supplicant
添加新的連接
wpa_cli -i wlan0 add_network //添加一個網絡連接,會返回<network id>
wpa_cli set_network <network id> ssid '"name"' //ssid名稱
wpa_cli set_network <network id> psk '“psk”' //密碼
wpa_cli set_network <network id> scan_ssid 1
wpa_cli set_network <network id> priority 1 //優先級
保存連接
wpa_cli -i wlan0 save_config //信息保存到默認的配置文件中
斷開連接
wpa_cli -i wlan0 disable_network <network id>
連接已有連接
wpa_cli -i wlan0 list_network //列舉保存過得連接
wpa_cli -i wlan0 select_network <network id> //連接指定的ssid
wpa_cli -i wlan0 enable_network <network id> //使能制定的ssid
3.顯示設置
在boot目錄下,找到config.txt
文件,里面許多選項被注釋掉了,我們需要在選擇以下命令:
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1 #類似windows電腦安全模式,分辨率非常小,所有的改動都無法生效
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1 #可以去掉開機屏幕周圍的黑色邊框
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1 #HDMI熱拔插(即插即用)
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2 #DMT模式
hdmi_mode=58 #分辨率為適應屏幕分辨率的選擇
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2 #音頻從HDMI接口
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4 如果有干擾或顯示不正常,可以添加信號量,增加范圍從1(用於短電纜)到7(用於長電纜)。
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d
紅字為一些重要配置
4.更換鏡像源
將 /etc/apt/sources.list
文件中默認的源地址 http://raspbian.raspberrypi.org/
替換為 http://mirrors.ustc.edu.cn/raspbian/
即可。
說明:http://mirrors.ustc.edu.cn/raspbian/
為中科大鏡像源,推薦,比較快而且軟件比較新
raspbian 2018-04-19 之后的鏡像默認源已經更改,用如下命令替換:
sudo sed -i 's|raspbian.raspberrypi.org|mirrors.ustc.edu.cn/raspbian|g' /etc/apt/sources.list
編輯文件后,請使用 sudo apt-get update
命令,更新軟件索引。
5.遠程桌面連接
1)使用xrdp
安裝:sudo apt-get install xrdp
然后運行Windows遠程桌面(mstsc),輸入ip進行連接
2)使用VNC
安裝:sudo apt-get install tightvncserver
打開:sudo tightvncserver
在Windows上安裝VNC Veiwer,在Sever中輸入IP:1之后輸入密碼
查看端口命令監聽:netstat -tnl
3350 3389(windows默認遠程端口) 22 (ssh)
LISTEN為監聽狀態
修改語言與鍵盤布局可以使用sudo raspi-config里面設置
sudo passwd root 來設置root用戶密碼