After Install 1 2 sudo apt-get updatesudo apt install net-tools wireless-tools build-essential plocate
启用无线网卡(可选) 1 2 3 4 5 6 7 lspci -nnk|grep -iA2 net #得到无线网卡硬件信息:MEDIATEK Corp. MT7921 xxx ip addr #得到无线网卡名称:wlp5s0 sudo ifconfig wlp5s0 up #启用无线网卡 sudo iwlist wlp5s0 scan | grep ESSID #让无线网卡搜索周边WIFI,记住想要连接的ESSID ll /etc/netplan/ # 得到类似50-cloud-init.yaml
sudo vi /etc/netplan/xxx-init.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 network: version: 2 ethernets: enp4s0: dhcp4: false dhcp6: false addresses: [10.0 .0 .18 /24 ] routes: - to: default via: 10.0 .0 .1 nameservers: addresses: [10.0 .0 .1 ] search: [] wifis: wlp5s0: dhcp4: false dhcp6: false addresses: [10.0 .0 .24 /24 ] nameservers: addresses: [10.0 .0 .1 ] access-points: "mywifiname": password: "mywifipassword"
重启服务
1 2 3 4 sudo netplan apply ip address ip route resolvectl
python和pip
安装
1 2 3 4 ll /usr/bin/python* sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1sudo update-alternatives --config pythonpython -V
pip镜像(方式一)
~/.config/pip/pip.conf
1 2 3 4 5 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
pip镜像(方式二)
1 2 3 # 使用ustc镜像站来升级 pip pip install -i https://mirrors.aliyun.com/pypi/simple/ pip -U pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip镜像(方式三)
如果方式二出现以下错误:
1 2 3 4 5 6 error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.
这种情况下官方推荐为每个python应用配置独立的虚拟空间:
1 2 3 4 cd /your/scripts/path python3 -m venv .venv source .venv/bin/activate pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
安装golang 1 2 sudo apt install golanggo version
配置git 1 2 3 git config ---global user.name 'myname' git config --global user.email 'xxx@xxx.com' ssh-keygen -t rsa -C 'xxx@xxx.com'
将pubkey填写到github –> SSH & GPG Keys。 可将id_rsa和id_rsa.pud拷贝到其他路径,如windows机器的%USERPROFILE%.ssh,以便共享。
安装好好上网服务(可选) (过程略)
设置代理
vi ~/.bashrc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 export PROXY_SERVER_IP=127.0.0.1function proxyon () { export http_proxy=http://$PROXY_SERVER_IP :10808 export https_proxy=http://$PROXY_SERVER_IP :10808 export ftp_proxy=socks5://$PROXY_SERVER_IP :10808 export all_proxy=socks5://$PROXY_SERVER_IP :10808 export no_proxy="localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;" git config --global http.proxy "http://$PROXY_SERVER_IP :10808" git config --global https.proxy "http://$PROXY_SERVER_IP :10808" export GO111MODULE=on export GOPROXY=https://goproxy.cn,direct go env -w GOPROXY=https://goproxy.cn,direct } function proxyoff () { unset http_proxy https_proxy ftp_proxy all_proxy no_proxy git config --global --unset http.proxy git config --global --unset https.proxy unset GO111MODULE GOPROXY }
其他必要设置
修改/etc/sudoers
1 2 + Defaults !env_reset - Defaults env_reset
设置时区和24小时
1 2 sudo timedatectl set-timezone Asia/Shanghaisudo vi /etc/default/locale
修改/etc/ssh/sshd_config后,重启ssh服务
1 2 + AllowTcpForwarding yes # 去掉注释 - #AllowTcpForwarding yes
参考资料https://sqlpey.com/python/how-to-fix-externally-managed-environment-error/ https://www.cnblogs.com/luk/p/18624859 https://askubuntu.com/questions/1464028/how-to-setup-static-ip-with-wireless-interface-and-netplan-on-ubuntu-22-04 https://www.configserverfirewall.com/ubuntu-linux/set-static-ip-ubuntu-server/