[经验]Ubuntu20.04全方位换系统

ubuntu安装gcc_ubuntu 安装 gcc 4.6_ubuntu安装gcc

1.装机然后系统更新,设置软件源

2.安装系统驱动

3安装CUDA及CuDNN

4常用软件安装

Reference

0.原始系统备份0.1文件备份

推荐使用bcompare软件,这样原先早已备份的文件,如今要增量更新的话,用这个软件就便捷的。

ubuntu安装gcc_ubuntu 安装 gcc 4.6_ubuntu安装gcc

ubuntu安装gcc_ubuntu安装gcc_ubuntu 安装 gcc 4.6

operations中:

可以先通过compare保留一个最终的文件夹,之后通过同步按键同步文件夹。

若果是不同用户之间进行同步,须要使用root身分运行bcompare:

sudo QT_GRAPHICSSYSTEM=native bcompare

root模式下界面与普通用户界面略有不同,而且将就用没问题。

0.2.bashrc备份

该文件中会有好多后加打系统变量,如QT,自定义程序的路径等

$ cat /home/randy/.bashrc
# ~/.bashrc: executed by bash(1) for non-login s.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

...

export PATH="/usr/local/cuda/bin:$PATH"
export CUDA_HOME=/usr/local/cuda
# export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

#
 >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/randy/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/randy/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/randy/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/randy/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

source /opt/ros/noetic/setup.bash

npm set prefix ~/.npm
PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"
PATH="$PATH:/home/randy/Downloads/Zotero_linux-x86_64/"

#
 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

#
 LD_LIBRARY_PATH=/home/randy/anaconda3/lib/python3.9/site-packages/PySide2/Qt/lib/:/home/randy/anaconda3/lib/:$LD_LIBRARY_PATH

ulimit -c unlimited

#
add QT ENV
# export QT_DEBUG_PLUGINS=1
# export PATH=/opt/Qt5.14.2/5.14.2/gcc_64/bin:$PATH
# export LD_LIBRARY_PATH=/opt/Qt5.14.2/5.14.2/gcc_64/lib:$LD_LIBRARY_PATH
# export QT_PLUGIN_PATH=/opt/Qt5.14.2/5.14.2/gcc_64/plugins:$QT_PLUGIN_PATH
# export QML2_IMPORT_PATH=/opt/Qt5.14.2/5.14.2/gcc_64/qml:$QML2_IMPORT_PATH

alias randy='source /home/randy/codes/scripts_randy/shell/happyRandy.sh'
if [ -f /home/randy/codes/scripts_randy/shell/happyRandy-completion.bash ]; then
    . /home/randy/codes/scripts_randy/shell/happyRandy-completion.bash
fi

___MY_VMOPTIONS_SHELL_FILE="${HOME}/.jetbrains.vmoptions.sh"; if [ -f "${___MY_VMOPTIONS_SHELL_FILE}" ]; then . "${___MY_VMOPTIONS_SHELL_FILE}"; fi

0.3编译好的代码、下载的软件、数据库备份文件备份

如编译好的pcl代码linux qq,Sourcetrail_2014_4_19_Linux_64bit程序ubuntu 安装 gcc 4.6,Zotero程序

数据库文件

$ ll db_randy/
total 743436
drwxrwxrwx 1 randy randy         0 3月  19 18:45 ./
drwxrwxrwx 1 randy randy      4096 3月  20 12:36 ../
-rwxrwxrwx 1 randy randy 761269678 3月  19 18:45 l4_db.sql*
-rwxrwxrwx 1 randy randy      1055 3月  19 18:45 secret.sql*

0.4虚拟机安装后的系统文件

例如VirtualBox虚拟机会在~/VirtualBoxVMs目录下保存已在虚拟机中安装的系统,可打包

0.5FileZilla站点保存

打开FileZilla后File->Export->Exportsettings选择站点导入

ubuntu安装gcc_ubuntu 安装 gcc 4.6_ubuntu安装gcc

0.6docker环境、cuda文件夹和conda环境打包0.7软件安装源文件备份

/etc/apt/sources.list

deb //mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src //mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb //mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src //mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb //mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src //mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb //mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src //mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb //mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src //mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
# deb //typora.io linux/
# deb-src //typora.io linux/
deb //qgis.org/ubuntu jammy main
deb-src //qgis.org/ubuntu jammy main

0.8云认证文件备份0.9docker配置

