Linux_centos7_文件权限与目录配置 _(Bird_Bro)

2023-11-13

Linux_文件权限与目录配置


[root@localhost bird_bro]# touch chgrp_test.t
[root@localhost bird_bro]# ls -l
total 0
-rw-r--r--. 1 root root 0 Mar 22 15:11 chgrp_test.t
[root@localhost bird_bro]# exit
exit
[kingarthur@localhost ~]$ touch chgrp_usergroup_test.t
[kingarthur@localhost ~]$ ls -l
total 240
-rw-rw-r--. 1 kingarthur kingarthur     0 Mar 22 15:12 chgrp_usergroup_test.t
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Desktop
drwxr-xr-x. 3 kingarthur kingarthur    19 Mar 22 15:10 Documents
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Downloads
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Music
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Pictures
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Public
-rw-rw-r--. 1 kingarthur kingarthur 57761 Jul 10  2019 README
-rw-rw-r--. 1 kingarthur kingarthur 57761 Jul 10  2019 README.1
-rw-rw-r--. 1 kingarthur kingarthur 57761 Jul 10  2019 README.2
-rw-rw-r--. 1 kingarthur kingarthur 57761 Jul 10  2019 README.3
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Templates
drwxrwxr-x. 2 kingarthur kingarthur     6 Mar 19 07:31 test_tty1
drwxr-xr-x. 2 kingarthur kingarthur     6 Mar 18 14:28 Videos

