您的位置:首页 > 文旅 > 美景 > 东莞读音_杭州知名设计公司_上海自动seo_百度打开

东莞读音_杭州知名设计公司_上海自动seo_百度打开

2025/4/21 22:10:14 来源:https://blog.csdn.net/weixin_73863213/article/details/144571781  浏览:    关键词:东莞读音_杭州知名设计公司_上海自动seo_百度打开
东莞读音_杭州知名设计公司_上海自动seo_百度打开

一.设置主机名称

1.文件的方式

[root@localhost 桌面]# vim /etc/hostname
[root@localhost 桌面]# cat /etc/hostname
shell.aaa.org

修改完毕文件后在当前的shell中是不生效的 如果需要看到效果,关闭当前shell后重新开启新的shell

2.通过命令更改主机名

[root@localhost 桌面]# hostnamectl hostname shell.aaa.org

即改即生效,无需重新启动shell

二.网络管理命令nmcli

1.查看网卡

[root@shell ~]# ip a s ens160
[root@shell ~]# ifconfig ens160
[root@shell ~]# nmcli device show ens160
[root@shell ~]# nmcli device status
[root@shell ~]# nmcli connection show ens160

2.设置网卡

a)当网卡未被设置过时

设置dncp网络工作模式

[root@shell ~]# ip a s ens160
[root@shell ~]# ifconfig ens160
[root@shell ~]# nmcli device show ens160
[root@shell ~]# nmcli device status
[root@shell ~]# nmcli connection show ens160

设置静态网络工作模式

[root@shell ~]# nmcli connection add con-name ens160 \
type ethernet ifname eth160 ipv4.method manual \
ipv4.addresses 172.25.254.100/24 \
ipv4.gateway 172.25.254.2

b)当网卡被设定,当前需要修改

[root@shell ~]# nmcli connection modify ens160 ipv4.addresses 172.25.254.200/24
[root@shell ~]# nmcli connection reload
[root@shell ~]# nmcli connection up ens160

当网卡未被设定时,对网卡的设定即改即生效 当网卡被设定过,我们通过命令更改后必须要刷新网卡才能生效

三.打印字符

1.打印连续数字

连续打印3个数字

[root@shell ~]# seq 1 5
1
2
3
4
5

指定打印格式

[root@shell ~]# seq -f "%03g" 1 3
001
002
003

设定打印步长

[root@shell ~]# seq 1 2 10
1
3
5
7
9

2.反向打印文件内容

[root@shell ~]# seq 1 9 > aaa
[root@shell ~]# tac aaa
9
8
7
6
5
4
3
2
1

3.打印字符

a)printf 打印字符

[root@shell ~]# printf "hello wan"
hello wan[root@shell ~]# 

打印字符指定格式(换行)

[root@shell ~]# printf “hello wan\n"
hello wan
[root@shell ~]# printf "hello\twan\n"
hello   wan

打印百分号

[root@shell ~]# printf "hello wan\n4%%\n"
hello wan
4%

打印整数,浮点数

[root@shell ~]# printf "%.0f" "3.1415926"
3
[root@shell ~]# printf "%0.1f" "0.12345"
0.1
[root@shell ~]# printf "%0.3f" "0.12345"
0.123

b)echo 打印字符

[root@shell ~]# echo "hello world"
hello world

不换行打印

[root@shell ~]# echo -n "hello world"
hello world[root@shell ~]#

解析转义字符

[root@shell ~]# echo -e "hello\tworld"
[root@shell ~]# echo -ne "\033[32mhello world\033[0m" //变换颜色

四.lscpu

lscpu命令是用于显示和收集有关CPU(中央处理器)架构和相关信息的命令。它提供了关于CPU的详细 信息,包括处理器类型、架构、核心数、线程数、缓存大小等。

// [root@shell ~]# cat /proc/cpuinfo | less[root@shell ~]# lscpu
架构:                   x86_64CPU 运行模式:         32-bit, 64-bitAddress sizes:         45 bits physical, 48 bits virtual字节序:               Little Endian
CPU:                     2在线 CPU 列表:        0,1
厂商 ID:                AuthenticAMDBIOS Vendor ID:        AuthenticAMD型号名称:             AMD Ryzen 7 5800U with Radeon GraphicsBIOS Model name:     AMD Ryzen 7 5800U with Radeon GraphicsCPU 系列:           25型号:               80每个核的线程数:     1每个座的核数:       1座:                 2步进:               0BogoMIPS:           3792.87标记:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext ssbd ibrs ibpb vmmcall fsgsbase bmi1avx2 smep bmi2 erms invpcid rdseed adx smap clflushoptclwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero wbnoinvd arat umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor fsrm
Virtualization features: 超管理器厂商:         VMware虚拟化类型:           完全
Caches (sum of all):     L1d:                   64 KiB (2 instances)L1i:                   64 KiB (2 instances)L2:                    1 MiB (2 instances)L3:                    32 MiB (2 instances)
NUMA:                    NUMA 节点:            1NUMA 节点0 CPU:       0,1
Vulnerabilities:         
​