$ cat /etc/docker/daemon.json
{
  "registry-mirrors": ["//docker.mirrors.ustc.edu.cn"],
  "insecure-registries": ["10.78.40.163:8080""10.79.88.162:33123"],
  "runtimes": {
      "nvidia": {
          "path""nvidia-container-runtime",
          "runtimeArgs": []
      }
  }
}

0.10主板驱动版本

$ nvidia-smi
Wed Mar 20 16:26:16 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.147.05   Driver Version: 525.147.05   CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   57C    P8    24W /  80W |    547MiB /  8192MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1885      G   /usr/lib/xorg/Xorg                 45MiB |
|    0   N/A  N/A      2832      G   /usr/lib/xorg/Xorg                370MiB |
|    0   N/A  N/A      3031      G   /usr/bin/gnome-shell               61MiB |
|    0   N/A  N/A     17821      G   ...800993256175944622,262144       39MiB |
|    0   N/A  N/A     22321      G   ...RendererForSitePerProcess       19MiB |
+-----------------------------------------------------------------------------+

sudo dpkg --list | grep nvidia-*
randy@Randy-HP-ZBook-G8:~/codes/scripts_randy/shell$ sudo dpkg --list | grep nvidia-*
[sudo] password for randy: 
ii  libnvidia-cfg1-525:amd64                                525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-525                                    525.147.05-0ubuntu0.20.04.1           all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-525:amd64                             525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA libcompute package
ii  libnvidia-compute-525:i386                              525.147.05-0ubuntu0.20.04.1           i386         NVIDIA libcompute package
rc  libnvidia-compute-535-server:amd64                      535.161.07-0ubuntu0.20.04.1           amd64        NVIDIA libcompute package
rc  libnvidia-compute-550:amd64                             550.54.14-0ubuntu0~gpu20.04.1         amd64        NVIDIA libcompute package
ii  libnvidia-decode-525:amd64                              525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA Video Decoding runtime libraries
ii  libnvidia-decode-525:i386                               525.147.05-0ubuntu0.20.04.1           i386         NVIDIA Video Decoding runtime libraries
ii  libnvidia-encode-525:amd64                              525.147.05-0ubuntu0.20.04.1           amd64        NVENC Video Encoding runtime library
ii  libnvidia-encode-525:i386                               525.147.05-0ubuntu0.20.04.1           i386         NVENC Video Encoding runtime library
ii  libnvidia-extra-525:amd64                               525.147.05-0ubuntu0.20.04.1           amd64        Extra libraries for the NVIDIA driver
ii  libnvidia-fbc1-525:amd64                                525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-fbc1-525:i386                                 525.147.05-0ubuntu0.20.04.1           i386         NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-525:amd64                                  525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-gl-525:i386                                   525.147.05-0ubuntu0.20.04.1           i386         NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
rc  linux-modules-nvidia-535-server-open-5.15.0-101-generic 5.15.0-101.111~20.04.1                amd64        Linux kernel nvidia modules for version 5.15.0-101
ii  nvidia-compute-utils-525                                525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA compute utilities
rc  nvidia-compute-utils-535-server                         535.161.07-0ubuntu0.20.04.1           amd64        NVIDIA compute utilities
rc  nvidia-compute-utils-550                                550.54.14-0ubuntu0~gpu20.04.1         amd64        NVIDIA compute utilities
ii  nvidia-dkms-525                                         525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA DKMS package
rc  nvidia-dkms-550                                         550.54.14-0ubuntu0~gpu20.04.1         amd64        NVIDIA DKMS package
ii  nvidia-driver-525                                       525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA driver metapackage
ii  nvidia-firmware-535-server-535.161.07                   535.161.07-0ubuntu0.20.04.1           amd64        Firmware files used by the kernel module
ii  nvidia-kernel-common-525                                525.147.05-0ubuntu0.20.04.1           amd64        Shared files used with the kernel module
rc  nvidia-kernel-common-535-server                         535.161.07-0ubuntu0.20.04.1           amd64        Shared files used with the kernel module
rc  nvidia-kernel-common-550                                550.54.14-0ubuntu0~gpu20.04.1         amd64        Shared files used with the kernel module
ii  nvidia-kernel-source-525                                525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA kernel source package
ii  nvidia-prime                                            0.8.16~0.20.04.2                      all          Tools to enable NVIDIA's Prime
ii  nvidia-settings                                         470.57.01-0ubuntu0.20.04.3            amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-525                                        525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA driver support binaries
ii  screen-resolution-extra                                 0.18build1                            all          Extension for the nvidia-settings control panel
ii  xserver-xorg-video-nvidia-525                           525.147.05-0ubuntu0.20.04.1           amd64        NVIDIA binary Xorg driver

