20220409

1. 755-》对应什么权限 rwxr-xr-x
   600-》对象什么权限 rw-------
   644-》对应什么权限 rw-r--r--
   1666-> 对应什么权限 sticky Bit rw-rw-rw-
   7777-> 对应什么权限 SUID SGID rwxrwxrwx
   6000-> 对应什么权限 SUID SGID---------
2.
 1).创建文件,并赋予权限611(两种方式,一种guoa,一种nnn)

[root@RHCSA ~]# ls -l file
-rw-r--r--. 1 root root 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod g=x,o=x file
[root@RHCSA ~]# ls -l file
-rw---x--x. 1 root root 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod 611 file
[root@RHCSA ~]# ls -l file
-rw---x--x. 1 root root 0 Mar 25 23:05 file


 2).创建目录,并赋予权限755(两种方式,一种guoa,一种nnn)

[root@RHCSA ~]# mkdir task
[root@RHCSA ~]# chmod u=rwx,g=rx,o=rx task
[root@RHCSA ~]# ls -dl task
drwxr-xr-x. 2 root root 6 Apr  9 09:13 task


 3).创建文件,并将文件的属主和属组修改其他用户

[root@RHCSA ~]# ls -dl task
drwxr-xr-x. 2 root root 6 Apr  9 09:13 task
[root@RHCSA ~]# chown rhcsa:rhcsa file
[root@RHCSA ~]# ls -l file
-rw---x--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file


 4).设置suid,为文件设置suid(两种方式 u+s和nnnn)的方式

[root@RHCSA ~]# ls -l file
-rw---x--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod u+s file
[root@RHCSA ~]# ls -l file
-rwS--x--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file
[root@RHCSA ~]# ls -l file
-rw---x--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod 4611 file
[root@RHCSA ~]# ls -l  file
-rwS--x--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file


 5).设置sgid, 为文件设置sgid(两种方式 g+s和nnnn)的方式

[root@RHCSA ~]# chmod g+s file
[root@RHCSA ~]# ls -l file
-rwS--s--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod 2611 file
[root@RHCSA ~]# ls -l file
-rw---s--x. 1 rhcsa rhcsa 0 Mar 25 23:05 file


 6).设置sbit,为目录设置sbit(两种方式 o+t和nnnn)的方式

[root@RHCSA ~]# chmod o+t file
[root@RHCSA ~]# ls -l file
-rw---s--t. 1 rhcsa rhcsa 0 Mar 25 23:05 file
[root@RHCSA ~]# chmod 1611 file
[root@RHCSA ~]# ls -l file
-rw---x--t. 1 rhcsa rhcsa 0 Mar 25 23:05 file


 7).创建文件,查询文件的acl

[root@RHCSA ~]# touch task1          
[root@RHCSA ~]# getfacl task1
# file: task1
# owner: root
# group: root
user::rw-
group::r--
other::r--


 为文件设置acl 用户为testuser1 权限为 rwx

[root@RHCSA ~]# setfacl -m u:testuser1:rwx task1
[root@RHCSA ~]# getfacl test1
# file: task1
# owner: root
# group: root
user::rwx
user:testuser1:rwx
group::r--
mask::rwx
other::r--


 为文件设置acl的mask: 权限为r-x

[root@RHCSA ~]# setfacl -m m:r-x task1
[root@RHCSA ~]# getfacl task1
# file: task1
# owner: root
# group: root
user::rw-
user:testuser1:rwx		#effective:r-x
group::r--
mask::r-x
other::r--


3.
 1).查询ip的几种方式: ip, ifconfig, nmcli,nmtui