#用户kingarthur 不能将kingarthur用户的文件移动到用户root创建的目录下
[kingarthur@localhost ~]$ mv ./chgrp_usergroup_test.t  ./Documents/Linux/bird_bro/
mv: cannot move ‘./chgrp_usergroup_test.t’ to ‘./Documents/Linux/bird_bro/chgrp_usergroup_test.t’: Permission denied
[kingarthur@localhost ~]$ su
Password: 
[root@localhost kingarthur]# ls
chgrp_usergroup_test.t  Desktop  Documents  Downloads  Music  Pictures  Public  README  README.1  README.2  README.3  Templates  test_tty1  Videos
[root@localhost kingarthur]# mv ./chgrp_usergroup_test.t  ./Documents/Linux/bird_bro/
[root@localhost kingarthur]# ls 
Desktop  Documents  Downloads  Music  Pictures  Public  README  README.1  README.2  README.3  Templates  test_tty1  Videos
[root@localhost kingarthur]# cd ./Documents/Linux/bird_bro/
#切换至用户root后成功 mv 文件
[root@localhost bird_bro]# ls 
chgrp_test.t  chgrp_usergroup_test.t
[root@localhost bird_bro]# ls -la
total 0
drwxr-xr-x. 2 root       root       56 Mar 22 15:17 .
drwxr-xr-x. 3 root       root       22 Mar 22 15:10 ..
-rw-r--r--. 1 root       root        0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur  0 Mar 22 15:12 chgrp_usergroup_test.t
#改变文件组信息 kingarthur -- >group
[root@localhost bird_bro]# chgrp root chgrp_usergroup_test.t 
[root@localhost bird_bro]# ls -la
total 0
drwxr-xr-x. 2 root       root 56 Mar 22 15:17 .
drwxr-xr-x. 3 root       root 22 Mar 22 15:10 ..
-rw-r--r--. 1 root       root  0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur root  0 Mar 22 15:12 chgrp_usergroup_test.t
#改变文件组信息 root --> kingarthur
[root@localhost bird_bro]# chgrp kingarthur chgrp_usergroup_test.t 
[root@localhost bird_bro]# ls -la
total 0
drwxr-xr-x. 2 root       root       56 Mar 22 15:17 .
drwxr-xr-x. 3 root       root       22 Mar 22 15:10 ..
-rw-r--r--. 1 root       root        0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur  0 Mar 22 15:12 chgrp_usergroup_test.t
#当组信息不在/etc/group 中时,报错
[root@localhost bird_bro]# chgrp test chgrp_test.t 
chgrp: invalid group: ‘test’
[root@localhost bird_bro]# su root
[root@localhost bird_bro]# su kingarthur
[kingarthur@localhost bird_bro]$ su root
Password: 
#查看sudoers用户
[root@localhost bird_bro]# ls -la /etc/sudoers
-r--r-----. 1 root root 4328 Oct 30  2018 /etc/sudoers
#查看编辑sudoers列表,追加 kingarthur
[root@localhost bird_bro]# vi /etc/sudoers
#文件增加 w  权限
[root@localhost bird_bro]# chmod u+w /etc/sudoers
[root@localhost bird_bro]# ls -l /etc/sudoers
-rw-r-----. 1 root root 4328 Oct 30  2018 /etc/sudoers
[root@localhost bird_bro]# vi /etc/sudoers
#取消 x 权限
[root@localhost bird_bro]# chmod u-x /etc/sudoers
[root@localhost bird_bro]# ls -l /etc/sudoers
-rw-r-----. 1 root root 4353 Mar 22 15:42 /etc/sudoers
#取消 w 权限
[root@localhost bird_bro]# chmod u-w /etc/sudoers
[root@localhost bird_bro]# ls -l /etc/sudoers
-r--r-----. 1 root root 4353 Mar 22 15:42 /etc/sudoers
#切换用户至 kingarthur
[root@localhost bird_bro]# su kingarthur
#切换用户至root
[kingarthur@localhost bird_bro]$ su root
Password: 
[root@localhost bird_bro]# su kingarthur
[kingarthur@localhost bird_bro]$ ls -l
total 0
-rw-r--r--. 1 root       root       0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 22 15:12 chgrp_usergroup_test.t
#复制 root 用户文件至当前路径下,文件名 *1.t
[kingarthur@localhost bird_bro]$ cp ./chgrp_test.t ./chgrp_test1.t
cp: cannot create regular file ‘./chgrp_test1.t’: Permission denied
# sudo 权限
[kingarthur@localhost bird_bro]$ sudo cp ./chgrp_test.t ./chgrp_test1.t
[sudo] password for kingarthur: 
#用户 kingarthur 成功复制 root 用户文件内容为新文件
[kingarthur@localhost bird_bro]$ ls -l
total 0
-rw-r--r--. 1 root       root       0 Mar 22 15:45 chgrp_test1.t
-rw-r--r--. 1 root       root       0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 22 15:12 chgrp_usergroup_test.t
[kingarthur@localhost bird_bro]$ pwd
/home/kingarthur/Documents/Linux/bird_bro
[kingarthur@localhost bird_bro]$ ls -l
total 0
-rw-r--r--. 1 root       root       0 Mar 22 15:45 chgrp_test1.t
-rw-r--r--. 1 root       root       0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 22 15:12 chgrp_usergroup_test.t
#更改文件所属用户及用户组, chown user file 将只更改文件所有者,
#指令 chown user:group file 将同时更改文件所有者及所属群组
[kingarthur@localhost bird_bro]$ chown kingarthur:root chgrp_test.t
chown: changing ownership of ‘chgrp_test.t’: Operation not permitted
[kingarthur@localhost bird_bro]$ sudo chown kingarthur:root chgrp_test.t
[sudo] password for kingarthur: 
#文件所有者 root 被更改为 kingarthhur, 用户组 root 更改为 root  
[kingarthur@localhost bird_bro]$ ls -l
total 0
-rw-r--r--. 1 root       root       0 Mar 22 15:45 chgrp_test1.t
-rw-r--r--. 1 kingarthur root       0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 22 15:12 chgrp_usergroup_test.t
[kingarthur@localhost bird_bro]$ chown root:kingarthur chgrp_usergroup_test.t 
chown: changing ownership of ‘chgrp_usergroup_test.t’: Operation not permitted
[kingarthur@localhost bird_bro]$ sudo chown root:kingarthur chgrp_usergroup_test.t 
#更改文件所有者 kingarthur 为 root , 用户组 kingarthur 更改为 kingarthur
[kingarthur@localhost bird_bro]$ ls -l
total 0
-rw-r--r--. 1 root       root       0 Mar 22 15:45 chgrp_test1.t
-rw-r--r--. 1 kingarthur root       0 Mar 22 15:11 chgrp_test.t
-rw-rw-r--. 1 root       kingarthur 0 Mar 22 15:12 chgrp_usergroup_test.t

#登录用户及系统登录口令
#cut -d : -f 1 仅查看用户名列, -d 后接分割字符,与 -f 连用,一句 -d 后的分割字符将一段文字
#分成数段,用 -f 取出第几段
[kingarthur@localhost bird_bro]$ cut -d : -f 1 /etc/passwd
root
bin
apache
tcpdump
kingarthur

