Debian的基本使用

前言

本人撰写的相关文档中,部分技术已经不再提供支持了(不得不感慨,菜鸡的个人进步追不上技术更新啊),比如Centos、EasyExcel,虽然说目前仅使用还没有什么问题,但是还是要了解一下备用方案。

Centos已经不再维护了,需要考虑使用其他系统,如Debian等,本次就先对Debian进行一下了解。国产化的如龙蜥、麒麟等也发展的很不错,也可以作为后续了解的方向。

需要说明的是,本人水平有限,理论知识就不班门弄斧了,大家可以自行在网上搜索,本次仅安装配置一些之前运行在centos上的软件,如git、maven等。

Debian安装配置JDK17

  • 查看Debian版本

    root@iZuf67owyzd0wopzvdfgsyZ:/# cat /etc/debian_version
    12.7

  • 安装jdk

12版本是可以直接安装jdk17的,如果想安装其他版本,可以使用wget的形式

先更新软件包信息

apt update

查看可安装的jdk版本

root@iZuf67owyzd0wopzvdfgsyZ:/# apt search /*-jdk
Sorting... Done
Full Text Search... Done
default-jdk/stable 2:1.17-74 amd64
  Standard Java or Java compatible Development Kit

default-jdk-doc/stable 2:1.17-74 amd64
  Standard Java or Java compatible Development Kit (documentation)

default-jdk-headless/stable 2:1.17-74 amd64
  Standard Java or Java compatible Development Kit (headless)

golang-github-jdkato-prose-dev/stable 1.2.1-1 all
  Golang library for text processing

golang-github-jdkato-syllables-dev/stable 0.1.0+git20170409.10.8961fa0-1.1 all
  Go syllable counter

openjdk-17-jdk/stable-security 17.0.13+11-2~deb12u1 amd64
  OpenJDK Development Kit (JDK)

openjdk-17-jdk-headless/stable-security 17.0.13+11-2~deb12u1 amd64
  OpenJDK Development Kit (JDK) (headless)

安装jdk17

root@iZuf67owyzd0wopzvdfgsyZ:/# apt install openjdk-17-jdk
#后续安装信息较多,不做展示

查看jdk目录

#java可执行文件所在位置
root@iZuf67owyzd0wopzvdfgsyZ:/# which java
/usr/bin/java
#jdk目录一般默认放置在/usr/lib/jvm/java-17-openjdk-amd64
root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# dpkg -L openjdk-17-jdk
/.
/usr
/usr/lib
/usr/lib/jvm
/usr/lib/jvm/java-17-openjdk-amd64
/usr/lib/jvm/java-17-openjdk-amd64/bin
/usr/lib/jvm/java-17-openjdk-amd64/bin/jconsole
/usr/lib/jvm/java-17-openjdk-amd64/include
/usr/lib/jvm/java-17-openjdk-amd64/include/jawt.h
/usr/lib/jvm/java-17-openjdk-amd64/include/linux
/usr/lib/jvm/java-17-openjdk-amd64/include/linux/jawt_md.h
/usr/lib/jvm/java-17-openjdk-amd64/man
/usr/lib/jvm/java-17-openjdk-amd64/man/man1
/usr/lib/jvm/java-17-openjdk-amd64/man/man1/jconsole.1.gz
/usr/lib/jvm/openjdk-17
/usr/share
/usr/share/doc
/usr/share/doc/openjdk-17-jre-headless
/usr/share/doc/openjdk-17-jre-headless/test-amd64
/usr/share/doc/openjdk-17-jre-headless/test-amd64/check-hotspot-hotspot.log.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/check-jaxp-hotspot.log.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/check-jdk-hotspot.log.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/check-langtools-hotspot.log.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/failed_tests-hotspot.tar.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/jtreg-summary-hotspot.log
/usr/share/doc/openjdk-17-jre-headless/test-amd64/jtreg_output-hotspot.log.gz
/usr/share/doc/openjdk-17-jre-headless/test-amd64/jtreport-hotspot.tar.gz
/usr/lib/jvm/openjdk-17/src.zip
/usr/share/doc/openjdk-17-jdk

查看jdk版本

root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# java -version
openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment (build 17.0.13+11-Debian-2deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.13+11-Debian-2deb12u1, mixed mode, sharing)

安装成功

Debian安装配置Git

故技重施,查看可安装的git

root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# apt search git
Sorting... Done
Full Text Search... Done
0install/stable 2.18-2 amd64
  cross-distribution packaging system

0install-core/stable 2.18-2 amd64
  cross-distribution packaging system (non-GUI parts)

aerc/stable 0.14.0-1+b5 amd64
  Pretty Good Email Client

aevol/stable 5.0+ds-3+b1 amd64
  digital genetics model to run Evolution Experiments in silico
.......

下面会出现非常多的安装包,不好定位,search是支持正则表达式的,可以借助正则表达式

