Ubuntu安装及配置脚本
安装Ubuntu
略
安装系统后
删除libreoffice
sudo apt remove *libreoffice*
安装必备软件
sudo apt install gcc g++ make automake curl wget p7zip unrar git zsh vim net-tools
net-tools 要被 iproute2 取代了。
安装oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
配置zsh样式
修改~\.zshrc
文件,原样式替换为agnoster
安装与配置zsh插件
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
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
sudo apt install autojump
修改~\.zshrc
文件,原插件处代码替换为plugins=(git sudo zsh-autosuggestions zsh-syntax-highlighting zsh-completions autojump)
安装zinit
sh -c "$(curl -fsSL https://git.io/zinit-install)"
添加sudo发现环境
~/.zshrc尾部增加
# 增加sudo发现当前环境路径
alias sudo='sudo env PATH=$PATH'
安装与配置brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
修改~\.zshrc
文件,最下面增加
# brew environment
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
配置代理
修改~\.zshrc
文件,最下面增加
# proxy environment
# 启动代理
proxy () {
export https_proxy=http://127.0.0.1:40289 http_proxy=http://127.0.0.1:40289 all_proxy=socks5://127.0.0.1:36655
echo "HTTP Proxy on"
}
# 关闭代理
noproxy () {
unset http_proxy
unset https_proxy
unset all_proxy
echo "HTTP Proxy off"
}
配置java环境
配置环境
修改~\.zshrc
文件,最下面增加
# java environment
export JAVA_HOME=/home/currying/org/jdk-17
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
增加java软链
sudo update-alternatives --install /usr/bin/java java /home/currying/org/jdk-17/bin/java 300
sudo update-alternatives --install /usr/bin/jar jar /home/currying/org/jdk-17/bin/jar 300
sudo update-alternatives --install /usr/bin/javac javac /home/currying/org/jdk-17/bin/javac 300
sudo update-alternatives --install /usr/bin/javap javap /home/currying/org/jdk-17/bin/javap 300
安装开发工具
安装配置IDEA
配置程序启动快捷方式
sudo vim /usr/share/applications/idea.desktop
[Desktop Entry]
Name=IntelliJ IDEA
Comment=IntelliJ IDEA
Exec=/home/currying/org/idea-IU/bin/idea.sh
Icon=/home/currying/org/idea-IU/bin/idea.png
Terminal=false
Type=Application
Categories=Developer;
增加启动授权
sudo chmod +x /usr/share/applications/idea.desktop
解决idea中文输入法问题
在idea打开页面
- 点击 help
- 点击 Edit Custom VM options
- 在末行添加:
-Drecreate.x11.input.method=true
安装配置redis
sudo apt update
sudo apt upgrade
sudo apt install tcl
tar xzf redis-6.2.6.tar.gz
cd redis-6.2.6
# PREFIX=/usr/local/soft/redis6 是指安装目录
# 如果不指定,默认安装到 /usr/local/bin 中
sudo make [PREFIX=/usr/local/soft/redis6]
测试
sudo make test
安装
sudo apt make install
生成日志和数据目录
mkdir -p ~/data/redis6
mkdir -p ~/data/redis6/logs
mkdir -p ~/data/redis6/data
修改redis.conf
# 守护进程(daemon)
daemonize yes
# 日志保存目录
logfile "/home/currying/data/redis6/logs/redis.log"
# 数据保存目录
dir /home/currying/data/redis6/data
# 使用的最大内存容量
maxmemory 256MB
# signal systemd 将 READY = 1写入$ NOTIFY_SOCKET
supervised systemd
# 密码
requirepass 123456
daemonize 是守护进程。
生成启动文件
# 启动文件位于源码的utils目录下
sudo cp -axv redis_init_script /etc/init.d/redis
sudo chmod +x /etc/init.d/redis
sudo update-rc.d redis defaults
修改启动文件
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
...
PIDFILE=/home/currying/data/redis/redis_${REDISPORT}.pid
CONF="/home/currying/data/redis/conf/redis.conf"
启动&停止
sudo service redis start
sudo service redis stop
如果出错可以看看端口占用情况
ss -lntps | grep 6379
第二种启动方式
上述的启动文件方式总是有点问题,停止不了。
创建redis用户
sudo useradd -r -s /sbin/nologin redis
创建打开 redis.service
sudo gedit /etc/systemd/system/redis.service
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
Type=forking
ExecStart=/usr/local/bin/redis-server /home/currying/data/redis6/conf/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
ExecStartPost=/bin/sh -c "echo $MAINPID > /home/currying/data/redis6/redis.pid"
Restart=always
[Install]
WantedBy=multi-user.target
安装nvm
brew install nvm
结束后将提示的配置文件加入 ~/.zshrc
文件尾部
nvm install v14.18.0 && nvm alias default v14.18.0 && nvm use v14.18.0
安装angular
npm install -g @angular/cli
安装文字排版工具texlive
自己去texlive查看