[root@RHCSA ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens160:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b6:fb:36 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.131/24 brd 192.168.100.255 scope global dynamic noprefixroute ens160
       valid_lft 1190sec preferred_lft 1190sec
    inet6 fe80::de24:7e85:2c8:16b3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:f4:89:4f brd ff:ff:ff:ff:ff:ff
4: virbr0-nic:  mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:f4:89:4f brd ff:ff:ff:ff:ff:ff
[root@RHCSA ~]# ifconfig
ens160: flags=4163  mtu 1500
        inet 192.168.100.131  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::de24:7e85:2c8:16b3  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b6:fb:36  txqueuelen 1000  (Ethernet)
        RX packets 16008  bytes 17394837 (16.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4338  bytes 329928 (322.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 240  bytes 19816 (19.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 240  bytes 19816 (19.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@RHCSA ~]# nmcli
ens160: connected to ens160
        "VMware VMXNET3"
        ethernet (vmxnet3), 00:0C:29:B6:FB:36, hw, mtu 1500
        ip4 default
        inet4 192.168.100.131/24
        route4 0.0.0.0/0
        route4 192.168.100.0/24
        inet6 fe80::de24:7e85:2c8:16b3/64
        route6 fe80::/64
        route6 ff00::/8

virbr0: unmanaged
        "virbr0"
        bridge, 52:54:00:F4:89:4F, sw, mtu 1500

lo: unmanaged
lines 1-16...skipping...
ens160: connected to ens160
        "VMware VMXNET3"
        ethernet (vmxnet3), 00:0C:29:B6:FB:36, hw, mtu 1500
        ip4 default
        inet4 192.168.100.131/24
        route4 0.0.0.0/0
        route4 192.168.100.0/24
        inet6 fe80::de24:7e85:2c8:16b3/64
        route6 fe80::/64
        route6 ff00::/8

virbr0: unmanaged
        "virbr0"
        bridge, 52:54:00:F4:89:4F, sw, mtu 1500

lo: unmanaged
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

virbr0-nic: unmanaged
        "virbr0-nic"
        tun, 52:54:00:F4:89:4F, sw, mtu 1500

DNS configuration:
        servers: 192.168.100.2
        domains: localdomain
        interface: ens160

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.

20220409_第1张图片
 2).nmcli命令使用:
 a.在ens160网卡上新建连接static_con,并配置静态ip

[root@RHCSA ~]# nmcli c add type ethernet con-name static_con ifname ens160 ipv4.address 192.168.100.132/24 ipv4.gateway 192.168.100.2 ipv4.dns 8.8.8.8 ipv4.method manual autoconnect yes 
Connection 'static_con' (59da42a2-b366-4c6e-8393-7309ba246a33) successfully added.

 b.在ens160网卡上新建连接auto_con, 配置动态ip

[root@RHCSA ~]# nmcli connection add type ethernet con-name auto_con ifname ens160 ipv4.method auto
Connection 'auto_con' (dfdebefa-cd44-479a-93f4-791d6c7e676e) successfully added.
[root@RHCSA ~]# nmcli c
NAME        UUID                                  TYPE      DEVICE 
ens160      3c9b69d3-a3d6-4f87-b64e-81470e7fd9a2  ethernet  ens160 
auto_con    dfdebefa-cd44-479a-93f4-791d6c7e676e  ethernet  --     
static_con  59da42a2-b366-4c6e-8393-7309ba246a33  ethernet  --     

 c.修改static_con的ip的方式: nmtui,nmcli c modify, nmcli c edit, 修改配置文件

20220409_第2张图片

[root@RHCSA ~]# nmcli c modify static_con ipv4.addr '192.168.100.133/24'
[root@RHCSA ~]# nmcli c show static_con
ipv4.addresses:                         192.168.100.133/24
[root@RHCSA ~]# nmcli c edit static_con 

===| nmcli interactive connection editor |===

Editing existing '802-3-ethernet' connection: 'static_con'

Type 'help' or '?' for available commands.
Type 'print' to show all the connection properties.
Type 'describe [.]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, tc, proxy
nmcli> goto ipv4.addresses 
nmcli ipv4.addresses> change 
Edit 'addresses' value: 192.168.100.134/24


 d.激活static_con的方式: up, reapply, reload, load

[root@RHCSA ~]# nmcli c up static_con 
[root@RHCSA ~]# nmcli d reapply static_con
[root@RHCSA ~]# nmcli d connect static_con


 e.删除auto_con

[root@RHCSA ~]# nmcli c delete auto_con 
Connection 'auto_con' (dfdebefa-cd44-479a-93f4-791d6c7e676e) successfully deleted.

 f.添加一个网卡,并查看设备状态

[root@RHCSA ~]# nmcli c add type ethernet con-name 111 ifname ens161
Connection '111' (4b9cf11d-a760-4c66-8d49-ae06f7633d06) successfully added.
[root@RHCSA ~]# nmcli c
NAME        UUID                                  TYPE      DEVICE 
static_con  59da42a2-b366-4c6e-8393-7309ba246a33  ethernet  ens160 
111         4b9cf11d-a760-4c66-8d49-ae06f7633d06  ethernet  --     
ens160      3c9b69d3-a3d6-4f87-b64e-81470e7fd9a2  ethernet  --     


 h:如果是connected,断开连接

[root@RHCSA ~]# nmcli c down ens160

 i:将断开的网卡状态设为connected

[root@RHCSA ~]# nmcli c up ens160


4.停止ens160连接(记得在Vmware上操作,因为停止ens160后,远程连接断掉)
 删除ens160连接

[root@RHCSA ~]# nmcli c delete ens160
Connection 'ens160' (3c9b69d3-a3d6-4f87-b64e-81470e7fd9a2) successfully deleted.


 查看所有连接
 查看所有设备

[root@RHCSA ~]# nmcli c
NAME        UUID                                  TYPE      DEVICE 
static_con  59da42a2-b366-4c6e-8393-7309ba246a33  ethernet  ens160 
111         4b9cf11d-a760-4c66-8d49-ae06f7633d06  ethernet  --     
[root@RHCSA ~]# nmcli d
DEVICE      TYPE      STATE      CONNECTION 
ens160      ethernet  connected  static_con 
virbr0      bridge    unmanaged  --         
lo          loopback  unmanaged  --         
virbr0-nic  tun       unmanaged  --         

 创建静态IP连接

[root@RHCSA ~]#  nmcli c add type ethernet con-name ens224 ifname ens224 ipv4.addr  192.168.100.13/24 ipv4.gateway 192.168.100.2 ipv4.method manual
Connection 'ens224' (014bf57b-5af9-43ad-bfc1-4263f6a8b6b4) successfully added.

 启动连接

[root@RHCSA ~]# nmcli c up ens224


 使连接生效的三种方式

[root@RHCSA ~]# nmcli c up ens224 
[root@RHCSA ~]# nmcli d connect ens224 
[root@RHCSA ~]# nmcli d reapply ens224 


 查看创建连接所产生的配置文件
 修改IP,在原先ip的基础上+10=》 比如:原IP为:192.168.233.128 =》 192.168.233.138

[root@RHCSA ~]# nmcli c modify ens224 ipv4.addr '192.168.100.23/24'

你可能感兴趣的:(linux)