用户的权限中的基本权限UGO

UGO概述:

像QQ黄钻、红钻、绿钻等特权,一刀9999
腾讯、爱奇艺、优酷会员都属于特权。
而文件特权设置真实样子就是赋于某个用户或组 能够以何种方式 访问某个文件(图片文件,视频文件,普通文件)。

权限对象:

u:代表属主
g:代表属组
o:代表其他人
a:代表全部(ugo)
敲黑板:注意不要混淆属主和属组

权限类型:

读:r=4
写:w=2
执行:x=1

设置权限

1、更改权限

使用符号:

了解普通文件的基本权限:
[root@localhost ~]# cd /tmp
[root@localhost ~]# touch file1
[root@localhost tmp]# ll file1
-rw-r–r--. 1 root root 0 4月 13 20:49 file1
-rw-r–r--.:代表了权限
root:属主 (第一个root)
root: 属组 (第二个root)
0 4月 13 20:49 :创建文件的时间
file1:文件名
编写程序
[root@localhost tmp]#vim file1
echo “hello 1803”
read -p “请输入您的姓名:” name
echo “哈哈 $name 是天底下最可爱的人”
敲黑板:注意用vim 编辑文本需要进入后按“i键”进行编辑,编辑完成之后按“ESC”退出后Shift+:+wq保存并回车。
增加执行权限:
[root@localhost tmp]# chmod u+x file1 (给属主增加执行权)
运行测试:
[root@localhost tmp]# ./file1
hello 1803
请输入您的姓名:xujingyuan
xujingyuan 是天底下最可爱的人
去除权限:
[root@localhost tmp]# chmod u-x file1
[root@localhost tmp]# ./file1
-bash: ./file1: 权限不够 (权限不够要退出到/下)
[root@localhost ~]#cd
[root@localhost ~]#chmod u-x file1
[root@localhost ~]#
(成功)
敲黑板:注意自己所处的位置,对文件权限进行更改要看其父系是否拥有这个权利才可以。
拓展:
a=rwx (所有人都拥有读写执行的权限)
“=”他的意思是 u,g,o=多少就是多少权限 =空白就是没有权限
u+w(属主增加写的权限),u-w(属主减去写的权限)

使用数字

4读 2写 1执行
[root@localhost ~]# chmod 644 file1
[root@localhost ~]# ll file1
-rw-r–r-- 1 alice it 17 10-25 16:45 file1
敲黑板:-rw-r–r--怎么看谁是属主谁是其他人
去掉开头的-如果结尾有.也去掉,然后按三个一份划分如下;
rw-:代表属主
r–:代表属组
r–:代表其他人

发布了3 篇原创文章 · 获赞 19 · 访问量 2113

猜你喜欢

转载自blog.csdn.net/Cuiyanbing1/article/details/104525416
今日推荐