当前位置: 首页 > 工具软件 > rtc-ssh > 使用案例 >

Ubuntu18.04 -Linux -win10子系统 树莓派 文件位置 ssh 系统源 pip源 python多版本共存等(持续更新)

周弘毅
2023-12-01

1 更新为阿里源

Ubuntu的版本号, 应该是18.04, 对应的代号是bionic

lsb_release -a

cp /etc/apt/sources.list /etc/apt/sources.list_backup
sudo nano  /etc/apt/sources.list

 

20:

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse


18:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

16:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
 
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

树莓派:

注意版本  Ubuntu 

修改软件更新源

sudo nano /etc/apt/sources.list     raspbian   stretch/buster   
Ctrl+o     回车    Ctrl+x

更改第一行

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
修改系统更新源

sudo nano /etc/apt/sources.list.d/raspi.list  更改第一行
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
 

sudo apt-get install aptitude

sudo apt update

sudo apt upgrade

pip更新

  1. 根目录创建.pip文件:mkdir ~/.pip
  2. vim .pip/pip.conf
  3. [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    trusted-host = pypi.tuna.tsinghua.edu.cn

pipenv更新

pipenv install 创建虚拟环境

在Pipfile 中

 url = "https://pypi.tuna.tsinghua.edu.cn/simple/"

2 安装NVIDIA社区版驱动

首先删除旧的NVIDIA驱动:

sudo apt-get purge nvidia-*

然后安装

sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt-get update

sudo apt-get upgrade ubuntu-drivers devices #查看自己的显卡及可以安装的驱动版本

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000139Bsv0000103Csd0000820Dbc03sc02i00
vendor   : NVIDIA Corporation
model    : GM107M [GeForce GTX 960M]
driver   : nvidia-driver-410 - third-party free
driver   : nvidia-driver-396 - third-party free
driver   : nvidia-driver-415 - third-party free recommended
driver   : nvidia-driver-390 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

sudo apt install nvidia-driver-410

重启

3 点击图标最小化

gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

4  统一Win10和Ubuntu18.04双系统的时间

UTC即Universal Time Coordinated,协调世界时(世界统一时间

GMT 即Greenwich Mean Time,格林尼治平时

Windows 与 Mac/Linux 看待系统硬件时间的方式是不一样的:Windows把计算机硬件时间当作本地时间(local time),所以在Windows系统中显示的时间跟BIOS中显示的时间是一样的。Linux/Unix/Mac把计算机硬件时间当作 UTC, 所以在Linux/Unix/Mac系统启动后在该时间的基础上,加上电脑设置的时区数( 比如我们在中国,它就加上“8” ),因此,Linux/Unix/Mac系统中显示的时间总是比Windows系统中显示的时间快8个小时。所以,当你在Linux/Unix/Mac系统中,把系统现实的时间设置正确后,其实计算机硬件时间是在这个时间上减去8小时,所以当你切换成Windows系统后,会发现时间慢了8小时
linux下:

timedatectl set-local-rtc 1 --adjust-system-clock

Windows:管理员权限

Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

5 安装压缩软件

sudo apt-get install p7zip-full p7zip-rar rar unzip

6 安装多版本python和pip共存

sudo apt install python2.7  #安装python2.7

sudo apt-get install python-pip#pip2
sudo apt install python3-pip#安装pip3 
sudo apt install python-testresources   #防止pip2出错
sudo apt install python3-testresources  #防止pip3出错
sudo pip3 install --upgrade pip #升级pip3
sudo pip2 install --upgrade pip #升级pip2

alternatives机制

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
如果要切换到Python2,执行:

sudo update-alternatives --config python

whereis pip

pip: /usr/local/bin/pip /usr/local/bin/pip3.6 /usr/local/bin/pip2.7

自定义alias别名:

vim  ~/.bashrc

alias pip=/usr/local/bin/pip3.6 alias python=/usr/bin/python3.6 

source ~/.bashrc 

7  ssh

我有两台主机分别IP分别是:192.168.48.131和192.168.48.132,现在需要从131的机器上免密码登录到132的机器上

1、分别安装ssh:sudo apt-get install ssh

ssh root@ip

ssh root@ip  -p 27509

2、在131的机器上生成公钥和私钥,输入命令,提示直接按enter就行了

 ssh-keygen -t  rsa

cd ~/.ssh就会发现多了如下文件:id_rsa 和id_rsa.pub分别是私钥和公钥。

3、执行如下命令:$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys,将公钥添加到.ssh/authorized_keys,这时就能在本机免密码登陆了

4、然后将id_rsa.pub文件复制到132上,这里我使用的是主机名

 scp .ssh/id_rsa.pub  root@wybl:~/home

5、在132上执行1、2、3,然后将id_rsa.pub的内容添加到132的authorized_keys文件中,完成之后就能在本级免密码登录132了

 cat ~/home/id_rsa.pub >> ~/.ssh/authorized_keys

6、完成之后在131上重启ssh服务后即可免密码登录132了

在终端上输出

7 、 scp -r xxxx@ip地址:路径/文件名/ ~/

远程到本地:scp xxx@ip:路径/文件名/  ~/

本地到远程:scp -r 文件 xxx@ip:/home/

指定端口      scp -P27509  文件 xxx@ip:/
 

8 子系统文件位置

win10子系统把windows的底层接口做了个转换到Linux从而能运行linux,但是他在安装的时候并没有提供安装位置的选项.(还有hyper v)

现在,所有从商店安装的发行版都存在于以下目录中

C:\Users<username>\AppData\Local\Packages

对于Ubuntu则在Packages目录下的CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState中

对于其他发行版则其组织名会有变化

全路径应当如下

C:\Users<username>\AppData\Local\Packages<group_name>\LocalState

对于旧的测试版wsl用户则存在于

`C:\Users\Username\AppData\Local\Lxss

当然如果你对环境变量%localappdata%改变过,则存在于%localappdata%\Lxss中.

顺便提一句 hyper-v镜像的存放目录在

C:\Users\Public\Documents\Hyper-V\Virtual hard disks中

9 中文设置

sudo apt install -y language-pack-zh-hans language-pack-zh-hans-base 

vi ~/.profile 
在末尾新增一行:LANG=zh_CN.UTF-8 

 

 

 

 

 类似资料: