Ubuntu常用环境配置

news/2024/7/5 7:16:16

配置软件源

切换清华源

sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo apt update -y
sudo apt upgrade -y

常用软件安装

基础软件安装

常用的一些环境包括编译环境

sudo apt install -y curl proxychains-ng vim openssh-server net-tools make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils liblzma-dev tk-dev python3-pip tree

代理

配置proxychains-ng

下面有某些软件可能无法访问,所以先配置代理

# 将192.168.3.104 10808 修改为自己的代理服务器地址
sudo sed -i 's/socks4[[:space:]]*127.0.0.1 9050/socks5\t192.168.3.104 10808/' /etc/proxychains4.conf

系统代理

设置

export ALL_PROXY="socks5://127.0.0.1:1080"
export all_proxy="socks5://127.0.0.1:1080"

取消

unset ALL_PROXY
unset all_proxy

常用配置

临时设置DNS

sudo sed -i '1i\nameserver 8.8.8.8' /etc/resolv.conf

设置默认编辑器

update-alternatives --config editor

配置ssh

允许root登陆

sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

设置开机启动

sudo systemctl enable --now ssh

常用软件安装

git

安装

sudo apt install git -y

配置

  1. 生成公钥
git config --global user.name "名字"
git config --global user.email "邮箱地址"
ssh-keygen -t rsa -C '邮箱地址'
  1. 复制公钥并配置到github
cat ~/.ssh/id_rsa.pub 

git代理设置

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

git代理取消

git config --global --unset http.proxy
git config --global --unset https.proxy

zsh

安装

sudo apt install zsh -y

配置

  1. 安装oh-my-zsh插件 https://ohmyz.sh/#install
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

国内DNS可能有污染,若失败试试换DNS
2. 配置插件
下载插件的插件

## 自动提示
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
## 高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. 修改配置文件
    编辑 ~/.zshrc
# 分别找到这两行代码
ZSH_THEME="robbyrussell"
plugins=(git)

# 分别替换成下面的
## 自定义随机主题(几个好用的)
THEMES=(darkblood bira duellj fino-time fox gnzh xiong-chiamiov-plus jonathan random)
## zsh中读取数组是从一开始算
ZSH_THEME=${THEMES[$((1 + ($RANDOM % ${#THEMES[*]})))]}

plugins=(git z zsh-syntax-highlighting zsh-autosuggestions)

或者执行命令

sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="jonathan"/' ~/.zshrc
sed -i 's/plugins=(git)/plugins=(git z zsh-syntax-highlighting zsh-autosuggestions)/' ~/.zshrc
source ~/.zshrc
  1. 显示优化(可选)
    ls -al显示的时间改为%Y-%m-%d %H:%M:%S'格式
export TIME_STYLE='+%Y-%m-%d %H:%M:%S'

Node

通过nvm安装node

# 下载安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# 重新进入bash(zshrc)或重新加载.bashrc(.zshrc)
source ~/.zshrc
# 安装node
nvm install v16.17.0
# 设置默认
nvm alias default v16.17.0

Anaconda

下载

wget https://repo.anaconda.com/archive/Anaconda3-2023.03-Linux-x86_64.sh
bash Anaconda3-2023.03-Linux-x86_64.sh
# 之后根据提示输入

jupyter-lab

安装完Anaconda默认就自带jupyter了

  1. 生成配置文件
jupyter lab --generate-config
  1. 设置密码
jupyter lab password
  1. 自动闭合(括号、引号这些)
    启动jupyter-lab后,在页面上方settings中找到Auto Close Brackets打勾

  2. 常用启动参数

# 指定IP
jupyter-lab --ip 0.0.0.0 
# 指定端口
jupyter-lab --port 8888
# 不自动启动浏览器
jupyter-lab --no-browser

插件安装

  1. 启动jupyter-lab后,打开Extension Manager ,点击enable启动插件
  2. 查看已安装的插件
jupyter server extension list
  1. 自动代码提示插件(需要node环境)
    首先
pip install jupyterlab-lsp
pip install 'python-lsp-server[all]'

然后在JupyterLab中的Extension Manager中找到jupyterlab-lsp点击install,经过漫长的等待,它可能会让你重启jupyter-lab
如果失败了可以用jupyter server extension list查看jupyterlab-lsp是否安装成功

  1. 启用或关闭插件(未测试)
# 关闭估计就是把`enable`改为`disable`
jupyter server extension enable --user --py jupyter_lsp

Pyenv

安装

curl https://pyenv.run | bash

配置环境

编辑~/.zprofile~/.zshrc,添加

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

~/.zshrc添加

eval "$(pyenv virtualenv-init -)"

修改镜像源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装指定版本python

pyenv install 3.8.16

设置默认python环境

pyenv global 3.8.16

删除python环境

pyenv uninstall 3.8.16

创建虚拟环境

pyenv virtualenv 3.8.16 my_env

查看虚拟环境

pyenv virtualenvs

激活虚拟环境

pyenv activate my_env

frp 内网穿透

地址: https://github.com/fatedier/frp
下载: https://github.com/fatedier/frp/releases

wget https://github.com/fatedier/frp/releases/download/v0.48.0/frp_0.48.0_linux_amd64.tar.gz
tar -zxvf frp_0.48.0_linux_amd64.tar.gz
cd frp_0.48.0_linux_amd64
sudo cp frpc /usr/bin/frpc
sudo cp frps /usr/bin/frps

客户端配置

  1. 创建文件夹/etc/frp/
  2. 创建文件sudo vim /etc/frp/frpc.ini
[common]
server_addr = 你的服务端IP
server_port = 你的服务端端口
token = 连接密码 

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 22022
  1. 创建开机自启动服务
    创建文件/lib/systemd/system/frpc.service
[Unit]
Description=Frp Client Service
After=network.target

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini
ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target

  1. 配置开机启动
systemctl enable --now frpc.service

grub(双系统)

在先装windows后装ubuntu的情况下,执行下面的命令会自动识别windows引导项

sudo update-grub2

配置主题

下载主题

挑一个好看的主题下载,地址:https://www.gnome-look.org/browse?cat=109&ord=latest
我下载的是Distro

sudo mkdir -p /boot/grub/themes/distro
sudo tar -xvf ubuntu.tar -C /boot/grub/themes/distro/

修改配置文件

编辑/etc/default/grub
插入下面内容

GRUB_THEME="/boot/grub/themes/distro/theme.txt"

注释GRUB_TIMEOUT_STYLE=hidden
更新配置

sudo update-grub 

落雪音乐

地址:https://github.com/lyswhut/lx-music-desktop

sudo dpkg -i lx-music-desktop-v2.2.0-x64.deb 

下面的用到再写

docker

vscode

vlc


http://lihuaxi.xjx100.cn/news/1010979.html

相关文章

Scrapy-爬虫多开技能

我们知道,现在运行Scrapy项目中的爬虫文件,需要一个一个地运行,那么是否可以将对应的爬虫文件批量运行呢?如果可以,又该怎么实现呢?在Scrapy中,如果想批量运行爬虫文件,常见的有两种…

IPv4 和 IPv6 的组成结构和对比

IPv4 和 IPv6 的组成结构和对比IPv4IPv6互联网协议 (IP) 是互联网通信的基础,IP 地址是互联网上每个设备的唯一标识符。目前最常用的 IP 协议是 IPv4,它已经有近 30 年的历史了。然而,IPv4 存在一些问题,例如: 地址空间不足:IPv4 …

向量的内积外积哈达玛积

1.向量的内积 1.1 定义 从代数角度看&#xff0c;先对两个数字序列中的每组对应元素求积&#xff0c;再对所有积求和&#xff0c;结果即为点积。从几何角度看&#xff0c;点积则是两个向量的长度与它们夹角余弦的积。 表示形式&#xff1a;ATBA^TBATB、<A,B><A,B&g…

[学习笔记]金融风控实战

参考资料&#xff1a; 零基础入门金融风控-贷款违约预测 导包 import pandas as pd import matplotlib.pyplot as plt# 读取数据 train pd.read_csv(train.csv) testA pd.read_csv(testA.csv) print(Train data shape:, train.shape) print(testA data shape:, testA.shape…

我的面试八股(JAVA并发)

程序计数器为什么是线程私有的? 程序计数器主要有下面两个作用&#xff1a; 字节码解释器通过改变程序计数器来依次读取指令&#xff0c;从而实现代码的流程控制&#xff0c;如&#xff1a;顺序执行、选择、循环、异常处理。在多线程的情况下&#xff0c;程序计数器用于记录…

Redis 客户端连接服务器失败

公司项目开发环境需要使用到 Redis&#xff0c;申请基础技术支撑平台的 Redis 中间件比较麻烦&#xff0c;项目组也不知道具体流程&#xff0c;而且时间可能比较长。 现在的情况是&#xff0c;项目因为 Redis 启动报错。 这种情况下&#xff0c;我们项目组就自行在虚拟机上临…

开心档之C++ 多态

目录 C 多态 实例 虚函数 纯虚函数 多态按字面的意思就是多种形态。当类之间存在层次结构&#xff0c;并且类之间是通过继承关联时&#xff0c;就会用到多态。 C 多态意味着调用成员函数时&#xff0c;会根据调用函数的对象的类型来执行不同的函数。 下面的实例中&#x…

【第0篇】从0-1自建个人博客系统【web端,admin管理端,express后端,Nginx部署】--vue3技术 reac+hook技术 umi4

【第0篇】从0-1自建个人博客系统【web端&#xff0c;admin管理端&#xff0c;后端】 文章完整地址&#xff1a;http://www.huxunxun.top/lookArtical?artical_id18 【序言】 我是一个微小的前端开发工程师。 我本不应该是一个前端开发的&#xff0c;我大学学的是计算机科学与…