SHELL脚本中的常用命令

一、设置主机名称

1、文件的方式

二、网络管理命令

查看网卡

[root@test ~]# nmcli connection show 
NAME        UUID                                  TYPE      DEVICE 
ethe        941638f6-4943-4bc5-878d-a5e0aa44aa93  ethernet  eth0   
eth1        f492df40-4db6-404e-a014-6c5a2763bb9b  ethernet  eth1   
lo          5dc67977-a6d3-4b73-bb1c-6fc2890046e4  loopback  lo     
有线连接 1  a7cdeab8-d42a-4ca1-903d-2564e3a578e3  ethernet  --     
ens160      768fd22e-8832-35c9-973f-e0f080078552  ethernet  --     

[root@test ~]# nmcli device show eth1
GENERAL.DEVICE:                         eth1
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:8C:4F:E7
GENERAL.MTU:                            1500
GENERAL.STATE:                          100(已连接)
GENERAL.CONNECTION:                     eth1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveC>
WIRED-PROPERTIES.CARRIER:               开

[root@test ~]# nmcli device status 
DEVICE  TYPE      STATE         CONNECTION 
eth0    ethernet  已连接        ethe       
eth1    ethernet  已连接        eth1       
lo      loopback  连接(外部)  lo    

[root@test ~]# ip a s eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:8c:4f:e7 brd ff:ff:ff:ff:ff:ff
    altname enp19s0
    altname ens224
    inet 192.168.0.100/24 brd 192.168.0.255 scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::91de:8c69:8af8:9c40/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

设置网卡

[root@test ~]# nmcli connection add con-name eth1

[root@test ~]# nmcli connection modify eth1 ipv4.addresses 172.25.254.100/24 
[root@test ~]# nmcli connection reload 
[root@test ~]# nmcli connection up eth1
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)

三、打印字符

1、打印连续字符

[root@test ~]# seq 1 3
1
2
3
[root@test ~]# seq -f "%03g" 1 3
001
002
003
[root@test ~]# seq 1 2 10
1
3
5
7
9
[root@test ~]# 

2、反向打印文件内容

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

3、打印字符

root@test ~]# printf "hello world"
hello world[root@test ~]# printf "hello world\d"
hello world\d[root@test ~]# printf "hello\world\n"
hello\world
[root@test ~]# printf "3%%\n"
3%
[root@test ~]# printf "%.1f" "3.141526"
3.1[root@test ~]# printf "%.1f \n" "3.141526"
3.1 
[root@test ~]# echo "hello word"
hello word
[root@test ~]# echo -n  "hello word"
hello word[root@test ~]# 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寒克1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值