將SELNUX=enforcing改成SELNUX=disabledhtml
root@centos7 ~]# nano /etc/selinux/config 配置文件,將SELNUX=enforcing改成SELNUX=disabled linux
[root@centos7 ~]# getenforce (#Enforcing:強制模式。表明SELinux在運行中,且已經開始限制domain/type之間的驗證關係) Enforcing [root@centos7 ~]# cat /etc/selinux/config (#查看配置文件) # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@centos7 ~]# nano /etc/selinux/config(#nano編輯配置文件) -bash: nano: command not found [root@centos7 ~]# yum -y install nano(#安裝nano) Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 updates/7/x86_64/primary_db | 4.7 MB 00:00:01 Resolving Dependencies --> Running transaction check ---> Package nano.x86_64 0:2.3.1-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: nano x86_64 2.3.1-10.el7 base 440 k Transaction Summary ============================================================================================================================== Install 1 Package Total download size: 440 k Installed size: 1.6 M Downloading packages: nano-2.3.1-10.el7.x86_64.rpm | 440 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : nano-2.3.1-10.el7.x86_64 1/1 Verifying : nano-2.3.1-10.el7.x86_64 1/1 Installed: nano.x86_64 0:2.3.1-10.el7 Complete! [root@centos7 ~]# nano /etc/selinux/config(#nano編輯配置文件)
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled(#此處模式已變)
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@centos7 ~]# ll anaconda-ks.cfg -rw-------. 1 root root 1259 Dec 3 20:30 anaconda-ks.cfg [root@centos7 ~]# ll -Z anaconda-ks.cfg -rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targetedcentos
----------------------------------------------------bash
關閉防火牆:dom
[root@centos7 ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@centos8 ~]# systemctl disable firewalld
[root@centos8 ~]#
更改文件的全部人和屬組 ide
1 [root@centos8 ~]# touch f1.txt(#建立文件) 2 [root@centos8 ~]# ll(#看看列表) 3 total 4 4 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Desktop 5 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Documents 6 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Downloads 7 -rw-r--r-- 1 root root 0 Jan 17 00:06 f1.txt (#建立成功) 8 -rw-r--r--. 1 root root 1778 Jan 11 17:12 initial-setup-ks.cfg 9 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Music 10 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Pictures 11 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Public 12 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Templates 13 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Videos 14 [root@centos8 ~]# chown kevin f1.txt(#改變全部者屬性) 15 [root@centos8 ~]# ll 16 total 4 17 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Desktop 18 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Documents 19 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Downloads 20 -rw-r--r-- 1 kevin root 0 Jan 17 00:06 f1.txt 21 -rw-r--r--. 1 root root 1778 Jan 11 17:12 initial-setup-ks.cfg 22 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Music 23 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Pictures 24 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Public 25 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Templates 26 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Videos 27 [root@centos8 ~]# chown :kevin f1.txt(#改變屬組屬性) 28 [root@centos8 ~]# ll 29 total 4 30 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Desktop 31 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Documents 32 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Downloads 33 -rw-r--r-- 1 kevin kevin 0 Jan 17 00:06 f1.txt 34 -rw-r--r--. 1 root root 1778 Jan 11 17:12 initial-setup-ks.cfg 35 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Music 36 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Pictures 37 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Public 38 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Templates 39 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Videos
最後檢查一下結果:post
[root@centos8 ~]# ll f1.txt
-rw-r--r-- 1 kevin kevin 0 Jan 17 00:06 f1.txt
[root@centos8 ~]# centos7
也能夠這樣改:spa
1 [root@centos8 ~]# ll f1.txt 2 -rw-r--r-- 1 kevin kevin 0 Jan 17 00:06 f1.txt 3 [root@centos8 ~]# chown root.bin f1.txt 4 [root@centos8 ~]# ll f1.txt 5 -rw-r--r-- 1 root bin 0 Jan 17 00:06 f1.txt 6 [root@centos8 ~]#
範例:3d
#chown --reference=f1.txt f2.txt(#像建立f1那樣建立f2)
1 [root@centos8 ~]# cp /etc/issue f2.txt(#建立f2) 2 [root@centos8 ~]# ll(#列出詳細,看到f2,txt已成功建立) 3 total 8 4 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Desktop 5 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Documents 6 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Downloads 7 -rw-r--r-- 1 root bin 0 Jan 17 00:06 f1.txt 8 -rw-r--r-- 1 root root 23 Jan 17 00:31 f2.txt 9 -rw-r--r--. 1 root root 1778 Jan 11 17:12 initial-setup-ks.cfg 10 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Music 11 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Pictures 12 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Public 13 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Templates 14 drwxr-xr-x. 2 root root 6 Jan 13 23:27 Videos
[root@centos8 ~]# chown --re --recursive --reference [root@centos8 ~]# chown --reference=f1.txt f2.txt(#像建立f1那樣建立f2)
[root@centos8 ~]# ll total 8
drwxr-xr-x. 2 root root 6 Jan 13 23:27 Desktop drwxr-xr-x. 2 root root 6 Jan 13 23:27 Documents drwxr-xr-x. 2 root root 6 Jan 13 23:27 Downloads -rw-r--r-- 1 root bin 0 Jan 17 00:06 f1.txt -rw-r--r-- 1 root bin 23 Jan 17 00:31 f2.txt -rw-r--r--. 1 root root 1778 Jan 11 17:12 initial-setup-ks.cfg drwxr-xr-x. 2 root root 6 Jan 13 23:27 Music drwxr-xr-x. 2 root root 6 Jan 13 23:27 Pictures drwxr-xr-x. 2 root root 6 Jan 13 23:27 Public drwxr-xr-x. 2 root root 6 Jan 13 23:27 Templates drwxr-xr-x. 2 root root 6 Jan 13 23:27 Videos
[root@centos8 ~]# chgrp root f1.txt (#只改變屬組,不改全部人)
[root@centos8 ~]# ll f1.txt#查看一下) -rw-r--r-- 1 root root 0 Jan 17 00:06 f1.txt [root@centos8 ~]#