# 查看宿主主机IP
ip route | grep default | awk '{print $3}'
cat /etc/resolv.conf
# 查看本机IP
ip a |grep "global eth0"
hostname -I | awk '{print $1}'
# 安装MySQL客户端
sudo apt-get install mysql-client
# 保留文件属性的多文件或文件夹的压缩及解压
tar --xattrs --xattrs-include=* -zcvf scala-env.tar.gz .cache .config .g8 .ivy2 .local .sbt cs hello-scala3 .motd_shown
tar --xattrs --xattrs-include=* -zxvf scala-env.tar.gz
# 创建目录并切换到新建的目录下
mkdir -p $HOME/Downloads/Jdk && cd "$_"
# 为应用创建别名,方便自己使用
alias dir=ls
配置防火墙
sudo ufw allow 3389
修改系统软件仓库
sudo sed -i 's/http:\/\/archive.ubuntu.com/https:\/\/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
# 安装open jdk
sudo apt-get install openjdk-21-jdk
/usr/lib/jvm/java-21-openjdk-amd64
# 脚本
vi ~/.bashrc
setJavaHome() {
case $1 in
8)
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
;;
11)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
;;
17)
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
;;
21)
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
;;
*)
echo "不支持的Java版本: $1"
return 1
esac
export PATH=$JAVA_HOME/bin:$PATH
echo "JAVA_HOME set to $JAVA_HOME"
java -version
}
source ~/.bashrc
setJavaHome 11
which java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
# 清除缓存并卸载
sudo apt autoclean && sudo apt autoremove
标签:java,amd64,openjdk,常用命令,jvm,Ubuntu,HOME,WSL2,JAVA From: https://www.cnblogs.com/terry-cc/p/17963197