1.装机然后系统更新,设置软件源

首先进行系统更新,以及设置软件更新源

可以按下述配置设置setup_part1.sh并运行。

由于前面要安装主板驱动,所以将系统自带的nouveau驱动屏蔽,否则Nvidia驱动难以安装。

#!/usr/bin/env bash

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade


SelectOS()
{
  echo -e "e[1;35mselect OS:e[0m"
  echo -e "     1) Ubuntu18.04"
  echo -e "     2) Ubuntu20.04"
}

#
 修改软件源
echo -e "e[1;32m修改软件源e[0m"
# sudo gedit /etc/apt/sources.list
SelectOS
read -p "Choose OS system, please: " sysType
if [ sysType == 1 ]; then
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
elif [ sysType == 2 ]; then
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb //mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src //mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
fi

#
 安装驱动
echo -e "e[1;32m禁用系统自带驱动nouveaue[0m"
# sudo gedit /etc/modprobe.d/blacklist.conf
sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
sudo echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist.conf
sudo echo "alias nouveau off" >> /etc/modprobe.d/blacklist.conf
sudo echo "alias lbm-nouveau off" >> /etc/modprobe.d/blacklist.conf

sudo cat /etc/modprobe.d/blacklist.conf

sudo update-initramfs -u

echo -e "e[1;32m请重启电脑:reboote[0m"

#
 重启系统(一定要重启)
# vertification , no  output is well
lsmod | grep nouveau

或则2行换源

sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
apt-get clean
apt-get update

2.安装系统驱动可通过ubuntuSoftware&Updates中的AdditionalDrivers安装

例如可选择460或470驱动,笔者选择了460。此步骤不装也行,CUDA安装包中包含安装驱动。选择的时侯不要选择tested版本,不稳定。

ubuntu安装gcc_ubuntu 安装 gcc 4.6_ubuntu安装gcc

点击ApplyChanges可进行安装,安装完可输入下边查看是否安装成功

# 查看驱动是否安装成功
nvidia-smi

#
 10s显示一次
watch -n 10 nvidia-smi

nvidia-smi -l

ubuntu 安装 gcc 4.6_ubuntu安装gcc_ubuntu安装gcc

使用搜索可用的驱动

ubuntu-drivers devices

randy@Randy-HP-ZBook-G8:~/codes/scripts_randy/shell$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000249Dsv0000103Csd00008873bc03sc00i00
vendor   : NVIDIA Corporation
driver   : nvidia-driver-550 - third-party non-free recommended
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-525-server - distro non-free
driver   : nvidia-driver-545 - third-party non-free
driver   : nvidia-driver-550-open - third-party non-free
driver   : nvidia-driver-535 - distro non-free
driver   : nvidia-driver-535-server-open - distro non-free
driver   : nvidia-driver-535-server - distro non-free
driver   : nvidia-driver-535-open - distro non-free
driver   : nvidia-driver-525 - distro non-free
driver   : nvidia-driver-525-open - distro non-free
driver   : nvidia-driver-545-open - third-party non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

== /sys/devices/pci0000:00/0000:00:1f.4 ==
modalias : pci:v00008086d000043A3sv0000103Csd00008873bc0Csc05i00
vendor   : Intel Corporation
driver   : oem-stella.cmit-mamoswine-meta - third-party free

安装驱动

sudo apt install nvidia-driver-XXX
sudo apt install nvidia-driver-525

安装完成后,输入nvidia-smi,

Notice

同一大版本系统(如Ubuntu20.04)ubuntu 安装 gcc 4.6,不同小版本的系统安装包,会造成系统推荐的主板驱动也不尽相同,驱动的版本号不一致。

ubuntu未能在附加驱动里选择其他主板驱动,只有继续使用自动安装的驱动选项

终端输入下边命令,之后重启。

sudo ubuntu-drivers install

假如里面界面为空,显示无附加驱动

sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update

有时侯安装的时侯会报错linux安装教程,非常注意/boot文件[1]

看/boot分区是不是满了,若果满了的话通常清除内核文件

sudo apt-get autoremove   #一般情况运行这个就可以,如果/boo分区占用减少就不能往下弄了

假如还不行,输入以下命令

