做系统的网站,百度推广是什么工作,电脑平面设计软件,国内知名设计网站一、Linux权限的概念
权限我们都熟悉#xff0c;最常见的就是在看电视时需要vip这个就是权限#xff0c;然后在Linux就是有两个权限#xff0c;就是管理员也就是超级用户和普通的用户 命令#xff1a;su [用户名] 功能#xff1a;切换用户。 例如#xff0c;要从root用户…一、Linux权限的概念
权限我们都熟悉最常见的就是在看电视时需要vip这个就是权限然后在Linux就是有两个权限就是管理员也就是超级用户和普通的用户 命令su [用户名] 功能切换用户。 例如要从root用户切换到普通用户user则使用 su user。 要从普通用户user切换到root用户则使用 surootroot可以省略此时系统会提示输入root用户的口令测试如下。 [rootVM-24-9-centos ~]# su ly [lyVM-24-9-centos root]$ su root Password: [rootVM-24-9-centos ~]# su ly [lyVM-24-9-centos root]$ su Password: ^C [lyVM-24-9-centos root]$ su Password: [rootVM-24-9-centos ~]# 二、Linux权限管理
1、文件访问者的分类
文件和文件目录的所有者u---User
文件和文件目录的所有者所在的组的用户g---Group
其它用户o---Others
文件访问者就是这三类。
2、文件类型和访问权限
a、文件类型 d文件夹 -普通文件 l软链接类似Windows的快捷方式 b块设备文件例如硬盘、光驱等 p管道文件 c字符设备文件例如屏幕等串口设备 s套接口文件 b、基本权限 i.读r/4Read对文件而言具有读取文件内容的权限对目录来说具有浏览该目录信息的权限 ii.写w/2Write对文件而言具有修改文件内容的权限对目录来说具有删除移动目录内文件的权限 iii.执行x/1execute对文件而言具有执行文件的权限对目录来说具有进入目录的权限 3、文件权限值的表示方法
如下面两个表格的表示
a、字符表示方法
Linux表示说明 r-- 只读-w-仅可写--x仅可执行rw-可读可写-wx可写和可执行 r-x 可读和可执行rwx可读可写可执行---无权限
b、8进制数值表示方法
权限符号读写执行八进制二进制r4100w2010x1001rw6110rx5101wx3011rwx7111---0000 4、文件访问权限的相关设置方法
使用chmod就可以修改文件的权限功能设置文件的访问权限格式chmod [参数] 权限 文件名常用选项有
chown功能修改文件的拥有者格式chown [参数] 用户名 文件名
chgrp功能修改文件或目录的所属组格式chgrp [参数] 用户组名 文件名常用选项-R 递归修改文件或目录的所属组
umask功能查看或修改文件掩码新建文件夹默认权限0666新建目录默认权限0777但实际上你所创建的文件和目录看到的权限往往不是上面这个值。原因就是创建文件或目录的时候还要受到umask的影响。假设默认权限是mask则实际创建的出来的文件权限是: mask ~umask 格式umask 权限值说明将现有的存取权限减去权限掩码后即可产生建立文件时预设权限。超级用户默认掩码值为0022普通用户默认为0002。 R - 递归修改目录文件的权限 说明只有文件的拥有者和root才可以改变文件的权限 ①chmod命令权限值的格式 :向权限范围增加权限代号所表示的权限 -:向权限范围取消权限代号所表示的权限 :向权限范围赋予权限代号所表示的权限 用户符号 u拥有者 g拥有者同组用 o其它用户 a所有用户 示例如下可以看到加上可执行去掉可执行。 [rootVM-24-9-centos ~]# ll total 132 drwxr-xr-x 5 root root 4096 Mar 24 18:50 d1 -rw-r--r-- 1 root root 179 Mar 24 18:58 d1.tgz -rw-r--r-- 1 root root 436 Mar 24 18:50 dd.zip -rw-r--r-- 1 root root 72 Mar 23 23:09 hello.c -rw-r--r-- 1 root root 29 Mar 24 17:21 t1.txt -rw-r--r-- 1 root root 29 Mar 24 17:32 t2.txt -rw-r--r-- 1 root root 108902 Mar 24 09:01 test.txt [rootVM-24-9-centos ~]# chmod ux test.txt [rootVM-24-9-centos ~]# ll total 132 drwxr-xr-x 5 root root 4096 Mar 24 18:50 d1 -rw-r--r-- 1 root root 179 Mar 24 18:58 d1.tgz -rw-r--r-- 1 root root 436 Mar 24 18:50 dd.zip -rw-r--r-- 1 root root 72 Mar 23 23:09 hello.c -rw-r--r-- 1 root root 29 Mar 24 17:21 t1.txt -rw-r--r-- 1 root root 29 Mar 24 17:32 t2.txt -rwxr--r-- 1 root root 108902 Mar 24 09:01 test.txt [rootVM-24-9-centos ~]# chomd u-x test.txt bash: chomd: command not found [rootVM-24-9-centos ~]# chmod u-x test.txt [rootVM-24-9-centos ~]# ll total 132 drwxr-xr-x 5 root root 4096 Mar 24 18:50 d1 -rw-r--r-- 1 root root 179 Mar 24 18:58 d1.tgz -rw-r--r-- 1 root root 436 Mar 24 18:50 dd.zip -rw-r--r-- 1 root root 72 Mar 23 23:09 hello.c -rw-r--r-- 1 root root 29 Mar 24 17:21 t1.txt -rw-r--r-- 1 root root 29 Mar 24 17:32 t2.txt -rw-r--r-- 1 root root 108902 Mar 24 09:01 test.txt [rootVM-24-9-centos ~]# ②三位8进制数字
示例如下对照上面的表就可以更改权限了。 [rootVM-24-9-centos ~]# chmod 000 test.txt [rootVM-24-9-centos ~]# ll total 132 drwxr-xr-x 5 root root 4096 Mar 24 18:50 d1 -rw-r--r-- 1 root root 179 Mar 24 18:58 d1.tgz -rw-r--r-- 1 root root 436 Mar 24 18:50 dd.zip -rw-r--r-- 1 root root 72 Mar 23 23:09 hello.c -rw-r--r-- 1 root root 29 Mar 24 17:21 t1.txt -rw-r--r-- 1 root root 29 Mar 24 17:32 t2.txt ---------- 1 root root 108902 Mar 24 09:01 test.txt [rootVM-24-9-centos ~]# chmod 644 test.txt [rootVM-24-9-centos ~]# ll total 132 drwxr-xr-x 5 root root 4096 Mar 24 18:50 d1 -rw-r--r-- 1 root root 179 Mar 24 18:58 d1.tgz -rw-r--r-- 1 root root 436 Mar 24 18:50 dd.zip -rw-r--r-- 1 root root 72 Mar 23 23:09 hello.c -rw-r--r-- 1 root root 29 Mar 24 17:21 t1.txt -rw-r--r-- 1 root root 29 Mar 24 17:32 t2.txt -rw-r--r-- 1 root root 108902 Mar 24 09:01 test.txt [rootVM-24-9-centos ~]# 三、思维导图