五.wget

作用是从指定的URL下载文件。wget命令非常稳定,一般即便网络波动也不会导致下载失败,而是不断 尝试重连,直到整个文件下载完毕。wget命令支持如HTTP、HTTPS、FTP等常见协议,可以在命令行中 直接下载网络文件。

1.查看wget版本

[root@shell ~]# wget -V

2.下载文件

[root@shell ~]# wget 
https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm
[root@shell ~]# wget 
https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm 
-O /mnt/qq.rpm
[root@shell ~]# wget http://www.baidu.com -o hello.html
[root@shell ~]# ls
11    模板  图片  下载  桌面  anaconda-ks.cfg  passwd
公共  视频  文档  音乐  aaa   hello.html

3.限速下载

[root@shell ~]# wget 
https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm -O  /mnt/qq.rpm  --limit-rate 1k

4.断点续传

[root@shell ~]# wgethttps://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm   -O  /mnt/qq.rpm  --limit-rate 1k -c

5.后台下载

[root@shell ~]# wget 
https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm -O /mnt/qq.rpm --limit-rate 1k  -b[root@shell ~]# tail -f wget-log

6.下载整个站点

[root@shell ~]# wget -r -O /mnt/baidu http://www.baidu.com

7.检测站点是否存活

[root@shell ~]# wget -q -T 3 -t 2 --spider http://www.baidu.com
//-q :表示 “quiet”,即安静模式,执行 wget 操作时不会输出详细的下载进度等信息,只输出必要的提示。
-T 3 :-T 是 --timeout 的缩写,这里设置超时时间为 3 秒,意味着如果在 3 秒内 wget 操作没有完成(比如无法建立连接、下载超时长等情况),就会终止当前尝试。
-t 2 :-t 是 --tries 的缩写,指定尝试连接的次数为 2 次。如果第一次尝试失败,会进行第二次尝试,但最多尝试 2 次就停止后续尝试了。[root@shell ~]# echo $?
0
//返回状态码 0 通常表示上一条命令执行成功,没有出现错误情况。
  • -V: 查看wget的版本

  • -O|--output-document=FILE 将下载的内容写入到文件中

  • -c,--continue 支持断点续传

  • -b 后台下载

  • --limit-rate=RATE 限制下载速度

  • -q: 静默下载,即无信息输出

  • -T,--timeout=SECONDS: 下载的超时时间

  • -t,--tries=NUMBER: 设置重试次数(0 代表无限制)

  • --spider: 不下载任何文件

六.watch

linux命令watch是周期性的用来执行某命令,并把某命令执行结果输出到屏幕上。使用watch命令,可以 周期性的监测并输出某命令的执行结果到屏幕上,省得手动一遍一遍运行某命令,提高工作效率。

1.设置被监控的命令执行间隔

[root@shell ~]# watch -n2 ls /mnt

2.高亮显示变化区域

[root@shell ~]# watch -d ls /mnt

3.屏蔽顶部时间信息

[root@shell ~]# watch -t ls /mnt
  • -n 指定时间间隔

  • -d 高亮显示变化区域

  • -t 屏蔽顶部时间

  • 如果要停止watch 按键 +

七.xargs

xargs 命令作用是将标准输入数据转换成命令行参数,能够处理管道或者标准输入并将其转换成特定命令 的命令参数

1.xargs作用命令

[root@shell ~]# echo /mnt/lee{1..3} | touch
touch: missing file operand
Try 'touch --help' for more information.
[root@shell ~]# echo /mnt/lee{1..3} | xargs touch
[root@shell ~]# seq 1 5 | xargs touch
[root@shell ~]# ls
1  2  3  4  5

2.多行输入单行输出

[root@shell ~]]# vim aaa
a a a a a a
b b b b b b
c c c c c c
d d d d d d
e e e e e e
f f f f f f
[root@shell ~]# xargs < aaa
a a a a a a b b b b b b c c c c c c d d d d d d e e e e e e f f f f f f

3.指定每行输出个数

[root@shell ~]# xargs -n 10 < aaa
a a a a a a b b b b
b b c c c c c c d d
d d d d e e e e e e
f f f f f f

4.指定分隔符

[root@shell ~]# echo "lee:lee:lee" | xargs
lee:lee:lee
[root@shell ~]# echo "lee:lee:lee" | xargs -d:
lee lee lee
[root@localhost ~]# xargs -n 10 -d c < aaa
a a a a a a
b b b b b bd d d d d d
e e e e e e
f f f f f f

5.用字符代替接收值

[root@shell ~]# ls * | xargs -Ifile mv file file.bak
[root@shell ~]# ls
file1.bak  file2.bak  file3.bak  file4.bak
  • -I:用于指定替换字符串,将输入数据中的特定字符串替换为命令行参数

  • -n:用于指定每次执行命令的参数个数

  • -t:用于打印执行的命令

  • -p:用于提示用户确认是否执行命令

  • -r:当标准输入为空时,不执行命令

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com