df -h   #查看/boot分区占用
sudo apt-get clean   #下命令先清除空间,确认/boot分区已有足够空余。
uname -a  #查看当前Linux系统的内核版本   或者 使用 uname -r
dpkg --get-selections | grep linux-image     #查看已经安装的内核版本  选择状态为install的卸载
sudo apt-get remove linux-image-unsigned-5.4.0-110-generic   #输入名字全称卸载就行
sudo  apt-get autoremove   # 清空不用的包,清除不需要的内核文件

3安装CUDA及CuDNN

按照自己笔记本主板配置及功能须要安装对应版本的CUDA,假如须要神经网路处理,就安装CuDNN。

相关版本下载:

#!/usr/bin/env bash

wget //developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
wget //developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
wget //developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run

具体安装方式,可参考【Ubuntu20.04安装CUDA、cuDNN】[2]

卸载驱动

sudo /usr/bin/nvidia-uninstall
sudo apt-get --purge remove nvidia-*
sudo apt-get purge nvidia*
sudo apt-get purge libnvidia*

4常用软件安装4.1常用软件安装

ubuntu安装gcc_ubuntu安装gcc_ubuntu 安装 gcc 4.6

首先安装搜狗输入法,提早下好安装包sogoupinyin_4.0.1.2800_x86_64.deb,再通过下边的一键究竟,沉溺式享受基本程序安装。

搜狗拼音安装比较麻烦,建议安装GooglePinyin[3]

sudo apt-get install language-pack-zh-hans
sudo apt-get install fcitx-googlepinyin
sudo apt-get install fcitx
im-config # 注意选择 fcitx
# 重启
fcitx-config-gtk3

基本程序包括:搜狗输入法、git、locate、cmake、flameshot、axel、nfs、cloudcompare、clang、filezilla、pcap环境等。

setup_part2.sh

#!/usr/bin/env bash

#
 常用软件
## 搜狗输入法
sudo apt-get install fcitx
sudo dpkg -i sogoupinyin_4.0.1.2800_x86_64.deb 
sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/
sudo apt purge ibus
sudo apt install libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2
sudo apt install libgsettings-qt1

echo -e  "e[1;32msetup gite[0m"
sudo apt install git -y

echo -e "e[1;32msetup mlocatee[0m"
sudo apt install mlocate

echo -e "e[1;32msetup cmakee[0m"
sudo apt  install cmake -y

echo -e "e[1;32msetup flameshote[0m"
sudo apt-get install flameshot

echo -e "e[1;32msetup axele[0m"
sudo apt-get install axel

echo -e "e[1;32msetup nfse[0m"
sudo apt-get install nfs-common -y

echo -e "e[1;32msetup cloudcomparee[0m"
snap install cloudcompare

echo -e "e[1;32msetup clang-formate[0m"
sudo apt-get install clang-format

echo -e "e[1;32msetup filezillae[0m"
sudo apt-get install filezilla

echo -e "e[1;32msetup pcape[0m"
sudo apt-get install libpcap-dev

#
 GNC C Compiler
# GNC C++ Compiler
# GNC C Library
# GNC make
echo -e "e[1;32msetup GNC C/C++ Compiler, C Library, makee[0m"
sudo apt install build-essential


sudo apt install python-pip
sudo apt install python3-pip

4.2Typora安装

#!/usr/bin/env bash

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
# or use wget -qO - //typora.io/linux/public-key.asc | sudo apt-key add -

sudo add-apt-repository 'deb //typora.io linux/'
sudo apt-get update
sudo apt-get install typora
sudo snap install typora

4.3docker安装

setup_docker.sh

#!/usr/bin/env bash

green="e[1;32m"
reset="e[0m"
purple="e[1;35m"
bold="e[1m"
yellow="e[1;33m"


echo -e "${green}卸载掉系统里的docker${reset}"
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo rm -rf /var/lib/docker

sudo apt-get update
echo -e "${green}添加HTTPS协议和CA证书 ${reset}"
sudo apt-get install  apt-transport-https  ca-certificates curl  software-properties-common

echo -e "${green}Add Docker’s official GPG key:${reset}"
sudo mkdir -p /etc/apt/keyrings
curl -fsSL //download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

 echo 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] //download.docker.com/linux/ubuntu 
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update

echo -e "${green}Install Docker Engine, containerd, and Docker Compose${reset}"
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin


echo -e "${yellow}下列语句写入 /etc/docker/daemon.json 文件中。如文件不存在,则创建一个 ${reset}"
echo "{"
echo "  "registry-mirrors": ["//docker.mirrors.ustc.edu.cn"]"
echo "}"

