# Linux学习 **Repository Path**: hrbu-2022/linux-learning ## Basic Information - **Project Name**: Linux学习 - **Description**: Linux学习 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-06 - **Last Updated**: 2025-05-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 使用现有的虚拟机 选择任意一个压缩包,解压到当前文件夹 ![image-20250506093210169](imgs/image-20250506093210169.png) ![image-20250506093349509](imgs/image-20250506093349509.png) ![image-20250506093428810](imgs/image-20250506093428810.png) ![image-20250506093447309](imgs/image-20250506093447309.png) ![image-20250506093520842](imgs/image-20250506093520842.png) ![image-20250506093543656](imgs/image-20250506093543656.png) 使用 root/root登录 ![image-20250506093704230](imgs/image-20250506093704230.png) ## 配置静态IP 通过检查vmnet8 的网卡地址 ![image-20250506102957435](imgs/image-20250506102957435.png) ![image-20250506103248150](imgs/image-20250506103248150.png) 通过观察发现网卡的地址是 192.168.49.1 虚拟机应该配置的网卡 192.168.**49.**100 切换目录 ```shell cd /etc/NetworkManager/system-connections vi ens33.connection ``` vi之后回车 ![image-20250506103616625](imgs/image-20250506103616625.png) 敲 `i `切换为编辑模式 ![image-20250506103641234](imgs/image-20250506103641234.png) 修改之后的地址 ![image-20250506103815331](imgs/image-20250506103815331.png) 退出编辑模式 敲 ```ESC`` 输入 保存并退出 ``` :wq ``` ![image-20250506103946818](imgs/image-20250506103946818.png) ## 重启网卡 ``` nmcli connection reload ens33.nmconnection nmcli connection up ens33 ``` ![image-20250506104205849](imgs/image-20250506104205849.png) ## 查看网卡信息 ``` ip addr ``` ![image-20250506104233394](imgs/image-20250506104233394.png) ## 测试网络连通性 虚拟机--外网 ``` ping www.baidu.com ``` 虚拟机(192.168.49.100)--> 真机 192.168.84.47 真机( 192.168.84.47)-->虚拟机(192.168.49.100) # 使用客户端软件连接 Final Shell Putty xShell Nshell https://dl.hostbuf.com/finalshell3/finalshell_windows_x64.exe # 用户和组的添加 - 添加用户和组 ```shell groupadd oracle useradd orcl -d /home/oracle -g oracle ``` 查看用户和组 ``` tail -n 1000 /etc/passwd ``` ![image-20250512143719393](imgs/image-20250512143719393.png) 使用root账号 修改密码 ``` passwd orcl ``` ![image-20250512144212495](imgs/image-20250512144212495.png) 使用新用户登录 ![image-20250512144341943](imgs/image-20250512144341943.png) # su 切换用户身份 - su username - su - username - su 默认切换到root # sudo 使用管理员身份操作 - 创建一个root 组的 用户 ```` useradd mysql-d /home/mysql -g root ```` 添加mysql 用户到 sudo 用户列表、 使用root 登录编辑 ``` visodu /etc/sudoers ``` mysql ALL=(ALL) ALL ![image-20250512153402797](imgs/image-20250512153402797.png) 通过sudo 临时切换到 超级管理员的身份 测试 使用mysql 用户登录, 编辑网卡 ``` sudo vi /etc/NetworkManager/system-connections/ens33.nmconnection ``` 需要输入的是 mysql的密码 # 压缩和解压缩 ## 打包 ``` tar -zcvf 压缩文件的文件名 打包压缩的目录 ``` ``` tar -zcvf software.tar.gz software ``` ## 解压缩 ``` tar -xzvf 压缩包的文件名 ``` ``` tar -xzvf software.tar.gz ``` # 下载jdk17 从官网下载 https://www.oracle.com/java/technologies/downloads/ ![image-20250513084945237](imgs/image-20250513084945237.png) ![image-20250513084957061](imgs/image-20250513084957061.png) ## 上传到 linux ![image-20250513085040445](imgs/image-20250513085040445.png) ![image-20250513085102535](imgs/image-20250513085102535.png) ![image-20250513085135453](imgs/image-20250513085135453.png) ## 解压 切换目录到 opt ``` cd /opt ``` ![image-20250513085209507](imgs/image-20250513085209507.png) **解压** ```shell tar -zxvf jdk-17.0.15_linux-x64_bin.tar.gz ``` ![image-20250513085428523](imgs/image-20250513085428523.png) ## 进入bin测试java命令 ``` cd /opt/jdk-17.0.15/bin java -version ``` ![image-20250513085938400](imgs/image-20250513085938400.png) ## 删除jdk21 ```java rpm -e jdk-21-21.0.6-8.x86_64 ``` ## 添加jdk17的环境变量 编辑用户下的 环境变量的文件 修改用户家目录中的 .bashrc /root/.bashrc ``` vi /root/.bashrc PATH=/opt/jdk-17.0.15/bin:$PATH export PATH ``` ![image-20250513091337808](imgs/image-20250513091337808.png) 手动加载一次 .bashrc ``` source /root/.bashrc ``` 查看环境变量 ``` echo $PATH ``` ![image-20250513091445852](imgs/image-20250513091445852.png) ## 验证JDK ``` java -version ``` ![image-20250513092109470](imgs/image-20250513092109470.png) # DNF - 安装源 ## 安装 gcc g++ ``` dnf install -y gcc g++ ``` ![image-20250513095855922](imgs/image-20250513095855922.png) ## 测试gcc 编写c语言的代码 ```` #include "stdio.h" void main(){ printf("hello gcc\n"); return; } ```` ![image-20250513100312202](imgs/image-20250513100312202.png) ```shell [root@neuedu-alma-linux ~]# vi demo1.c [root@neuedu-alma-linux ~]# ll total 12 -rw-r--r--. 1 root root 110 Jan 24 14:05 Run.java -rw-------. 1 root root 843 Jan 24 10:36 anaconda-ks.cfg -rw-r--r--. 1 root root 95 May 7 15:51 demo1.c # 编译 c代码 [root@neuedu-alma-linux ~]# gcc demo1.c -o demo1 [root@neuedu-alma-linux ~]# ll total 32 -rw-r--r--. 1 root root 110 Jan 24 14:05 Run.java -rw-------. 1 root root 843 Jan 24 10:36 anaconda-ks.cfg -rwxr-xr-x. 1 root root 17488 May 7 15:51 demo1 -rw-r--r--. 1 root root 95 May 7 15:51 demo1.c # 执行 [root@neuedu-alma-linux ~]# ./demo1 hello gcc [root@neuedu-alma-linux ~]# ``` ![image-20250513100339452](imgs/image-20250513100339452.png) ## Nginx软件 ### 使用源码安装(不需要操作,了解) wget 路径 ``` wget https://nginx.org/download/nginx-1.26.3.tar.gz ``` ![image-20250513104256876](imgs/image-20250513104256876.png) ![image-20250513104318110](imgs/image-20250513104318110.png) ![image-20250513104411348](imgs/image-20250513104411348.png) 安装确实的模块 ``` sudo dnf install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel ``` ![image-20250513104536365](imgs/image-20250513104536365.png) ![image-20250513104657374](imgs/image-20250513104657374.png) ``` 执行make命令 编译 make 安装 sudo make install ``` ### dnf的方式安装 ```shell dnf install -y nginx ``` ![image-20250513104921417](imgs/image-20250513104921417.png) # Nginx使用 检查安装的位置 ``` cd /etc/nginx ls ``` ![image-20250513105034414](imgs/image-20250513105034414.png) ``` #任意位置 敲 nginx命令 nginx ``` ![image-20250513105123403](imgs/image-20250513105123403.png) ![image-20250513105211124](imgs/image-20250513105211124.png) ## 关闭防火墙 ``` sudo systemctl stop firewalld sudo systemctl disable firewalld ``` ## 访问nginx 在浏览器中敲 http://ip:port/项目的名称(网站的名称) ![image-20250513105627747](imgs/image-20250513105627747.png) 修改测试页面 ``` cd /usr/share/testpage ``` ![image-20250513110029883](imgs/image-20250513110029883.png) 修改nginx ```html Document
使用vue 实现的 网站
``` ![image-20250513110453088](imgs/image-20250513110453088.png)