登陸樹莓派官網,下載官方鏡像,並解壓爲 .img 文件javascript
注:DESKTOP 版本是有桌面環境的,Lite 版本沒有桌面環境php
win32diskimager 是鏡像讀寫軟件,使用此軟件燒錄樹莓派系統。html
因爲後續須要遠程登陸系統,須要開啓系統的ssh服務,默認是未開啓的。java
操做:打開讀卡器根路徑,新建文本文檔並更名爲 ssh (無後綴),便可。linux
注意:此處默認PC機都是有無線網絡和有線網絡的,若是是臺式機,沒有無線網絡。須要經過手機的USB共享網絡功能,讓樹莓派鏈接到手機網絡中,經過juiceSSH等軟件進行遠程登陸操做,可查閱相關資料,在此不作贅述。web
因爲須要樹莓派和PC機同網絡,所以,將無線網絡分享給有線網絡,而後用網線將PC和樹莓派鏈接起來。安全
鏈接圖以下:ruby
在電腦上設置把無線網絡共享給有線網絡(以win7爲例):網絡
打開控制面板,找到網絡鏈接,右擊 無線網絡鏈接-屬性,點擊共享選項卡,選擇共享到本地鏈接,勾選容許,肯定。app
打開命令行工具(win徽標鍵+R,輸入cmd)。輸入ipconfig 查看本地網絡ip
此時的樹莓派和PC機是共享了一樣的有線網,可是如何知道樹莓派的地址呢?
下面就要使用 advance_ip_scanner.exe 查看樹莓派的IP地址了。
查看結果以下圖:
製造商帶有 Raspberry Pi 字樣的 IP地址就是咱們要找的IP。
上述中,192.168.137.69 就是咱們要登陸的IP地址。此處咱們使用putty登陸IP地址。
固然也可使用其餘的遠程登陸軟件,只是putty輕便小巧,無記錄。
首次登陸,彈出安全警告,點擊確認。
默認的用戶名是 pi
密碼是 raspberry (注意:linux系統中,密碼都是不可見的,不要覺得沒有輸入進去而屢次輸入。)
回車後,登陸成功。
此處選擇最簡單的設置方法,所以使用樹莓派自帶的配置界面進行網絡設置。
命令行中輸入 sudo raspi-config
pi@raspberrypi:~ $ sudo raspi-config
彈出設置GUI界面以下:
選擇 2 NetWork Options ,回車。
選擇 N2 Wi-fi ,回車。
選擇國家,輸入 C ,定位到 CN China ,回車。
點擊OK。
輸入wifi名稱,按↓箭頭,選擇OK,回車。
輸入密碼,選擇OK,回車。
返回菜單首頁,tab鍵選擇Finish。回車。完成設置。
輸入 ifconfig 。查看當前網絡。
pi@raspberrypi:~ $ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.137.69 netmask 255.255.255.0 broadcast 192.168.137.255 inet6 fe80::ebcd:2a3e:5a3e:d31 prefixlen 64 scopeid 0x20<link> ether b8:27:eb:ca:cd:4e txqueuelen 1000 (Ethernet) RX packets 3197 bytes 196291 (191.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 970 bytes 247748 (241.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.103 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::e91c:4f1e:5794:fc0a prefixlen 64 scopeid 0x20<link> ether b8:27:eb:9f:98:1b txqueuelen 1000 (Ethernet) RX packets 38 bytes 5328 (5.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 36 bytes 5971 (5.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 pi@raspberrypi:~ $
找到wlan0,會發現網絡已鏈接,IP爲192.168.0.103
再打開putty,輸入192.168.0.103 發現已經能夠正常鏈接。
終於,咱們能夠拔掉網線,放飛樹莓派,讓它自由飛翔。(大霧)
至此,咱們能夠爲所欲爲的操做咱們的raspberry pi了。可是,醜媳婦總要見公婆的。咱們沒有顯示屏,也想看看這媳婦怎麼辦?
樹莓派軟件源地址在國外,因爲你們都懂的緣由,想要下載順暢絲滑,須要更換國內源,此處以阿里雲的源爲例更改。
命令行中輸入:
pi@raspberrypi:~ $ sudo nano /etc/apt/sources.list
修改文本內容:
# deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi # Uncomment line below then 'apt-get update' to enable 'apt-get source' #deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
命令行中輸入:
pi@raspberrypi:~ $ sudo nano /etc/apt/sources.list.d/raspi.list
修改文本內容:
# deb http://archive.raspberrypi.org/debian/ stretch main ui # Uncomment line below then 'apt-get update' to enable 'apt-get source' #deb-src http://archive.raspberrypi.org/debian/ stretch main ui deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main ui
注意:可使用如下任意源,可是須要明確本身是什麼版本的系統,此處的樹莓派系統是 stretch 相應更換此代號便可。
感謝: 此博客[1] 提供的源。
目前最新的樹莓派中國大陸地區的軟件源: 中國科學技術大學 Raspbian http://mirrors.ustc.edu.cn/raspbian/raspbian/ 阿里雲 Raspbian http://mirrors.aliyun.com/raspbian/raspbian/ 清華大學 Raspbian http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ 華中科技大學 Raspbian http://mirrors.hustunique.com/raspbian/raspbian/ Arch Linux ARM http://mirrors.hustunique.com/archlinuxarm/ 華南農業大學(華南用戶) Raspbian http://mirrors.scau.edu.cn/raspbian/ 大連東軟信息學院源(北方用戶) Raspbian http://mirrors.neusoft.edu.cn/raspbian/raspbian/ 重慶大學源(中西部用戶) Raspbian http://mirrors.cqu.edu.cn/Raspbian/raspbian/ 新加坡國立大學 Raspbian http://mirror.nus.edu.sg/raspbian/raspbian 牛津大學 Raspbian http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/ 韓國KAIST大學 Raspbian http://ftp.kaist.ac.kr/raspbian/raspbian/
輸入 sudo apt-get update 命令,獲取最早軟件包。
pi@raspberrypi:~ $ sudo apt-get update Get:1 http://mirrors.aliyun.com/raspbian/raspbian stretch InRelease [15.0 kB] Get:2 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf Packages [11.7 MB] Get:3 http://mirrors.aliyun.com/raspbian/raspbian stretch/contrib armhf Packages [56.9 kB] Get:4 http://mirrors.aliyun.com/raspbian/raspbian stretch/non-free armhf Packages [95.2 kB] Get:5 http://mirrors.aliyun.com/raspbian/raspbian stretch/rpi armhf Packages [1,360 B] Fetched 11.8 MB in 10s (1,151 kB/s) Reading package lists... Done W: Target Packages (main/binary-armhf/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Packages (main/binary-armhf/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4 W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list.d/raspi.list:4
pi@raspberrypi:~ $ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: libjavascriptcoregtk-4.0-18 libruby2.3 libssh-gcrypt-4 libwebkit2gtk-4.0-37 ruby2.3 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 14.8 MB of archives. After this operation, 2,301 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf libwebkit2gtk-4.0-37 armhf 2.18.6-1~deb9u1+rpi1 [9,709 kB] Get:2 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf libjavascriptcoregtk-4.0-18 armhf 2.18.6-1~deb9u1+rpi1 [1,846 kB] Get:3 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf libruby2.3 armhf 2.3.3-1+deb9u3+rpi1 [2,865 kB] Get:4 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf libssh-gcrypt-4 armhf 0.7.3-2+deb9u1 [144 kB] Get:5 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf ruby2.3 armhf 2.3.3-1+deb9u3+rpi1 [188 kB] Fetched 14.8 MB in 4s (3,348 kB/s) Reading changelogs... Done (Reading database ... 105923 files and directories currently installed.) Preparing to unpack .../libwebkit2gtk-4.0-37_2.18.6-1~deb9u1+rpi1_armhf.deb ... Unpacking libwebkit2gtk-4.0-37:armhf (2.18.6-1~deb9u1+rpi1) over (2.16.6-0+deb9u1+rpi1) ... Preparing to unpack .../libjavascriptcoregtk-4.0-18_2.18.6-1~deb9u1+rpi1_armhf.deb ... Unpacking libjavascriptcoregtk-4.0-18:armhf (2.18.6-1~deb9u1+rpi1) over (2.16.6-0+deb9u1+rpi1) ... Preparing to unpack .../libruby2.3_2.3.3-1+deb9u3+rpi1_armhf.deb ... Unpacking libruby2.3:armhf (2.3.3-1+deb9u3+rpi1) over (2.3.3-1+deb9u1+rpi1) ... Preparing to unpack .../libssh-gcrypt-4_0.7.3-2+deb9u1_armhf.deb ... Unpacking libssh-gcrypt-4:armhf (0.7.3-2+deb9u1) over (0.7.3-2) ... Preparing to unpack .../ruby2.3_2.3.3-1+deb9u3+rpi1_armhf.deb ... Unpacking ruby2.3 (2.3.3-1+deb9u3+rpi1) over (2.3.3-1+deb9u1+rpi1) ... Setting up libssh-gcrypt-4:armhf (0.7.3-2+deb9u1) ... Processing triggers for libc-bin (2.24-11+deb9u3) ... Processing triggers for man-db (2.7.6.1-2) ... Setting up libjavascriptcoregtk-4.0-18:armhf (2.18.6-1~deb9u1+rpi1) ... Setting up libruby2.3:armhf (2.3.3-1+deb9u3+rpi1) ... Setting up libwebkit2gtk-4.0-37:armhf (2.18.6-1~deb9u1+rpi1) ... Setting up ruby2.3 (2.3.3-1+deb9u3+rpi1) ... Processing triggers for libc-bin (2.24-11+deb9u3) ... pi@raspberrypi:~ $ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
想看「醜媳婦」,就須要藉助vnc工具了。
VNC(Virtual Network Console)虛擬網絡控制檯,原理是在咱們的Pi上安裝Server,而後在PC上安裝Viewer,經過網絡,實現顯示內容的傳輸。
命令行中執行:sudo apt-get install tightvncserver
pi@raspberrypi:~ $ sudo apt-get install tightvncserver Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libxfont1 xfonts-base xfonts-encodings xfonts-utils Suggested packages: tightvnc-java The following packages will be REMOVED: realvnc-vnc-server The following NEW packages will be installed: libxfont1 tightvncserver xfonts-base xfonts-encodings xfonts-utils 0 upgraded, 5 newly installed, 1 to remove and 0 not upgraded. Need to get 7,225 kB of archives. After this operation, 24.0 MB disk space will be freed. Do you want to continue? [Y/n] y Get:1 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf libxfont1 armhf 1:1.5.2-4 [120 kB] Get:2 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf tightvncserver armhf 1:1.3.9-9 [550 kB] Get:3 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf xfonts-encodings all 1:1.0.4-2 [574 kB] Get:4 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf xfonts-utils armhf 1:7.7+4 [70.4 kB] Get:5 http://mirrors.aliyun.com/raspbian/raspbian stretch/main armhf xfonts-base all 1:1.0.4+nmu1 [5,911 kB] Fetched 7,225 kB in 3s (2,155 kB/s) (Reading database ... 105924 files and directories currently installed.) Removing realvnc-vnc-server (6.3.1.36657) ... Selecting previously unselected package libxfont1:armhf. (Reading database ... 105847 files and directories currently installed.) Preparing to unpack .../libxfont1_1%3a1.5.2-4_armhf.deb ... Unpacking libxfont1:armhf (1:1.5.2-4) ... Selecting previously unselected package tightvncserver. Preparing to unpack .../tightvncserver_1%3a1.3.9-9_armhf.deb ... Unpacking tightvncserver (1:1.3.9-9) ... Selecting previously unselected package xfonts-encodings. Preparing to unpack .../xfonts-encodings_1%3a1.0.4-2_all.deb ... Unpacking xfonts-encodings (1:1.0.4-2) ... Selecting previously unselected package xfonts-utils. Preparing to unpack .../xfonts-utils_1%3a7.7+4_armhf.deb ... Unpacking xfonts-utils (1:7.7+4) ... Selecting previously unselected package xfonts-base. Preparing to unpack .../xfonts-base_1%3a1.0.4+nmu1_all.deb ... Unpacking xfonts-base (1:1.0.4+nmu1) ... Processing triggers for mime-support (3.60) ... Processing triggers for desktop-file-utils (0.23-1) ... Setting up tightvncserver (1:1.3.9-9) ... update-alternatives: using /usr/bin/tightvncserver to provide /usr/bin/vncserver (vncserver) in auto mode update-alternatives: using /usr/bin/Xtightvnc to provide /usr/bin/Xvnc (Xvnc) in auto mode update-alternatives: using /usr/bin/tightvncpasswd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode Setting up xfonts-encodings (1:1.0.4-2) ... Setting up libxfont1:armhf (1:1.5.2-4) ... Processing triggers for libc-bin (2.24-11+deb9u3) ... Processing triggers for man-db (2.7.6.1-2) ... Processing triggers for shared-mime-info (1.8-1+deb9u1) ... Processing triggers for gnome-menus (3.13.3-9) ... Processing triggers for hicolor-icon-theme (0.15-1) ... Processing triggers for fontconfig (2.11.0-6.7) ... Setting up xfonts-utils (1:7.7+4) ... Setting up xfonts-base (1:1.0.4+nmu1) ...
命令行中輸入:tightvncserver
pi@raspberrypi:~ $ tightvncserver You will require a password to access your desktops. Password:輸入密碼 Warning: password truncated to the length of 8. Verify:再次輸入密碼 Would you like to enter a view-only password (y/n)? n # 此處問是否須要建立可遠觀而不可褻玩的密碼,我選擇否,若是須要給別人開放一個查看密碼,選擇y New 'X' desktop is raspberrypi:1 Creating default startup script /home/pi/.vnc/xstartup Starting applications specified in /home/pi/.vnc/xstartup Log file is /home/pi/.vnc/raspberrypi:1.log
可使用 tightvncviewer 軟件。
打開軟件,輸入IP地址和端口(端口默認爲5901)點擊Connect鏈接。
輸入剛纔填寫的密碼,OK確認。
終於讓咱們揭開了兒媳婦的面紗(這媳婦還挺俊hhhhhh)。
而後,咱們就能夠任意的操做樹莓派的系統了。
本文已完。。。。。。。。那是不可能的。
一旦咱們重啓樹莓派,再次登陸,就無法登入vnc界面了。
這是爲何呢?
由於咱們沒有讓 tightvncserver 開機自啓動。
pi@raspberrypi:~ $ sudo nano /etc/init.d/tightvncserver
編輯輸入:
#!/bin/sh
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $syslog $remote_fs $network
# Required-Stop: $syslog $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts VNC Server on system start.
# Description: Starts tight VNC Server. Script written by James Swineson.
### END INIT INFO
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
start)
su $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Starting TightVNC Server for $VNCUSER"
;;
stop)
pkill Xtightvnc
echo "TightVNC Server stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0
pi@raspberrypi:~ $ sudo chmod 755 /etc/init.d/tightvncserver # 添加執行權限 pi@raspberrypi:~ $ sudo update-rc.d tightvncserver defaults # 設置開啓啓動 pi@raspberrypi:~ $ sudo reboot # 重啓
pi@raspberrypi:~ $ sudo update-rc.d -f tightvncserver remove
至此,本文真的藥丸了。
關於其餘的關於樹莓派的食用記錄:
[1]: 樹莓派更換中國大陸地區軟件源