read -p "modify the file  from upper tips, then input any key." user_status

echo -e "${green}建立docker用户组 ${reset}"
sudo groupadd docker
echo -e "${green}将当前用户加入 docker 组 ${reset}"
sudo usermod -aG docker $USER
sudo gpasswd -a $USER docker
echo -e "${green}更新用户组 ${reset}"
newgrp docker

echo -e "${green}修改docker权限 ${reset}"
sudo chmod a+rw /var/run/docker.sock

echo -e "${green}重启终端或重启docker${reset}"
sudo systemctl restart docker

echo -e "${green}查看docker版本 ${reset}"
docker version

4.4nvidia-docker安装

setup_nvidia-docker.sh

#!/usr/bin/env bash

echo -e "e[1;32m安装NVIDIA Docker2:e[0m"

curl -s -L //nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L //nvidia.github.io/nvidia-docker/ubuntu18.04/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

echo -e "e[1;32m安装2.0e[0m"
sudo apt-get install nvidia-docker2

echo -e "e[1;32m重新加载docker守护进程配置e[0m"
sudo pkill -SIGHUP dockerd

echo -e "e[1;32mnvidia-docker versione[0m"
nvidia-docker --version

4.5pypcd安装

setup_pypcd.sh

#!/usr/bin/env bash
git clone //github.com/dimatura/pypcd
cd pypcd
git fetch origin pull/9/head:python3
git checkout python3
python setup.py install

4.6PCL安装环境安装setup_pcl.sh

#!/usr/bin/env bash
echo "setup pcl environment of pcl"
sudo apt-get update  
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common 
sudo apt-get install libflann1.9 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk7.1p-qt
sudo apt-get install libvtk7.1p 
sudo apt-get install libvtk7-qt-dev
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install openjdk-8-jdk openjdk-8-jre

echo "下载pcl代码"
git clone //github.com/PointCloudLibrary/pcl.git 
cd pcl 
mkdir release 
cd release

echo "compile"
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr  -DBUILD_GPU=ON-DBUILD_apps=ON -DBUILD_examples=ON  -DCMAKE_INSTALL_PREFIX=/usr .. 
make
sudo make install

4.7Eigen安装

可以直接安装

sudo apt-get install libeigen3-dev

可以通过脚本安装setup_eigen.sh

git clone //github.com/eigenteam/eigen-git-mirror
cd eigen-git-mirror
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
sudo make install

不仅install,还可以查看其他信息:

-- ************************************************************
-- 
-- Configured Eigen 3.3.90
-- 
-- Some things you can do now:
-- --------------+--------------------------------------------------------------
-- Command       |   Description
-- --------------+--------------------------------------------------------------
-- make install  | Install Eigen. Headers will be installed to:
--               |     /
--               |   Using the following values:
--               |     CMAKE_INSTALL_PREFIX: /usr
--               |     INCLUDE_INSTALL_DIR:  include/eigen3
--               |   Change the install location of Eigen headers using:
--               |     cmake . -DCMAKE_INSTALL_PREFIX=yourprefix
--               |   Or:
--               |     cmake . -DINCLUDE_INSTALL_DIR=yourdir
-- make doc      | Generate the API documentation, requires Doxygen & LaTeX
-- make check    | Build and run the unit-tests. Read this page:
--               |   //eigen.tuxfamily.org/index.php?title=Tests
-- make blas     | Build BLAS library (not the same thing as Eigen)
-- make uninstall| Removes files installed by make install
-- --------------+--------------------------------------------------------------

注意

当调用eigen库时,会报错:fatalerror:Eigen/Core:Nosuchfileordirectory

这是由于eigen库默认安装在了/usr/include/eigen3/Eigen路径下,需使用下边命令映射到/usr/include路径下

sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen

4.8yaml安装

setup_yaml.sh

git clone //github.com/jbeder/yaml-cpp
mkdir build
cd build
cmake ..

cmake -DBUILD_SHARED_LIBS=ON ..
这里的参数on代表创建动态链接库,默认是off,即创建静态链接库

make
make install

sudo make install
sudo ldconfig

4.9卸载libreoffice

remove_libreoffice.sh

#!/usr/bin/env bash

sudo apt remove libreoffice-calc
sudo apt remove libreoffice-draw
sudo apt remove libreoffice-impress
sudo apt remove libreoffice-writer
sudo apt remove libreoffice*
sudo apt  purge libreoffice*

4.10安装录屏软件

