| TAG | Log4j2、JNDI、RCE |
| 漏洞等級: | 攻擊者利用此漏洞,可實現遠程代碼執行。 |
| 版本: | 1.1 |
簡介
Apache Log4j是Apache的一個開源項目,Apache log4j2是Log4j的升級版本,我們可以控制日志信息輸送的目的地為控制台、文件、GUI組件等,通過定義每一條日志信息的級別,能夠更加細致地控制日志的生成過程。
漏洞概述
12月9日,網上披露Apache Log4j2 遠程代碼執行漏洞,由於Apache Log4j2某些功能存在遞歸解析功能,未經身份驗證的攻擊者通過發送特別構造的數據請求包,可在目標服務器上執行任意代碼。漏洞PoC已在網上公開,默認配置即可進行利用,該漏洞影響范圍極廣,建議相關用戶盡快采取措施進行排查與防護。
12月10日,Apache Log4j 2.15.0-rc1 版本僅修復LDAP和增加了host白名單,可以被繞過利用,官方發布了Apache Log4j 2.15.0-rc2版本進行修復,增加了對urI異常的處理。
Apache Log4j2是一款開源的Java日志框架,被廣泛地應用在中間件、開發框架與Web應用中,用來記錄日志信息。
漏洞成功復現信息:
| 漏洞細節 | 漏洞PoC | 漏洞EXP | 利用 |
|---|---|---|---|
| 已公開 | 已公開 | 已公開 | 存在 |
參考鏈接:
https://issues.apache.org/jira/projects/LOG4J2/issues/LOG4J2-3201?filter=allissues
受影響版本
- 2.0 <= Apache Log4j <= 2.15.0-rc1
注:使用Apache Log4j 1.X版本的應用,若開發者對JMS Appender利用不當,可對應用產生潛在的安全影響。
供應鏈影響范圍
已知受影響應用及組件:
Apache Solr
Apache Struts2
Apache Flink
Apache Druid
spring-boot-strater-log4j2
更多組件可參考如下鏈接:
https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core/usages?p=1
不受影響版本
Apache log4j-2.15.0-rc2(與官網的2.15.0穩定版相同)
漏洞檢測
人工檢測
1、用戶可以更加java jar解壓后查看是否存在org/apache/logging/log4j相關路徑結構,判斷是否存在使用的漏洞組件,如果存在相關java程序包,說明很有可能存在漏洞。

