樹莓派4b+linux

用Win32DiskImager燒錄系統html

先在boot根目錄下新建ssh空文件夾來開啓ssh功能,不然ssh是關閉的,用putty一直連不上,顯示拒絕鏈接linux

1.聯網:git

初次github

(實踐證實:直接在sd卡根目錄新建wap_supplicant.conf並寫入wifi信息不可行)shell

1.能夠經過在boot根目錄下新建wap_supplicant.conf進行初次開機就聯網ubuntu

關鍵1:是不能用windows自帶的文本編輯器編輯,在linux中打開會有^M這種符號windows

能夠用notpad編輯就沒問題服務器

關鍵2:arp –a找不到mac地址,能夠ping raspberry.local來獲取ip地址,由於有時得到的是ipv6地址,就不會顯示mac地址網絡

如下兩種方式等效:dom


2.網線鏈接電腦和樹莓派(簡單,不用鏈接路由器,一根網線就行)

共享pc的網絡給樹莓派,好比:電腦連的wifi,那就經過網線(以太網)共享網絡

clip_image001

wlan--右鍵--屬性--共享,勾選容許其餘網絡鏈接,在下面選擇以太網,肯定

(第一次時會彈出以太網會配置成192.168.xxx.1,是否確認?這樣一個界面,點擊確認)

clip_image002

以太網--右鍵--屬性,選擇ipv4--屬性

clip_image003

配置ip地址和dns服務器地址(默認便可,應該是和以前彈出的提示中的ip保持一致)

clip_image004

參考:https://www.jianshu.com/p/c161cbc9645a?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation


3.網線鏈接路由器和樹莓派

cmd中:

arp –a

查找mac地址以dc開頭的ip  (視本身的mac地址爲準)

用putty鏈接後配置wifi聯網:(默認用戶名:pi,密碼:raspberry)

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
         ssid="你的無線網名字"
         psk="密碼"
         key_mgmt=WPA-PSK

}

network={…}

能夠設置多個WIFI信息

按下Ctrl+O 寫出保存 ,按下Enter 肯定,最後Ctrl+X 退出

sudo reboot

以後再次arp -a找到ip,這時候能夠發現已經連的是路由器了

以後也會開機自動鏈接wifi


以後

配置好後,兩種查看樹莓派ip的方法:

1.arp –a  mac地址(dc開頭)對應的ip地址

2.ping raspberrypi.local,便可看到(若是是ipv6則上面方法失效,用這個)

配置靜態ip

更改dhcp(動態分配ip)的配置文件:/etc/dhcpcd.conf

# wlan0是無線網卡,其餘還有eth0

interface wlan0

# 192.168.1.10/24中的24表示子網掩碼爲255.255.255.0
static ip_address=194.168.1.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=194.168.1.1
#static domain_name_servers=194.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

開啓/關閉網卡:

ifconfig ethx up

ifconfig ethx down

2.建立用戶:

useradd -m +用戶名

設置密碼:passwd 用戶名,鍵入兩次密碼便可

1.在root權限下,useradd只是建立了一個用戶名,如(useradd+用戶名),它並無在/home目錄下建立同名文件夾,也沒有建立密碼,所以利用這個用戶登陸系統,是登陸不了的,爲了不這樣的狀況出現,能夠用(useradd -m +用戶名)的方式建立,它會在/home目錄下建立同名文件夾,而後利用(passwd + 用戶名)爲指定的用戶名設置密碼。

useradd –m username

passwd username

會提示輸入密碼:xxxx

2.刪除用戶,只需使用一個簡單的命令"userdel 用戶名"便可。不過最好將它留在系統上的文件也刪除掉,你可使用"userdel -r 用戶名"來實現這一目的。

啓用root管理帳戶

初次使用樹莓派系統時,默認用戶是pi ,密碼爲raspberry。

要想使用root賬號,或者說開啓root用戶,可以使用pi用戶登陸,執行下面命令

sudo passwd root (給root用戶設置密碼)

會提示設置root用戶的密碼:xxxx

接着輸入下面命令,用來解鎖root帳戶

sudo passwd --unlock root

用下面命令切換到root管理員

su root

一樣,切換到普通用戶

su 用戶名

盡能夠在樹莓派默認用戶pi下能夠更改root的密碼,而在建立的普通用戶下面不能更改

3.ssh-傳輸文件

將本地文件拷貝到遠程服務器上

scp 本地文件 用戶名@服務器ip:服務器目錄

須要服務器上的用戶名和服務器ip地址

將遠程服務器的文件下載到本地

scp 用戶名@服務器ip:服務器目錄 本地目錄

scp –r 拷貝文件夾

不管是linux仍是windows,格式都是同樣的

linux默認有ssh服務,因此之間能夠直接傳文件

windows下默認沒有ssh服務,須要手動安裝


OpenSSH

1. https://github.com/PowerShell/Win32-OpenSSH/releases

進入連接下載最新 OpenSSH-Win64.zip64位系統),解壓至C:\Program Files\OpenSSH

二、打開cmd,cd進入C:\Program Files\OpenSSH(安裝目錄),執行命令:

powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

3.設置服務自動啓動並啓動服務

sc config sshd start= auto

net start sshd

到此服務已經安裝完畢,默認端口同樣是22,默認用戶名密碼爲Window帳戶名和密碼

參考:https://www.jianshu.com/p/6e5bc39d386e


問題:windows使用scp出現REMOTE HOST IDENTIFICATION HAS CHANGED

ras_key更改了,直接刪除C:\Users\用戶登錄名\.ssh\known_hosts

而後在scp命令,會提示是否添加,yes便可


4.更新下載源

apt源

更改/etc/apt/sources.list

deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib

阿里源:https://developer.aliyun.com/mirror/debian?spm=a2c6h.13651102.0.0.53322f70W9C1Gk

(將其中的stretch替換爲buster便可)


更改完後更新:apt-get update

(能夠參考:http://www.javashuo.com/article/p-fsesujnt-gp.html

(若是源可用的話,是不會出現下面問題的)

問題1:

The following signatures couldn't be verified because the public key is not available

添加公鑰:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys '提示中缺失的pubkey'

添加完後再執行一次更新命令便可

問題2:Temporary failure resolving 'archive.raspberrypi.org',連不到樹莓派域名

從新配置DNS

查看DNS服務器:cat /etc/resolv.conf
更改DNS服務器:

   echo nameserver 101.198.199.200 > /etc/resolv.conf

   echo nameserver 8.8.8.8 > /etc/resolv.conf


樹莓派源:

配置/etc/apt/sources.list.d/raspi.list源:

中科大:

deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main


pip源:

參考:https://www.cnblogs.com/justaman/p/11833793.html



其餘有用的命令:

查看本身樹莓派的版本:

   lsb_release –a

   cat /proc/version

   cat /etc/debian_version

查看cpu溫度:

cat /sys/class/thermal/thermal_zone0/temp

相關文章
相關標籤/搜索