安装kazam这款软件。

sudo apt-get install kazam

4.11安装tree

sudo apt install tree

4.12安装ROS

sudo sh -c 'echo "deb //packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl # if you haven't already installed curl
curl -s //raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update  # 更新apt软件源
sudo apt install ros-noetic-desktop-full  # 安装ROS
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc  # 设置环境变量
source ~/.bashrc  # 使设置生效
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo apt install python3-rosdep
sudo rosdep init
rosdep update

############## 部分操作  ##############
(base) randy@Randy-HP-ZBook-G8:~/Downloads$ sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-rosinstall is already the newest version (0.7.8-4).
python3-wstool is already the newest version (0.1.18-2).
build-essential is already the newest version (12.8ubuntu1.1).
The following NEW packages will be installed:
  python3-rosdep
The following packages will be upgraded:
  python3-rosinstall-generator
1 upgraded, 1 newly installed, 0 to remove and 22 not upgraded.
Need to get 15.3 kB of archives.
After this operation, 22.5 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 //packages.ros.org/ros/ubuntu focal/main amd64 python3-rosdep all 0.22.2-1 [3,532 B]
Get:2 //packages.ros.org/ros/ubuntu focal/main amd64 python3-rosinstall-generator all 0.1.23-1 [11.8 kB]
Fetched 15.3 kB in 1s (14.1 kB/s)                        
Selecting previously unselected package python3-rosdep.
(Reading database ... 307887 files and directories currently installed.)
Preparing to unpack .../python3-rosdep_0.22.2-1_all.deb ...
Unpacking python3-rosdep (0.22.2-1) ...
Preparing to unpack .../python3-rosinstall-generator_0.1.23-1_all.deb ...
Unpacking python3-rosinstall-generator (0.1.23-1) over (0.1.18-1) ...
Setting up python3-rosinstall-generator (0.1.23-1) ...
Setting up python3-rosdep (0.22.2-1) ...
(base) randy@Randy-HP-ZBook-G8:~/Downloads$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

    rosdep update

(base) randy@Randy-HP-ZBook-G8:~/Downloads$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit //raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit //raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit //raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit //raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit //raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index //raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/randy/.ros/rosdep/sources.cache

在ROS中有许多功能包,可以用以下命令安装指的功能包:

sudo apt install ros-noetic-PACKAGE
# 例如
sudo apt install ros-noetic-slam-gmapping

查看可以安装的功能包:

apt search ros-noetic

上述安装过程倘若遇见E:Unmetdependencies.错误

ubuntu安装gcc_ubuntu安装gcc_ubuntu 安装 gcc 4.6

(base) randy@Randy-HP-ZBook-G8:~/Downloads$ sudo apt install ros-noetic-desktop-full
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ros-noetic-desktop-full is already the newest version (1.5.0-1focal.20240125.205120).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python3-rosdep-modules : Depends: python3-rospkg-modules (>= 1.4.0) but it is not going to be installed
                          Depends: python3-catkin-pkg-modules (>= 0.4.0) but it is not going to be installed
                          Depends: python3-rosdistro-modules (>= 0.7.5) but it is not going to be installed
 ros-noetic-rospack : Depends: python3-catkin-pkg-modules but it is not going to be installed
 ros-noetic-rqt-gui : Depends: python3-rospkg-modules but it is not going to be installed
 ros-noetic-rqt-robot-monitor : Depends: python3-rospkg-modules but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

解决办法:

现将info文件夹改名

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bk

新建一个新的info文件夹

sudo mkdir /var/lib/dpkg/info

安装修补

sudo apt-get update
sudo apt-get install -f 

在info文件夹下生成一些文件,现将这种文件全部移到info.bk文件夹下

sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info.bk

删掉自己新建的info文件夹

sudo rm -rf /var/lib/dpkg/info

恢复原有info文件夹

sudo mv /var/lib/dpkg/info.bk /var/lib/dpkg/info

Reference参考资料

[1]

有时侯安装的时侯会报错,非常注意/boot文件:

[2]

【Ubuntu20.04安装CUDA、cuDNN】:

[3]

安装GooglePinyin:

[4]

Ubuntu20.04深度学习开发环境安装教程完全版[CUDA/TensorRT/Docker/OpenCV...]:

[5]

E:Sub-process/usr/bin/dpkgreturnedanerrorcode(1)解决办法:

本文原创地址://gulass.cn/uqfwhxtzncxt.html编辑:刘遄,审核员:暂无