root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# apt search  '^git$'
Sorting... Done
Full Text Search... Done
git/stable-security 1:2.39.5-0+deb12u1 amd64
  fast, scalable, distributed revision control system
  • 安装git

    root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# apt install git

  • 查看git版本信息

    root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# git --version
    git version 2.39.5

  • 配置git

    #添加用户名和邮箱,需自行替换
    root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# git config --global user.name "test"
    root@iZuf67owyzd0wopzvdfgsyZ:/usr/lib/jvm/java-17-openjdk-amd64# git config --global user.email "****@qq.com"

查看git配置

root@iZuf67owyzd0wopzvdfgsyZ:/etc# git config --list --show-origin
file:/root/.gitconfig   user.name=test
file:/root/.gitconfig   user.email=****@qq.com
  • 生成公钥

    root@iZuf67owyzd0wopzvdfgsyZ:~# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa
    Your public key has been saved in /root/.ssh/id_rsa.pub

  • 查看公钥

    root@iZuf67owyzd0wopzvdfgsyZ:~# cd /root/.ssh
    root@iZuf67owyzd0wopzvdfgsyZ:~/.ssh# ls
    authorized_keys id_rsa id_rsa.pub
    root@iZuf67owyzd0wopzvdfgsyZ:~/.ssh# cat id_rsa.pub
    #内容复制下,配置gitee需要用


  • 将公钥配置到gitee中

clone一个项目

新建目录
root@iZuf67owyzd0wopzvdfgsyZ:~/.ssh# mkdir /demo
#进入目录

root@iZuf67owyzd0wopzvdfgsyZ:~/.ssh# cd /demo
#clone gitee项目,需自行替换
root@iZuf67owyzd0wopzvdfgsyZ:/demo# git clone git@gitee.com:**/***.git
Cloning into 'demo'...
The authenticity of host 'gitee.com (180.76.198.225)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
remote: Enumerating objects: 139, done.
remote: Counting objects: 100% (120/120), done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 139 (delta 19), reused 0 (delta 0), pack-reused 19
Receiving objects: 100% (139/139), 14.93 KiB | 804.00 KiB/s, done.
Resolving deltas: 100% (19/19), done.

Debian安装配置Maven

  • 查找可安装的maven

    root@iZuf67owyzd0wopzvdfgsyZ:/demo# apt search '^maven$'
    Sorting... Done
    Full Text Search... Done
    maven/stable 3.8.7-1 all
    Java software project management and comprehension tool

  • 安装maven

中间遇到选项选y

root@iZuf67owyzd0wopzvdfgsyZ:/demo# apt install maven
*****
update-alternatives: using /usr/share/maven/bin/mvn to provide /usr/bin/mvn (mvn) in auto mode
  • 查看maven版本

    root@iZuf67owyzd0wopzvdfgsyZ:/demo# mvn -version
    Apache Maven 3.8.7
    Maven home: /usr/share/maven
    Java version: 17.0.13, vendor: Debian, runtime: /usr/lib/jvm/java-17-openjdk-amd64
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "6.1.0-25-amd64", arch: "amd64", family: "unix"

  • 换源

也可以用vim的

nano /etc/maven/settings.xml

找到mirror标签,进行替换

<mirror>
    <id>aliyunmaven</id>
    <mirrorOf>*</mirrorOf>
    <name>阿里云公共仓库</name>
    <url>https://maven.aliyun.com/repository/public</url>
</mirror>
  • 测试

进入demo目录

root@iZuf67owyzd0wopzvdfgsyZ:/demo/demo# cd /demo/demo

进行打包

root@iZuf67owyzd0wopzvdfgsyZ:/demo/demo# mvn clean package
[INFO] Scanning for projects...
*******
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:45 min
[INFO] Finished at: 2024-11-04T15:30:28+08:00
[INFO] ------------------------------------------------------------------------

其实总体的流程和在centos上进行安装配置是比较类似的,就是部分命令不一样

相关推荐
杨半仙儿还未成仙儿1 小时前
linux ls -l 输出 drwxr-xr-x 2 root root 4096 Dec 5 21:48 rootTest 是什么意思
linux·运维·xr
内核程序员kevin1 小时前
使用trace-cmd跟踪Linux内核函数:一次愉快的内核探险
linux·运维·linux内核·ftrace
moxiaoran57532 小时前
使用Feign远程调用丢失请求头问题
运维·服务器
come-昂-2 小时前
Zephyr2.7.0与3.7.0测试用例版本差异
linux·运维·服务器·测试用例
快刀一哥2 小时前
ubuntu扩展虚拟你
linux·运维·ubuntu
假客套2 小时前
2024 阿里云Debian12.8安装Redis【图文讲解】
数据库·redis·网络安全·debian
confident32 小时前
centos 常见问题处理
linux·运维·centos
海岛日记3 小时前
Docker、DBGPT一键安装、卸载
运维·docker·容器
kaoa0003 小时前
Linux入门攻坚——40、Linux集群系统入门-lvs(1)
linux·运维·服务器
墨痕诉清风4 小时前
MacOS安装软件后无法启动报错:“已损坏,无法打开,你应该将它移到废纸篓“
linux·运维·服务器