#查看当前用户所在群组及该群组成员
[kingarthur@localhost bird_bro]$ groups
kingarthur
[kingarthur@localhost bird_bro]$ groups kingarthur
kingarthur : kingarthur
[kingarthur@localhost bird_bro]$ groups root
root : root
#添加新群组
[kingarthur@localhost bird_bro]$ sudo groupadd test_group
#显示当前用户所在group
[kingarthur@localhost bird_bro]$ groups
kingarthur
#查看group信息
[kingarthur@localhost bird_bro]$ cut -d : -f  1  /etc/group
root
bin
daemon
sys
adm
kingarthur
test_group
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux_centos7_文件权限与目录配置 _(Bird_Bro) 的相关文章

  • 寒假小复习4

    冒泡排序 public class Sort public static void main String args double nums 1 66 73 41 30 1 double temp for int i 0 i lt nums
  • 深入springMVC

    HTML 页面中的表单最初所采用 application x www form urlencode 编码方式 并不满足文件上传的需要 所以 RFC 1867 在此基础上增加了新的 multipart form data 编码方式以支持基于表
  • LRU算法(JAVA实现)

    一 算法介绍 最近最久未使用 Least Recently Used LRU 算法是 种缓存淘汰策略 它是大部分操作系统为最大化页面命中率而广泛采用的一种页面置换算法 该算法的思路是 发生缺页中断时 将最近一段时间内最久未使用的页面置换出去
  • Java static——拾遗

    Java static 拾遗 Java Static 作为修饰符 可以用来修饰变量 方法 代码块 但绝对不能修饰类 1 修饰变量 类的所有对象共同拥有的一个属性 也称为类变量 这类似于C语言中的全局变量 类变量在类加载的时候初始化 而且只被
  • Jenkins添加用户并授权

    添加用户 先选择系统管理1 再在右侧选择2 例如 注意 之后点击保存按钮 如果没有角色先去添加角色 设置完毕一般等待几分钟才可登录查看自己的功能权限 太早登录没任何功能
  • Excel下拉框样式

    1 打开要修改的Excel 选中要修改样式的单元格 2 在上边导航栏中选择 Data 找到 Data Validation 点击下面的 Data Validation 3 在设置中找到 Allow 项 选择 List Source中填写可供
  • 运行mvn -v后出现“cmd 不是内部或外部命令,也不是可运行的程序"

    1 下载maven 官网下载地址 http maven apache org download cgi 2 解压到软件安装目录 比如我解压到E java apache maven 3 5 0 bin apache maven 3 5 0 3
  • mysql中分组取创建时间最新的数据

    近期由于公司数据库升级 遇到了一个问题 以前写的SQL语句查询结果出现了异常 sql实现的功能 将数据以PID进行分组 在组内获取创建时间最新的数据 项目数据比较敏感写了一些测试数据 执行的sql语句 select from select
  • Android中使用jiecaovideoplayer播放视频

    每天学一点2020 5 13 Android 2 Android中使用jiecaovideoplayer播放视频 1 添加依赖 2 添加运行时的权限 3 布局 4 JCVideoPlayer使用 5 设置视频 Android中使用jieca
  • moviepy使用教程

    moviepy使用教程 一 剪辑成果 二 遇到问题 三 moviepy方法分享 一 音频剪辑方法 二 视频剪辑方法 一 剪辑成果 未来 二 遇到问题 尝试使用ffmpeg moviepy pydub 其中pydub主要是对音频的处理 mov
  • @Transactional注解的方法之间调用事务是否生效及其他事务失效场景总结

    对于方法之间调用 注解 Transaction生效以及失效的场景 首先 我们需要知道 Spring是通过代理管理事务的 方法和方法之间的调用分为两种情况 解决办法可在下面列举的不同场景中自取 1 不同类之间的方法调用 如类A的方法a 调用类
  • 三、python基础——六大基本数据类型

    目录 六大标准数据类型 1 数字 Number 不可变 1 1 数值的运算 2 字符串 String 不可变 2 1 介绍 2 2 操作 2 2 1 切片 2 2 2 转义字符 3 列表 List 3 1 介绍 3 2 操作 3 2 1 索
  • 关于CyclicBarrier的一些解释

    我在网上找了一些关于CyclicBarrier的一些解释 In a nutshell just to understand key functional differences between the two public class Co
  • 华为服务器怎么修改启动项,服务器启动项设置方法

    服务器启动项设置方法 内容精选 换一换 如果密码丢失 或创建时未设置密码 推荐您在控制台设置登录密码 有以下几种现象 将制作好的SD卡插入开发者板并上电后 开发者板LED1与LED2灯状态信息异常 将制作好的SD卡插入开发者板 并通过USB
  • std::true_type和std::false_type

    一 认识std true type和std false type std true type和std false type实际上是类型别名 源码如下 template
  • @vue/cli4.5.8搭建项目的坑

    先说下我使用脚手架4 5遇到的问题 使用GUI面板配置项目 脚手架版本4 5 8 安装好Element ui 运行结果如图所示 测试了很多次 还是有问题 最终的解决方案 卸载当前脚手架版本 npm uninstall g vue cli 安

随机推荐