-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux.txt
838 lines (368 loc) · 20.9 KB
/
linux.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
https://www.10besty.com/best-linux-distros/ ------linux发行版排行
// 根据md5值比对是否内容一致
md5sum 1_Slope.png
md5sum wuzhong.png
rz -E // 上传文件
sz // 下载文件
(1)------
(2)Ubuntu, Debian,Fedora, Red Hat, CentOS
(3)学习使用vi命令来编辑文本文件
vi 路径 ------ 进去编辑器
按i ------ 进入编辑状态
按esc ------ 退出编辑状态
按(shift + :)组合键 再输入wq ------ 退出vi并保存
按(shift + :)组合键 再输入q! ------ 退出vi不保存
查找:在命令模式下输入/,按enter查找到第一个结果,按n查找下一个,按N查找上一个
(4)学习使用cp命令来拷贝文件或目录
cp xxxx.conf xxxx_20200119.conf ------ 将当前目录中的xxxx.conf复制到xxxx_20200119.conf(没有该文件会自动创建)
cp -r dest dest_20210715
(5)ls: 查看某一目录中有哪些子目录和文件
ls ------ 查看目录中所有子目录和文件
ls *.png ------ 匹配以.png结尾的图片 或者用grep ls | grep *png
ls *20240307* ------ 在当前目录下查看符合条件的目录(会罗列所有该目录下的子目录或文件, 针对文件过滤更有用,或管道符接grep *20240307* )或文件, 也可用 ll *20240307*
(6)ps -ef | grep java ----查看含有java的进程 (ps -ef | grep "java -jar" ------ 查询所有当前运行的java程序)
(7)kill 45555 ------ 杀死进程
(8)kill -9 4555 ------ 强制杀死进程
文件权限管理:
d rwx r-x r--
文件类型 属主权限(u) 属组权限(g) 其他用户权限(o)
d:目录 r: 可读 4
-:文件 w:可写 2
l:链接 x: 可执行 1
(9)chmod u=rwx,g=r-w,o=rw aa.txt ------ 修改文件权限:使当前用户拥有rwx的权限 当前用户所在组的其他用户拥有r的权限。u:当前用户,g: 属组,o: 其他用户,a: 全部(ugo), +添加权限,-删除权限, =替换权限, r读, w写,x可执行
chmod u=rwx,go=rw aa.txt ------ go写一起 语法中的逗号前后不能有空格
(10)chmod 755 aa.txt ------ 等价于 chmod u=rwx,g=rx,o=rx aa.txt 7 = 4(r) + 2(w) + 1(x) 5 = 4(r) + 1(x)
(6)ping 地址 ------ ping www.baidu.com 学习使用curl命令
(7) ps -ef | grep python 查看进程
(8)kill 18923 20920 20921 20922 20923 20924 ------ 杀死进程
(8.1)kill -9 18923 ------ 强制杀死进程
(8.2)ll /proc/20920 ------ 查看pid为20920的详细信息,proc里存放的是当前所有运行进程的详细信息
(9)rm -rf 文件或目录名称 ------ 删除文件或目录
rm -rf * ------ 删除当前目录下所有文件和目录
(11)getconf LONG_BIT ------ 查看linux系统是多少位的
(12)ls ------ 查看当前目录下的所有文件以及目录
(13)ls -s ------ 查看当前目录下的所有文件以及目录(包含隐藏文件)
(14)ls -l ------ 查看文件或目录的详细信息
(15)ll ------ 相当于ls -al
(16) cd / ------ 到根目录
(17)cd ~ ------ 到用户目录
(18)cd - ------ 返回上一次所在的目录
(19)pwd ------ 查看路径
(20)mkdir 目录名 ------ 创建目录
(21)rmdir 目录名 ------ 删除目录(必须是空目录)
(21)mkdir -p 目录名/子目录名[ 目录名/子目录名 ...] ------ 创建多级目录
(22)rm a.txt ------ 删除文件。 rm -rf ml ------ 删除目录(比较危险的操作,可以不加f参数,以便删除时给予提示)
(23)cat 文件名 ------ 查看文件所有内容
(24)more 文件名 ------ 查看文件,先显示一屏,按enter逐行显示,按space逐页显示,按q或ctrl+c或exit退出,还有一个less命令和more相似
(25)tail -10 文件名 ------ 查看文件最后10行内容
(26)tail -f 文件名 ------ 动态查看文件 结束按ctrl+c
(27)cp a.txt ml ------ 拷贝指定文件到指定目录
(28)cp a.txt ml/b.txt ------ 拷贝指定文件到指定目录并重命名
(29)cp -r ml ml1 ------ 拷贝目录到另一个目录
(30)mv a.txt ml ------ 将指定文件剪切到指定目录
(31)mv a.txt ml/b.txt ------ 将指定文件剪切到指定目录并重命名
(32)mv a.txt a1.txt ------ 将当前目录下的a.txt重命名为a1.txt
(32)tar -zcvf a.tar.gz ./* ------ 将当前目录里所有文件打包并压缩,命名为a.tar.gz
(33)tar -cvf a.tar ./* ------ 将当前目录里所有文件打包,命名为a.tar
(34)tar -zxvf a.tar.gz ------ 将当前目录下的a.tar.gz解压到当期目录
(35)tar -zxvf a.tar.gz -C ml ------ 将当前目录下的a.tar.gz解压到当前ml目录里
(36)find / -name nginx*.log ------ 在根目录下根据文件名称寻找文件,文件名称中可以使用通配符
(37)grep proxy ../nginx.log ------ 在指定文件中查找指定字符串
(38)grep proxy ../nginx.log --color ------ 在指定文件中查找指定字符串并突出显示
(39)clear ------ 清屏 或者按 ctrl + l
(40)cat a.txt > b.txt ------ 将输出重定向到文件(覆盖)
(41)cat a.txt >> b.txt ------ 将输出重定向到文件(追加)
(42)cat a.txt | more ------- 管道
(43)ifconfig ------ 查看ip
(44)lsb_release -a ------ 查看系统信息
(45)防火墙
systemctl status firewalld ------ 查看防火墙状态
systemctl start firewalld ------ 开启防火墙
systemctl stop firewalld ------ 关闭防火墙
sudo firewall-cmd --permanent --add-port=8080/tcp ------ 放行指定端口
sudo firewall-cmd --reload ------ 重新加载使放行的端口生效
sudo firewall-cmd --list-ports ------ 查看被放行的端口
确保启用了防火墙
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --list-all ------ 查看所有放行
linux安装软件的方式:二进制发布包;rpm(不会安装依赖);yum(在线安装,会安装依赖);源码编译安装
(-2)rpm -qpR 包路径 ------ 未被安装时查看rpm包的依赖
(-1)rpm -qR 包名称 ------ 已安装时查看指定包的依赖
(0)rpm -ivh 包路径 ------ 安装rpm包
(1)rpm -qa | grep java ------ 查看之前有没有安装过java
(2)rpm -e --nodeps rpm包名称 ------ 删除指定rpm包(--nodeps: 不要验证包依赖关系)
(3)yum install | update | remove 包名 ------ 安装更新卸载包(yum使用教程:https://blog.csdn.net/MssGuo/article/details/114283074)
(4)yum list | grep mysql ------ 查看有没有安装mysql
(5)yum history ------ 查看历史
(6)javajdk安装
1.官网下载tar包:https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
2.tar -zxvf jdk-17_linux-x64_bin.tar.gz ------ 将jdk解压到当前目录
3.配置环境变量
vim /etc/profile
# 设置java环境变量(文件末尾)
export JAVA_HOME=/software/javajdk/jdk-17.0.2
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile ------ 重新加载配置
4.java -version ------ 查看下版本号看是否安装成功
5.rpm安装:https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
sudo rpm -ivh jdk-17_linux-x64_bin.rpm
6.yum安装
sudo yum update
sudo yum install java-17-openjdk
7.使用rpm和yum会自动配置环境变量
(7)安装mysql8.0 :https://blog.csdn.net/qq_32332469/article/details/115461639
1.rpm -qa | grep mysql ------ 查看mysql是否已安装,如果已安装,执行下面的命令删除
2.rpm -e --nodeps rpm包名称 ------ 删除指定rpm包(--nodeps: 不要验证包依赖关系)
3.mysql8.0社区版下载地址(centos7, rpm-bundle.tar), 步骤如下:
>> https://dev.mysql.com/downloads/mysql/
>> Red Hat Enterprise Linux / Oracle Linux
>> Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)
>> RPM Bundle(mysql-8.0.29-1.el7.x86_64.rpm-bundle.tar), 这里下载了所有功能
4.将下载好的tar文件上传到/software/mysql8目录下:
/software/mysql8/mysql-8.0.29-1.el7.x86_64.rpm-bundle.tar
5.解压tar文件到当前目录:tar -xvf mysql-8.0.29-1.el7.x86_64.rpm-bundle.tar
解压后的rpm文件有:
mysql-community-client-8.0.29-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.29-1.el7.x86_64.rpm
mysql-community-common-8.0.29-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.29-1.el7.x86_64.rpm
mysql-community-devel-8.0.29-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.29-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.29-1.el7.x86_64.rpm
mysql-community-libs-8.0.29-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.29-1.el7.x86_64.rpm
mysql-community-server-8.0.29-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.29-1.el7.x86_64.rpm
mysql-community-test-8.0.29-1.el7.x86_64.rpm
6.安装前先卸载mariadb:
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
如果之前安装过mysql需要先卸载,记着备份数据
7.再安装解包后的rpm文件:
可以先安装mysql服务(mysql-community-server-8.0.29-1.el7.x86_64.rpm),会有依赖缺失的报错而导致安装失败,根据报错提示安装对应的依赖就行,下面还需要安装一个名为libaio的包:
yum install libaio (如果没有网络,可以在一个有网的服务器上用yum下载:yum install --downloadonly --downloaddir=./ libaio)
最后再次安装mysql服务:
rpm -ivh mysql-community-server-8.0.29-1.el7.x86_64.rpm
mysql服务安装成功
8.修改文件权限避免服务启动失败:sudo chown -R mysql.mysql /var/lib/mysql (show用法:https://www.runoob.com/linux/linux-comm-chown.html)
9.启动服务:systemctl start mysqld.service
10.查看服务状态:systemctl status mysqld.service
11.相关文件位置:
/var/lib/mysql ------ 数据文件位置(包含binlog日志)
/etc/my.cnf ------ 配置文件位置
/var/lib/mysql/mysql.sock ------ sock文件位置(用于client连接)
/var/log/mysqld.log ------ 日志文件位置
/var/run/mysqld/mysqld.pid ------ 进程文件位置
/usr/bin/mysql ------ 客户端访问二进制文件位置
/usr/sbin/mysqld ------ 服务端启动二进制文件位置
12.使用客户端登录mysql
mysql -uroot -p ------ 对于初次登录需要用到日志文件(/var/log/mysqld.log)中的临时密码,找到后登录再修改密码
> alter user root@'localhost' identified by 'abcdEF;123456'; ------ 修改密码
13.创建一个能够远程登录的用户(https://blog.csdn.net/weixin_42782150/article/details/124330167)
mysql -uroot -p
> use mysql;
> update user set host='%' where user='root';
> alter user root identified with mysql_native_password by 'abcdEF;123456';
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; # 授权
> FLUSH PRIVILEGES; # 刷新, 两步完成后使用navicat远程ip登录试试
14.重启mysql服务:systemctl restart mysqld.service
15.开机自启动:systemctl enable mysqld
16.修改root密码:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'qwER_1234';
(8)systemctl常用命令(主要与服务相关的命令)
1、启动服务 systemctl start 服务名
2、停止服务 systemctl stop 服务名
3、重启服务 systemctl restart 服务名
4、查看服务是否已启动 systemctl is-active 服务名
5、查看服务的状态 systemctl status 服务名
6、启用开机自启动服务 systemctl enable 服务名
7、停用开机自启动服务 systemctl disable 服务名
8、查看服务是否为开机自启动 systemctl is-enabled 服务名
9、只重启正在运行中的服务 systemctl try-restart 服务名
10、显示所有的服务状态---空格翻页 q推出 systemctl list-units --type service --all
11、查看启动成功的服务列表 systemctl list-unit-files|grep enabled
12、查看启动失败的服务列表 systemctl --failed
13、查看所有服务的状态---空格翻页 q推出 systemctl list-unit-files --type service
14、查看防火墙是否开启:systemctl status firewalld
15、开启防火墙:systemctl start firewalld
(9)安装tomcat: https://blog.csdn.net/qq_30797051/article/details/116267935
1、https://tomcat.apache.org/ >>> download >>> Tomcat10 >>> Binary Distributions >>> Core >>> tar.gz >>> apache-tomcat-10.0.22.tar.gz
2、将下载好的压缩包放到/software/tomcat目录下,并解压到当前目录:tar -zxvf apache-tomcat-10.0.22.tar.gz
3、进入bin目录:cd apache-tomcat-10.0.22
4、在bin目录下执行:./startup.sh 来启动tomcat
5、阿里云配置tomcat服务所使用的端口8080:https://jingyan.baidu.com/article/3c343ff7109c8d4c377963c6.html
6、将tomcat添加到服务(systemctl):
修改bin目录下的catalina.sh文件:
#加入到CATALINA_BASE定义后面(添加在这一行代码的下面:[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME")
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
编辑并创建文件: vim /usr/lib/systemd/system/tomcat.service
[Unit]
Description=Tomcat
After=network.target
[Service]
Type=forking
Environment="CATALINA_HOME=/software/tomcat/apache-tomcat-10.0.22"
Environment="JAVA_HOME=/software/javajdk/jdk-17.0.2"
#PATH不可用变量
PIDFile=/software/tomcat/apache-tomcat-10.0.22/tomcat.pid
ExecStart=/software/tomcat/apache-tomcat-10.0.22/bin/catalina.sh start
ExecReload=/software/tomcat/apache-tomcat-10.0.22/bin/catalina.sh restart
ExecStop=/software/tomcat/apache-tomcat-10.0.22/bin/catalina.sh stop
[Install]
WantedBy=multi-user.target
#重载systemctl配置
systemctl daemon-reload
#添加开机自启
systemctl enable tomcat.service
#关闭开机自启
systemctl disable tomcat.service
#启动tomcat服务
systemctl start tomcat.service
#关闭tomcat服务
systemctl stop tomcat.service
#重载tomcat服务
systemctl restart tomcat.service
(10)radis安装
1、下载radis:https://redis.io/download/ >>> Download 7.0.2 >>> redis-7.0.2.tar.gz
2、上传到服务器:/software/radis,并解压到当前目录:tar -zxvf redis-7.0.2.tar.gz
3、安装radis前先安装gcc-c++: yum install gcc-c++
4、cd到redis-7.0.2目录里
5、编译:make
6、安装到/usr/local/redis:make PREFIX=/usr/local/redis install
7、前台启动:cd /usr/local/redis/bin ./redis-server
8、后台启动:
在/software/radis/redis-7.0.2目录下将redis.conf文件拷贝到/usr/local/redis/bin, cp redis.conf /usr/local/redis/bin
修改/usr/local/redis/bin/redis.conf
将 daemonize no 改为 daemonize yes,即开启后台启动
后台启动服务:./redis-server redis.conf
9、客户端连接: ./redis-cli ------ 进入交互模式后如果前导符号里没有ip:port(127.0.0.1:6379)的话,可以断开ssh重新连接
10、服务配置:vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
ExecStop=/usr/local/redis/bin/redis-cli shutdown
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#重载systemctl配置
systemctl daemon-reload
#启动redis服务
systemctl start redis.service
#添加开机自启
systemctl enable redis.service
11、配置文件:对于远程访问,设置密码等都可以在配置文件里配置,配置完成后重新启动服务
(11)卸载nginx
1、使用yum卸载:yum remove nginx
使用rpm卸载:rpm -e nginx
2、删除残余文件:
先按文件名称寻找到名为nginx的文件或目录 find / -name nginx 删除寻找到的文件或目录 rm -rf 文件或目录
在使用*通配符查找文件确保完全删除删除 find / -name nginx*
(12)使用yum线上安装nginx
1、yum install nginx
2、安装完成后nginx会自动添加到服务
3、使用systemctl start nginx启动服务
4、使用systemctl enable nginx 添加到开机自启动
5、使用systemctl is-enabled nginx 查看是否开机自启动功能生效了
(13)使用rpm本地安装nginx
0、之前装1.22.0(nginx-1.22.0-1.el7.ngx.x86_64.rpm)版本没有安装上,报错如下(后面具体再看下原因)
error: Failed dependencies:
libpcre2-8.so.0()(64bit) is needed by nginx-1:1.22.0-1.el7.ngx.x86_64
后来成功安装1.20.2版本,步骤如下:
1、在nginx官网下载所需要的的rpm包,地址为:http://nginx.org/packages/,
centos7所需的rpm包下载地址:http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.24.0-1.el7.ngx.x86_64.rpm
2、下载后上传至服务器/software/nginx目录下
3、在/software/nginx目录下安装rpm包:rpm -ivh nginx-1.20.2-1.el7.ngx.x86_64.rpm
4、安装时可能会报错:(参考地址:https://blog.csdn.net/X_yufei/article/details/131480737)
error: Failed dependencies:
libpcre2-8.so.0()(64bit) is needed by nginx-1:1.24.0-1.el7.ngx.x86_64
下载对应依赖,下载地址:http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm
安装依赖:rpm -ivh pcre2-10.23-2.el7.x86_64.rpm
5、使用systemctl start nginx 启动服务
使用ps -ef | grep nginx 命令查看nginx是否启动,会看到有一个nginx主进程和若干子进程
6、使用systemctl enable nginx设置为开机自启动
7、使用systemctl is-enabled nginx 查看是否开机自启动功能生效了
8、实时查看日志:tail -f /var/log/nginx/access.log tail -f /var/log/nginx/error.log
(14)安装nvm(在线安装)
1、执行命令:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
2、使环境变量生效:source ~/.bashrc ------ 执行家目录(~)下的.bashrc文件
3、查看是否安装成功:nvm --version
4、经测试发现本机安装node18及以上版本会出现依赖过低的提示,在不升级依赖的前提下,需使用18以下版本
(15)在线安装python3,这样安装版本比较旧
sudo yum update
sudo yum install python3
python3 --version
sudo yum install python3-pip
pip3 --version
(16)离线安装python3:https://blog.csdn.net/Happy_Sunshine_Boy/article/details/123180678
1. 在外网服务器上,下载依赖包,保存在 当前路径的 python3.12.2 目录下
yum install --downloadonly --downloaddir=./python3.12.2 zlib-devel bzip2-devel openssl-devel ncurses-devel epel-release gcc gcc-c++ xz-devel readline-devel gdbm-devel sqlite-devel tk-devel db4-devel libpcap-devel libffi-devel
2. 把从外网下载的依赖包,拷贝到内网,进行安装
rpm -Uvh ./*.rpm --nodeps --force ------ -U:表示更新包 -v: 提供更详细的输出 -h:在安装包时打印散列标记(可以使用-v) --nodeps:不验证包依赖 --force:忽略包之间的文件冲突
3. 下载python后上传到内网服务器,也可以去官网下载
wget --no-check-certificate https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgz
4. 安装
# 解压到指定目录
tar -zxvf Python-3.12.2.tgz -C /opt/
cd /opt/Python-3.12.2
# 将Python3安装到此目录下
./configure --prefix=/usr/local/bin/python3
# 编译和安装
make && make install
5. 创建软连接
# 创建python3软连接
ln -s /usr/local/bin/python3/bin/python3 /usr/bin/python3
# 创建pip3的软连接
ln -s /usr/local/bin/python3/bin/pip3 /usr/bin/pip3
6. 检查
python3 --version
pip3 --version
python --version
pip --version
7. 离线安装第三方模块
# 在有网服务器上下载(以paramiko2.4.2为例)
pip3 download paramiko==2.4.2 -d /tmp/packages/
# 在无网服务器上安装(以paramiko2.4.2为例)
pip3 install --no-index --find-links=/tmp/packages paramiko==2.4.2
8. 下载模块
# 如果新安装某一个模块,可以直接下载下来,并且依赖包也会下载下来
pip3 download -d /tmp/packages/ xxx
# 或者
pip3 download xxx -d /tmp/packages/
# 默认情况download是最新版本模块,但有时候我们需要下载指定模块版本,比如下面我们下载paramiko的2.4.2版本。
pip3 download -d /tmp/packages/ paramiko==2.4.2
# 或者
pip3 download paramiko==2.4.2 -d /tmp/packages/
# 或者 将pip3 list的信息生成文档
pip3 freeze >requirements.txt
# 将requirement.txt文档中列出的模块信息下载到指定目录
pip3 download -r requirements.txt -d /tmp/packages/ #推荐使用
# 或者
pip3 install --download /tmp/packages -r requirements.txt
9. 离线安装模块
# 批量离线安装requirments.txt中的模块,需要将下载好的模块和requirments.txt都copy到一个目录,然后执行下面的命令
pip3 install --no-index --find-links=/tmp/packages xxx
# 例如:
pip3 install --no-index --find-links=/tmp/packages paramiko==2.4.2
# 或者
pip3 install --no-index --find-links=/tmp/packages -r requirments.txt
https://pkgs.org 可以搜索各种rpm包
lsb_release -a
https://blog.csdn.net/sinat_35861727/article/details/123508145 yum 安装 nodejs
netstat -antup
netstat -antup | grep 4873
curl 用法
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html
https://blog.csdn.net/zcs2312852665/article/details/134931379
curl [options...] url
curl -X POST -H "Content-Type:application/json" -d '{"queryValue":"","queryType":"1","order":"desc","topNum":20,"statype":"011,11,012,12,013,13","qcodee":"2024-10-16 13:00:00","element":"PRE_1h"}' http://10.1.64.154/art/api/topApi/TopByTime
//测试不行
curl -H 'Content-Type:application/json' http://10.1.64.154/art/api/verObsApi/queryUparWprStationIdsByTimeRainge?startTime=20241016040400&endTime=20241016060400
wget
学习使用ssh命令
解压zip,如果系统unzip命令可用yum安装
sudo yum install unzip
unzip xxx.zip 将xxx.zip解压到当前目录