2、程序使用gradle打包,可以查看build.gradle編譯配置文件,若在dependencies部分存在org.apache.logging.log4j相關字段,且版本號為小於2.15.0-rc2,說明存在該漏洞。
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.1'
}
修復后
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.15.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.15.0'
}
3、若程序使用maven打包,查看項目的pom.xml文件中是否存在下圖所示相關字段,若版本號為小於2.15.0-rc2,說明存在該漏洞。
dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.12.1</version>
</dependency>
</dependencies>
修復后的
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.15.0</version>
</dependency>
</dependencies>
攻擊排查
- 攻擊者在利用前通常采用 dnslog 方式進行掃描、探測,對於常見
利用方式可通過應用系統報錯日志中的
“javax.naming.CommunicationException”、
“javax.naming.NamingException: problem generating object using object factory”、”Error looking up JNDI resource”關鍵字進行排查。 - 流量排查:攻擊者的數據包中可能存在:“${jndi:rmi”、
“${jndi:ldap” 字樣
漏洞修復方案:
Apache官方已發布補丁,建議受影響的用戶盡快升級到安全版本。
補丁下載地址:
https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc1
漏洞緩解措施:
(1)jvm參數 -Dlog4j2.formatMsgNoLookups=true
(2)log4j2.formatMsgNoLookups=True
建議 JDK 使用 11.0.1、8u191、7u201、6u211 及以上的高版本。
官方文檔:
https://logging.apache.org/log4j/2.x/maven-artifacts.html
https://hxg-packages.%88%BF2%E6%B5%8B%E8%AF%95%E5%8C%85.zip
================================================
安裝步驟
tar xfz gromacs-2023.3.tar.gz
cd gromacs-2023.3
mkdir build
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
make
make check
sudo make install
source /usr/local/gromacs/bin/GMXRC
下載地址: https://ftp.gromacs.org/gromacs/gromacs-2023.3.tar.gz
CentOS 7.6 安裝部署Gromacs 2023 布朗動力學模擬
安裝要求:
獲取最新版本的C和C++編譯器。
使用:gcc版本9.3,路徑加入到bashrc
檢查您是否擁有CMake 3.18.4或更高版本。
使用:cmake-3.23.5
獲取並打開GROMACS tarball的最新版本。
制作一個單獨的生成目錄並對其進行更改。
以源路徑為參數運行cmake
運行make、make check和make install
來源GMXRC以訪問GROMACS
這里對gromcas的編譯依賴於python3版本和gcc的高版本(最低要求是5.x版本)
但是在Centos里,默認的python是2.x版本,gcc默認是4.x版本。使用yum對gcc的升級最多到4.x版本。
軟件下載地址:
gcc
http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-3.el7.centos.noarch.rpm
cmake
https://cmake.org/files/v3.25/
主題簡述
Gromacs是研究生物大分子體系的動力學模擬軟件,在國內外有着廣泛的應用。目前Gromacs只發布了基於Linux/Unix的安裝程序包,本教程將介紹在VMware虛擬機上安裝Gromacs正式版本2019.6。
工具/原料
VMware 虛擬機容器和Linux系統CentOS7對應鏡像文件——官網下載
Cmake和Gromacs程序包——官網下載(Gromacs官網和cmake官網下載安裝程序包(http://manual.gromacs.org/documentation/ 以及 https://cmake.org/download/)
Gromacs詳細安裝教程
1、檢查和安裝C/C++
檢查命令
gcc -v
安裝命令
sudo yum install gcc (這里sudo是獲取臨時root權限,需要管理員密碼;另外用"su"命令進行root操作也可以)
CentOS7.6 gcc9.3安裝方法
更新gcc版本
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-3.el7.centos.noarch.rpm
[root@lianglab tmp]# yum -y install centos-release-scl-2-3.el7.centos.noarch.rpm
Loaded plugins: fastestmirror
Examining centos-release-scl-2-3.el7.centos.noarch.rpm: centos-release-scl-2-3.el7.centos.noarch
Marking centos-release-scl-2-3.el7.centos.noarch.rpm to be installed
Resolving Dependencies
2.安裝devtoolset:
這里需要注意一下,如果想安裝7.版本的,就改成devtoolset-7-gcc,以此類推.
sudo yum install devtoolset-9-gcc-c++
3. 激活對應的devtoolset:
scl enable devtoolset-9 bash
或者
source /opt/rh/devtoolset-9/enable
[root@lianglab tmp]# scl enable devtoolset-9 bash
[root@lianglab tmp]# source /opt/rh/devtoolset-9/enable
[root@lianglab tmp]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
[root@lianglab tmp]#
若是重新安裝gcc,從而提高gcc的版本,就很費時費磁盤空間,這里介紹一種普遍的方法來暫時的更新gcc:
yum安裝相關依賴,將gcc提高到8.x版本:
yum install centos -release-scl -y
yum install devtoolset-8 -y
安裝成功后,輸入如下命令,打開一個新bash,在里面暫時更新gcc的版本:
scl enable devtoolset-8 bash
查看gcc的版本:
gcc --version
若是上面的方法不能更新gcc,可以使用如下方法使用devtoolset-8的內置腳本:
source /opt/rh/devtoolset-8/enable
這個就不會新開bahs,檢查gcc版本:
gcc --version




查看gcc版本

2、檢查cmake
cmake -version
說明:
如果沒有安裝cmake或版本過低,需要到網上下載,yum資源庫中的cmake版本一般較低:
下載安裝包: https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz
wget https://github.com/Kitware/CMake/releases/download/v3.23.5/cmake-3.23.5-linux-x86_64.tar.gz
(用系統自帶的下載工具下載)
3、cmake安裝步驟
$ tar zxvf cmake-3.25.1-linux-x86_64.tar.gz (解壓安裝包)
cd /opt && mkdir cmake
cd cmake
wget -c https://cmake.org/files/v3.25/cmake-3.25.1-linux-x86_64.tar.gz
tar -zxvf cmake-3.25.1-linux-x86_64.tar.gz
vi /etc/profile.d/cmakeenv.sh
export CMAKE_HOME=/opt/cmake/cmake-3.25.1-linux-x86_64/bin
export PATH=$CMAKE_HOME:$PATH
source /etc/profile
cmake --version

4、Python3安裝
解決依賴關系:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel
tar -zxf Python-3.7.12.tgz -C .
cd Python-3.7.12 && ./configure prefix=/usr/local/python3
進行安裝:
make && make -j 4 install
Generating grammar tables from /usr/local/python3/lib/python3.7/lib2to3/PatternGrammar.txt
Writing grammar tables to /usr/local/python3/lib/python3.7/lib2to3/PatternGrammar3.7.12.final.0.pickle
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpudhcmddy
Processing /tmp/tmpudhcmddy/setuptools-47.1.0-py3-none-any.whl
Processing /tmp/tmpudhcmddy/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
WARNING: The script easy_install-3.7 is installed in '/usr/local/python3/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts pip3 and pip3.7 are installed in '/usr/local/python3/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.1.1 setuptools-47.1.0
[root@lianglab Python-3.7.12]#
編譯安裝成功后,進入到/usr/local/python3文件夾里查看是否成功安裝:
[root@lianglab Python-3.7.12]# cd /usr/local/python3/bin && ll
total 31600
lrwxrwxrwx. 1 root root 8 Dec 1 01:07 2to3 -> 2to3-3.7
-rwxr-xr-x. 1 root root 109 Dec 1 01:07 2to3-3.7
-rwxr-xr-x. 1 root root 246 Dec 1 01:08 easy_install-3.7
lrwxrwxrwx. 1 root root 7 Dec 1 01:07 idle3 -> idle3.7
-rwxr-xr-x. 1 root root 107 Dec 1 01:07 idle3.7
-rwxr-xr-x. 1 root root 237 Dec 1 01:08 pip3
-rwxr-xr-x. 1 root root 237 Dec 1 01:08 pip3.7
lrwxrwxrwx. 1 root root 8 Dec 1 01:07 pydoc3 -> pydoc3.7
-rwxr-xr-x. 1 root root 92 Dec 1 01:07 pydoc3.7
lrwxrwxrwx. 1 root root 9 Dec 1 01:07 python3 -> python3.7
-rwxr-xr-x. 2 root root 16161800 Dec 1 01:07 python3.7
lrwxrwxrwx. 1 root root 17 Dec 1 01:07 python3.7-config -> python3.7m-config
-rwxr-xr-x. 2 root root 16161800 Dec 1 01:07 python3.7m
-rwxr-xr-x. 1 root root 2910 Dec 1 01:07 python3.7m-config
lrwxrwxrwx. 1 root root 16 Dec 1 01:07 python3-config -> python3.7-config
lrwxrwxrwx. 1 root root 10 Dec 1 01:07 pyvenv -> pyvenv-3.7
-rwxr-xr-x. 1 root root 449 Dec 1 01:07 pyvenv-3.7
[root@lianglab bin]#
使用軟連接將python3編譯器和pip鏈接到/usr/bin里,方便在命令行里調用:
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@lianglab bin]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@lianglab bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@lianglab bin]#
最后在命令行里輸入python3查看能否打開python3編譯器:
[root@lianglab bin]# python3
Python 3.7.12 (default, Dec 1 2023, 01:06:32)
[GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
————————————————
wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz








5、安裝Gromacs
官網下載
下載安稱耍裝包: https://ftp.gromacs.org/gromacs/gromacs-2023.3.tar.gz
(用辭泥系統自帶的下載工具下載) (如下圖)
$ tar xfz gromacs-2019.6.tar.gz (解壓安裝包)
$ cd gromacs-2019.6 (進入目錄)
$ mkdir build (新建文件夾build) (如下圖)
$ cd build (進入目錄)
$ cmake .. -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs-2019.6 (要求安裝過程中自動下載FFTW庫文件,指定程序安裝到目錄/usr/local/gromacs-2019.6)
$ make (編譯時間比較長)
$ make check
$ sudo make install (安裝)
tar xfz gromacs-2023.3.tar.gz
cd gromacs-2023.3
mkdir build
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
make
make check
sudo make install
source /usr/local/gromacs/bin/GMXRC
[root@lianglab tmp]# tar zxvf gromacs-2023.3.tar.gz
[root@lianglab tmp]# cd gromacs-2023.3
[root@lianglab gromacs-2023.3]# ls
admin AUTHORS cmake COPYING CPackInit.cmake docs python_packaging scripts src
api CITATION.cff CMakeLists.txt COPYING.derived CTestConfig.cmake INSTALL README share tests
[root@lianglab gromacs-2023.3]# mkdir build
[root@lianglab gromacs-2023.3]# cd build
[root@lianglab build]# cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
------------------------------省略---------------------------
-- [download 99% complete]
-- [download 100% complete]
-- Could NOT find Sphinx (missing: SPHINX_EXECUTABLE pygments) (Required is at least version "4.0.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/gromacs-2023.3/build
[root@lianglab build]# make
------------------------------省略---------------------------
[ 98%] Linking CXX shared library ../../lib/libnblib_gmx.so
[ 98%] Built target nblib
[ 98%] Building CXX object api/nblib/samples/CMakeFiles/argon-forces-integration.dir/argon-forces-integration.cpp.o
[ 98%] Linking CXX executable ../../../bin/argon-forces-integration
[ 98%] Built target argon-forces-integration
[ 98%] Building CXX object api/nblib/samples/CMakeFiles/methane-water-integration.dir/methane-water-integration.cpp.o
[100%] Linking CXX executable ../../../bin/methane-water-integration
[100%] Built target methane-water-integration
[100%] Building CXX object src/programs/CMakeFiles/mdrun_objlib.dir/mdrun/mdrun.cpp.o
[100%] Building CXX object src/programs/CMakeFiles/mdrun_objlib.dir/mdrun/nonbonded_bench.cpp.o
[100%] Built target mdrun_objlib
[100%] Building CXX object src/programs/CMakeFiles/gmx_objlib.dir/gmx.cpp.o
[100%] Building CXX object src/programs/CMakeFiles/gmx_objlib.dir/legacymodules.cpp.o
[100%] Built target gmx_objlib
[100%] Linking CXX executable ../../bin/gmx
[100%] Built target gmx
[root@lianglab build]# make check
Start 84: regressiontests/complex
84/87 Test #84: regressiontests/complex ................... Passed 77.63 sec
Start 85: regressiontests/freeenergy
85/87 Test #85: regressiontests/freeenergy ................ Passed 41.03 sec
Start 86: regressiontests/rotation
86/87 Test #86: regressiontests/rotation .................. Passed 2.48 sec
Start 87: regressiontests/essentialdynamics
87/87 Test #87: regressiontests/essentialdynamics ......... Passed 1.54 sec
100% tests passed, 0 tests failed out of 87
Label Time Summary:
GTest = 245.07 sec*proc (81 tests)
IntegrationTest = 199.80 sec*proc (25 tests)
MpiTest = 217.99 sec*proc (19 tests)
QuickGpuTest = 75.73 sec*proc (17 tests)
SlowGpuTest = 279.87 sec*proc (18 tests)
SlowTest = 43.14 sec*proc (13 tests)
UnitTest = 2.13 sec*proc (43 tests)
Total Test time (real) = 367.83 sec
[100%] Built target run-ctest-nophys
[100%] Built target check
[root@lianglab build]#
[root@lianglab build]#
[root@lianglab build]# make install
[root@lianglab build]# source /usr/local/gromacs/bin/GMXRC









6、備注說明:
首先申明不推薦老系統安裝新的軟件,太費事了
安裝軟件的話,首先要考慮環境
首要任務:升級gcc和g++,這塊比較順暢
https://www.123pan.com/s/JylVVv-rv1w3.html
我用誇克網盤分享了「Python-3.7.12.tgz」,點擊鏈接即可保存。打開「誇克APP」,無需下載在線播放視頻,暢享原畫5倍速,支持電視投屏。
鏈接:
https://pan.quark.cn/s/95ab0a50d455
sudo /opt/schily/bin/mkisofs -iso-level 3 -r -V sblive -cache-inodes -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o sblive.iso sblive
grep 'JAVA_HOME' /etc/profile || {
echo 'export JAVA_HOME=/usr/lib/jdk' >>/etc/profile
echo 'export JRE_HOME=${JAVA_HOME}/jre' >>/etc/profile
echo 'export CLASSPATH=.😒{JAVA_HOME}/lib:${JRE_HOME}/lib' >>/etc/profile
echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> /etc/profile
}
source /etc/profile
update-alternatives --install /usr/bin/java java /usr/lib/jdk/bin/javac 300
update-alternatives --install /usr/bin/javac javac /usr/lib/jdk/bin/javac 300
update-alternatives --install /usr/bin/jps jps /usr/lib/jdk/bin/jps 300
clear
java -version
echo 'export JAVA_HOME=/usr/lib/jdk' >>/etc/profile.d/jdkenv.sh
echo 'export JRE_HOME=${JAVA_HOME}/jre' >>/etc/profile.d/jdkenv.sh
echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >>/etc/profile.d/jdkenv.sh
echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> /etc/profile.d/jdkenv.sh
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-get update && sudo apt-get upgrade -y
# 針對WSL1的問題進行處理,不然在解壓縮時可能會出問題。
echo -en '\x10' | sudo dd of=/usr/bin/gzip count=1 bs=1 conv=notrunc seek=$((0x189))
# 安裝Geant4依賴
sudo apt-get install cmake build-essential libgl1-mesa-dev libglu1-mesa-dev libxt-dev libxmu-dev libxi-dev zlib1g-dev libgl2ps-dev libexpat1-dev libxerces-c-dev -y
sudo apt-get install qt5* --fix-missing -y
# 設置Geant4安裝路徑
export G4dir=$HOME/Application/Geant4 # Geant4待安裝路徑
mkdir -p $G4dir
cd $G4dir
# 生成下載地址
wget -O G4temp1 https://geant4.web.cern.ch/support/download# 下載Geant4Release頁面,命名為G4temp1
grep -n '^\s*download' G4temp1 > G4temp2 # 使用grep預處理,將download信息提出出來
awk -F'"' '{i = 1; while (i <= NF) {if ($i ~/G4/) print "https://geant4-data.web.cern.ch/datasets/"$(i)"."$(i+2)".tar.gz";i++}}' G4temp2 > G4downloadList # 使用awk提取文件名並拼接成下載地址
awk -F'"' '{i = 1; while (i <= NF) {if ($i ~/geant4.*?gz/) print "https://geant4-data.web.cern.ch/releases/"$(i);i++}}' G4temp2 >> G4downloadList
rm G4temp* # 清理臨時文件
# 下載Geant4數據及主程序
wget -i G4downloadList
# 編譯安裝主程序
tar -xzvf geant4*.tar.gz # 解壓出geant4開頭的文件,不同版本文件名不同
cd $G4dir/geant4*/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=.. -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON .. # 指定安裝內容,這里加入了QT
make -j4 # 編譯,可以根據計算機CPU線程數來設置
make install
# 將之前下載好的DATA文件放到對應的位置
cd $G4dir
mkdir data
mv G4*gz data
mv data $G4dir/gea*/share/*eant*/ # 需要把data文件放到這里才行
cd $G4dir/gea*/share/*eant*/data
ls *.tar.gz | xargs -n1 tar xzvf # 批量解壓
# 將加載Geant4運行環境的命令開機自啟
echo "source $G4dir/gea*/bin/geant4.sh" >> ~/.bashrc
# 將綁定X轉發端口的命令開機自啟(對應於WSL1的操作。WSL2見更下面)
# 注意,這一步針對WSL。需要將Geant4的QT界面通過X轉發到windows中,這樣才能打開圖形化界面。當然,為此需要在windows上配置xServer(比如xming)。下載下來安裝運行,輸入和下面綁定相同的端口號即可。
# echo "export DISPLAY=localhost:0.0" >> ~/.bashrc #對應於WSL1
# WSL2的這個DISPLAY地址設置有所不同,應該像下面這樣
echo 'host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")' >> ~/.bashrc #對應於WSL2
echo 'export DISPLAY=$host_ip:0.0' >> ~/.bashrc #對應於WSL2
# 注意,這里單引號表示將這個文本原封不動的寫入文件,這樣每次開啟終端時都會自動設置 host_ip,可以應對每次重啟導致wsl2變更host_ip的情況。
[AppStream]
name=AppStream
baseurl=http://mirrors.aliyun.com/almalinux/9.2/AppStream/x86_64/os/
gpgcheck=0
enabled=1
[BaseOS]
name=BaseOS
baseurl=http://mirrors.aliyun.com/almalinux/9.2/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
[extras]
name=extras
baseurl=http://mirrors.aliyun.com/almalinux/9.2/extras/x86_64/os/
gpgcheck=0
enabled=1
[plus]
name=plus
baseurl=http://mirrors.aliyun.com/almalinux/9.2/plus/x86_64/os/
gpgcheck=0
enabled=1
[devel]
name=devel
baseurl=http://mirrors.aliyun.com/almalinux/9.2/devel/x86_64/os/
gpgcheck=0
enabled=1
[NFV]
name=NFV
baseurl=https://mirrors.aliyun.com/almalinux/9.2/NFV/x86_64/os/
gpgcheck=0
enabled=1
[CRB]
name=CRB
baseurl=https://mirrors.aliyun.com/almalinux/9.2/CRB/x86_64/os/
gpgcheck=0
enabled=1
[HighAvailability]
name=HighAvailability
baseurl=https://mirrors.aliyun.com/almalinux/9.2/HighAvailability/x86_64/os/
gpgcheck=0
enabled=1
[epel-USTC]
name=epel-USTC--CentOS-$releasever
baseurl=https://mirrors.ustc.edu.cn/epel/$releasever/Everything/$basearch/
enabled=1
gpgcheck=0
https://cn.download.nvidia.cn/XFree86/Linux-x86_64/535.146.02/NVIDIA-Linux-x86_64-535.146.02.run
1.安裝依賴環境、查看內核版本
查看內核版本
[root@localhost ~]# ls /boot | grep vmlinu
[root@localhost ~]# rpm -aq | grep kernel-devel
安裝依賴環境
yum -y install gcc dkms
yum install kernel-devel kernel-doc kernel-headers gcc\* glibc\* glibc-\*
2.禁用nouveau
查看命令
lsmod | grep nouveau
修改dist-blacklist.conf文件:
vim /lib/modprobe.d/dist-blacklist.conf
將nvidiafb注釋掉:
#blacklist nvidiafb
然后添加以下語句:
blacklist nouveau
options nouveau modeset=0
重建initramfs image
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut /boot/initramfs-$(uname -r).img $(uname -r)
重啟
reboot
確認nouveau已被禁用
lsmod | grep nouveau
