第三章:Linux基础之权限操作

Linux权限管理是Linux中一个十分重要的概念,也是系统安全性的重要保障。这里主要介绍Linux的基本权限和默认权限,通过理论讲解与实验演示,可以详细了解到权限的相关操作及其重要性。

文件权限

[root@localhost ~]# ls -l /etc/passwd
-rw-r–r–. 1 root root 2133 Apr 16 11:33 /etc/passwd
[root@localhost ~]#

文件的权限:所有者,所属组,其他人
rwx,读、写、执行,没有权限就是“-”
第一个组rwx:文件所有者的权限
第二个组rwx:文件所属组的权限
第三个组rwx:文件其他人的权限

目录的权限linux权限管理
r:具有读取目录结构列表的权限,可以查看目录下有哪些文件
w:该权限对于目录来说是很大的,
1、可以在该目录下新建新的文件和目录
2、可以删除已经存在的文件和目录
3、将已经存在的文件和目录重命名
4、移动目录内的文件和目录的位置
x:是否可以进入该目录

修改权限

chown命令:修改文件的拥有者,前提是要有该拥有者(-R 递归修改)

[root@localhost tmp]# tail -1 /etc/passwd
linux00:x:1001:1001::/home/linux00:/bin/bash
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# touch file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 root root 0 Apr 26 08:56 file1
[root@localhost tmp]# chown linux00 file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]#

chgrp命令:修改文件所属组,前提是要有该组(-R 递归修改)

[root@localhost tmp]# tail -1 /etc/group
xiuyuan:x:1002:
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]# chgrp raoxiuyuan file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 xiuyuan 0 Apr 26 08:56 file1
[root@localhost tmp]#

chmod命令:修改拥有者和所属组的权限
● 加减法:u/g/o +/-/= r/w/x
● 数字法:r=4,w=2,x=1

[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]# chmod g+w file1
[root@localhost tmp]# ll file1
-rw-rw-

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值