个人笔记,后续会慢慢补充
1、查看系统版本信息:
[root@root bin]# cat /proc/version
Linux version 5.10.23-5.al8.x86_64 (mockbuild@x86-006.build.alibaba.eu6) (gcc (GCC) 10.2.1 20200825 (Alibaba 10.2.1-3 2.30), GNU ld version 2.35-12.2.al8) #1 SMP Fri Apr 23 16:56:08 CST 2021
[root@root bin]# uname -a
Linux root 5.10.23-5.al8.x86_64 #1 SMP Fri Apr 23 16:56:08 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
2、sodu: Linux sudo命令以系统管理者的身份执行指令,也就是说,经由 sudo 所执行的指令就好像是 root 亲自执行。
3、curl: 在命令行方式下,利用URL进行数据/文件的传输。可测试网络是否可访问,功能很强大
crrl -i URL获取网站文本信息以及协议头部
curl -X POST --header"Conetent-Type:application/json" --data '{}' URL post方式发送json数据
[root@root ~]# curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>
...
</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[root@root ~]# curl -i www.baodu.com
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 05 Jan 2022 08:39:04 GMT
Content-Type: text/html
Content-Length: 16981
Last-Modified: Sun, 10 Jan 2021 10:27:33 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5ffad695-4255"
Accept-Ranges: bytes
<!DOCTYPE html>
<html>
<head>
4、管道命令,查看日志非常方便
cat xxx.log | grep -n "xxx"
5、查看8080端口情况:
netstat -tunlp | grep 8080
netstat -ano|findstr "2181";
[root@root lib]# netstat -tunlp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 2316/java
[root@root lib]# lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 2316 root 57u IPv6 30963 0t0 TCP *:webcache (LISTEN)
查看服务器指定端口:telnet 127.0.0.1 8080
[root@root conf]# telnet 172.23.34.45:8080
telnet: 172.23.34.45:8080: Name or service not known
[root@root conf]# telnet 172.23.34.45 8080
Trying 172.23.34.45...
Connected to 172.23.34.45.
Escape character is '^]'.
^CConnection closed by foreign host.
[root@root conf]# telnet 172.23.34.46 8080
Trying 172.23.34.46...
查看服务器是否可用:ping www.baidu.com
[root@root conf]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=52 time=8.31 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=52 time=8.31 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=52 time=8.32 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=52 time=8.34 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=52 time=8.34 ms
查看进程信息:ps -aux | grep 28990
[root@root conf]# ps -aux|grep 28990
root 158734 0.0 0.0 221460 856 pts/2 R+ 17:47 0:00 grep --color=auto 28990
6、文件查看头几行和结尾几行
head/tail -n 5 logback.xml
[root@root conf]# head -n 5 logback.xml
<!--
~ Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
-->
<!-- The default logback configuration that Play uses if no other configuration is provided -->
<configuration>
[root@root conf]# tail -n 5 logback.xml
<appender-ref ref="ASYNCFILE" />
<appender-ref ref="ASYNCSTDOUT" />
</root>
</configuration>
7 、查找文件或目录
find / -name 'xxxxx*' 在根目录下查找以xxxxx开头的文件或目录
8、文件移动
mv bbb /usr/aaa 当前目录到usr/aaa
mv /bbb /usr/aaa 根目录下的bbb目录移动到/usr目录下并改名为aaa
9、拷贝
cp -r /aaa /bbb 递归拷贝
10、删除
rm -rf /bbb 慎用!!!递归删除
11、文件查看vi/vim..,
less 可空格一页一页看,键盘上下键控制,?查询,q退出
cat 直接看文本