ubuntu22.04 打开工作新局面【git加速、手机连通、git配置】

1,035 阅读1分钟

本文正在参加「金石计划 . 瓜分6万现金大奖」

ubuntu22.04 打开工作新局面

1.github dns设置

之前在windows下,通过 UsbEAm Hosts Editor v3.63 修改dns来提高访问 github 速度,简直是爱不释手。目前切换到ubuntu了,怎么办?

问了度娘很久,有linux下类似软件,可是在github上,下在很难,于是换了办法。请出自带的 nslookup 工具干活了!!!

1.1 github.com dns查询

(base) livingbody@gaint:~/Downloads$ nslookup github.com
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	github.com
Address: 20.205.243.166

1.2 github.global.ssl.fastly.net dns查询

(base) livingbody@gaint:~/Downloads$ nslookup github.global.ssl.fastly.net
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	github.global.ssl.fastly.net
Address: 66.220.149.32
Name:	github.global.ssl.fastly.net
Address: 2001::a27d:206

1.3 写入hosts

通过命令 sudo gedit /etc/hosts ,打开 hosts 文件,添加查询到的dns并保存。

20.205.243.166	github.com
66.220.149.32	github.global.ssl.fastly.net

2.打通手机

win下,我的小米手机通过 miui+ 和电脑无缝连接,切到ubuntu下怎么办呢?传输文件感觉很棘手。。。。。。

度娘告诉我,用 scrcpy

安装 scrcpy 工具,用他来打通linux和手机。

2.1 scrcpy安装

sudo apt-get install scrcpy

2.2 andorid手机设置

  • 打开开发者模式
  • 打开usb调试
  • 打开usb安全调试

2.3 启动服务

可通过usb或者wifi adb连接手机、电脑

启动服务命令如下:

(base) livingbody@gaint:~/.local/share$ scrcpy
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
/usr/local/share/scrcpy/scrcpy-server...hed. 4.5 MB/s (41159 bytes in 0.009s)
[server] INFO: Device: Xiaomi 22041216UC (Android 12)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 520.56.06
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2456
INFO: Device clipboard copied
[server] INFO: Device clipboard set
[server] INFO: Device clipboard set

2.4 效果

怎么样,效果还不错吧,可以互传文件,可以通过电脑操作手机,不输 miui+(它该不会是用这个软件改的吧?)

选区_004.png

3.git应用

搞开发离不开github,因为经常抄作业(下载资源),因此我第一个安装的就是git工具。

3.1 git安装

3.2 拷贝密钥

理论上要配置ssh-key什么的,但是以前windows下用的不是有吗?直接拷贝过来即可。

拷贝过来的文件主要有:

  • id_rsa
  • id_rsa.pub
  • known_hosts
  • known_hosts.old
(base) livingbody@gaint:~$ ls .ssh
id_rsa  id_rsa.pub  known_hosts  known_hosts.old

3.3 git用户信息配置

git config --global user.name "livingbody"
git config --global user.email "155203340@qq.com"

3.4 配置验证

(base) livingbody@gaint:~$ git config -l
user.name=livingbody
user.email=155203340@qq.com

看到如下信息,基本可以确定配置完成了!

如此以来, win 和 我的 ubuntu 可以用一套密钥了。