进入系统镜像下载界面:

Install Ubuntu on a Raspberry Pi | UbuntuUbuntu is an open-source operating system for cross platform development, there's no better place to get started than with Ubuntu on a Raspberry Pi.https://ubuntu.com/download/raspberry-pi选择需要下载的版本。

下载烧录工具,这里有两种:

1,balena工具,这个工具烧写完成后有校验;

balenaEtcher - Flash OS images to SD cards & USB drivesA cross-platform tool to flash OS images onto SD cards and USB drives safely and easily. Free and open source for makers around the world.https://www.balena.io/etcher/2,官网下载工具:

Raspberry Pi OS – Raspberry Piicon-default.png?t=M0H8https://www.raspberrypi.com/software/下载完成后,使用SD卡进行烧写。烧写完成后进入下面步骤配置。
1,打开sd卡的system-boot分区,找到network-config这个文件,添加:
wifis:
  wlan0:
    dhcp4: true
    optional: true
    access-points:
      "TP-202_kubao": #wifi名称
        password: "823238@11"#wifi密码
        hidden: true

2,登录路由器后台查看树莓派IP地址
3,使用ssh工具连接树莓派:
ssh是默认开启的,初始账号和密码都是ubuntu

4,连接成功后会提示初始化密码
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for ubuntu.
Current password: 输入当前密码
New password: 输入新密码
Retype new password: 验证密码
passwd: password updated successfully

5,重新使用新密码连接并创建root用户:
ubuntu@ubuntu:~$ sudo passwd # 创建root密码
New password: 
Retype new password: 
passwd: password updated successfully
ubuntu@ubuntu:~$ su root # 切换到root账户
Password: 
root@ubuntu:/home/ubuntu# 

6,使用vim /etc/ssh/sshd_config编辑配置文件
找到#PermitRootLogin prohibit-password并在下面新建一行PermitRootLogin yes
#PermitRootLogin prohibit-password
PermitRootLogin yes

7,跟换国内源:
sudo nano /etc/apt/sources.list
把所有的url全换为https://mirrors.ustc.edu.cn/ubuntu-ports/

sudo apt-get update
sudo apt-get upgrade


8,安装桌面 
sudo apt-get install ubuntu-desktop
reboot

9,开启FTP服务
在树莓派终端安装FTP服务器
sudo apt-get install vsftpd
然后对FTP进行配置,打开它的配置文件
sudo nano /etc/vsftpd.conf
修改以下配置
# 不允许匿名访问 
anonymous_enable=NO 
# 设定可以进行写操作
write_enable=YES 
# 设定本地用户可以访问
local_enable=YES 
ascii_upload_enable=YES 
ascii_download_enable=YES
重启服务
sudo service vsftpd restart

10,安装VNC桌面(Xfce4)
#安装Xfce4桌面环境
sudo apt-get install xfce4
#安装VNCServer
sudo apt-get install tightvncserver
或者
sudo apt-get install vnc4server
#安装xrdp
sudo apt-get install xrdp   
#安装xfce4-terminal
sudo apt install xfce4-terminal
#进入vnc配置文件路径修改xstartup文件
cd .vnc/
mv xstartup xstartup_bak
sudo nano xstartup
#输入以下内容

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

#gnome-terminal &

sesion-manager & xfdesktop & xfce4-panel &
xfce4-menu-plugin &
xfsettingsd &
xfconfd &
xfwm4 &

启动vnc
vncserver :1 -geometry 1536x864 

11,VNC terminal打不开等bug问题
在页面左上角上找到 Appication->Settings->Preferred Applications->Utilities中改成xfce-Terminal
最后关掉vncserver重开,然后再连接,VNC可以正常使用
vncserver -kill :1 
vncserver :1 -geometry 1536x864 

12,开机自启动vnc设置
#打开文件/etc/init.d/tightvncserver并且编辑
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='ubuntu'
case "$1" in
        start)
                su $VNCUSER -c '/usr/bin/tightvncserver :1 -geometry 1536x864'
                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

#修改文件权限
sudo chmod 755 /etc/init.d/tightvncserver
#跟新系统自启动项
sudo update-rc.d tightvncserver defaults
#需要取消开机自动启动vnc
sudo update-rc.d -f tightvncserver remove

13,添加中文支持:
#查看已经安装的语言包
locale -a
en_US.utf8 //英文语言包(这玩意肯定有吧)
zh_CN.utf8 //中文语言包
#如果没有 zh_CN.utf8 ,需要安装中文语言包
sudo apt-get install language-pack-zh-hans
#然后添加中文支持
sudo locale-gen zh_CN.UTF-8
#改一下 locale 文件配置,打开 /etc/default/locale 文件
sudo nano /etc/default/locale
#切换中文,用下面的内容替换:
#  File generated by update-locale
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"

14,改为英文配置:
#如果没有 en_US.utf8 ,需要安装英文文语言包
sudo apt-get install language-pack-en
#添加英文支持
locale-gen en_US.UTF-8
#打开 /etc/default/locale 文件
sudo nano /etc/default/locale
#切换英文,用下面的内容替换
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

15,ubuntu 树莓派改时区
sudo tzselect
按要求选好,一步步往下操作
sudo cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
sudo vi /etc/timezone
打文件里的内容改为Asia/Shanghai 或sudo tzselect  命令中提示要保存的内容。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