【转】How to Change File Ownership & Groups in Linux
有关linux下 文件权限的问题,一直不是很清楚。(参考菜鸟教程: http://www.runoob.com/linux/linux-file-attr-permission.html)

像上面这样,default 这个链接文件的权限 rwx rwx rwx 即该文件的所有者的权限rwx(4-2-1),所有者所在的组的权限rwx, 其它用户(该组之外的所有用户)的权限rwx.

Linux文件属主和属组

对于文件来说,它都有一个特定的所有者,也就是对该文件具有所有权的用户。
同时,在Linux系统中,用户是按组分类的,一个用户属于一个或多个组。
文件所有者以外的用户又可以分为文件所有者的同组用户和其他用户。
因此,Linux系统按文件所有者、文件所有者同组用户和其他用户来规定了不同的文件访问权限。
在以上实例中,bin文件是一个目录文件,属主和属组都为root,属主有可读、可写、可执行的权限;与属主同组的其他用户有可读和可执行的权限;其他用户也有可读和可执行的权限。
-----------------------------------------------------------------------------------
原文:http://www.hostingadvice.com/how-to/change-file-ownershipgroups-linux/
File ownership and groups for files are fundamental to the Linux operating system. Every file in Linux is managed by a specific user and a specific group.
Figure Out Who Owns the File, Then Use Either chown or chgrp
Display ownership and group information using the following command:
|
1
2
|
ls -l file.txt
-rw-rw-r-- 1 root www-data 0 Feb 25 15:51 file.txt
|
This file is owned by the root user and belongs to the www-data group.
Changing the Ownership of a File Using chown
You can change the ownership of a specific file using the chown command. For security purposes only, the root user or members of the sudo group may transfer ownership of a file.
To change the ownership of a file:
|
1
2
3
4
|
chown robert file.txt
ls -l file.txt
-rw-rw-r-- 1 robert www-data 0 Feb 25 15:51 file.txt
|
The file file.txt is now owned by Robert. By default, chown follows symbolic links and changes the owner of the file pointed to by the symbolic link. If you wish to change ownership of all files inside a directory, you can use the -R option.
|
1
|
chown -R user directory/
|
Changing the Group Ownership of a File Using chgrp
All users on the system belong to at least one group. You can find out which groups you belong to using the following command:
|
1
|
groups username
|
You can then change the group ownership of a specific file using the chgrp command:
|
1
2
3
4
|
chgrp webdev file.txt
ls -l file.txt
-rw-rw-r-- 1 robert webdev 0 Feb 25 15:51 file.txt
|
The file file.txt now belongs to the webdev group.
Changing Both the Owner and the Group Using chown
You can change both the owner and group of a file using just the chown command.
|
1
2
3
4
|
chown tito:editors file.txt
ls -l file.txt
-rw-rw-r-- 1 tito editors 0 Feb 25 15:51 file.txt
|
The file file.txt is now owned by Tito and belongs to the editors group.
【转】How to Change File Ownership & Groups in Linux的更多相关文章
- How to restrict root user to access or modify a file and directory in Linux
Now in this article I will show you steps to prevent or restrict access of root user to access certa ...
- C# get md5,renamed file and can not change file's md5
using System; using System.Text; using System.IO; using System.Security.Cryptography; namespace Cons ...
- How to change default root@ email address linux / postfix / centos?
Change root@hostname to different email address By default, any email sent by system is sent to root ...
- User and User Groups in Linux
本文梳理了一下Linux用户和用户组的常用的一些命令. 有关的配置文件: /etc/group 存储当前系统中所有用户组信息 /etc/gshadow 存储当前系统中所有用户组的密码 /etc/pas ...
- How To Change Log Rate Limiting In Linux
By default in Linux there are a few different mechanisms in place that may rate limit logging. These ...
- ImportError: libsybdb.so.5: cannot open shared object file: No such file or directory pymssql linux 问题解决 搭建驱动
[root@hadoop1 nlp]# python sqlserver_t.py Traceback (most recent call last): File "sqlserver_t ...
- Modify File Descriptor Limit on Linux
System-wide File Descriptor Limit Get current value: sysctl fs.file-max modify max fd limit: sysctl ...
- 无法完成安装:'Cannot access storage file '/
今天自己编译了spice-protocol spice-gtk spice qemu,然后想用virsh去创建一个虚机: # virsh define demo.xml 定义域 demo(从 ...
- PHP7函数大全(4553个函数)
转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...
随机推荐
- Linux下关于/tmp目录的清理规则
本文将介绍Linux下/tmp目录的清理规则,rhel6和rhel7将以完全不同的两种方式进行清理. RHEL6 tmpwatch命令 tmpwatch 是专门用于解决“删除 xxx天没有被访问/修改 ...
- 《零基础入门学习Python》【第一版】视频课后答案第003讲
测试题答案: 0. 以下哪个变量的命名不正确?为什么? (A) MM_520 (B) _MM520_ (C) 520_MM (D) _520_MM(C)选项不正确,因为 Python 中的变量名不能以 ...
- Python学习网站推荐
B站是目前本人看到的最好的免费学习Python的网站 黑马程序员- https://space.bilibili.com/37974444?spm_id_from=333.338.viewbox_re ...
- ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.pid).
本文转载自http://www.jb51.net/article/48625.htm 今天网站web页面提交内容到数据库,发现出错了,一直提交不了,数找了下原因,发现数据写不进去!第一反应,重启mys ...
- LIN总线协议
汽车电子类的IC有的采用LIN协议来烧录内部NVM,如英飞凌的TLE8880N和博世的CR665D. LIN总线帧格式如下,一个LIN信息帧有同步间隔.同步域.标示符域(PID域).数据域.校验码域. ...
- 【LeetCode】Path Sum(路径总和)
这道题是LeetCode里的第112道题.是我在学数据结构——二叉树的时候碰见的题.题目要求: 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和 ...
- PAT Basic 1072
1072 开学寄语 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面.理发.整衣,然后思过.读 ...
- 算法学习记录-排序——选择排序(Simple Selection Sort)
之前在冒泡排序的附录中提到可以在每次循环时候,不用交换操作,而只需要记录最小值下标,每次循环后交换哨兵与最小值下标的书, 这样可以减少交换操作的时间. 这种方法针对冒泡排序中需要频繁交换数组数字而改进 ...
- Knockout v3.4.0 中文版教程-15-控制文本内容和外观-attr绑定
6. attr绑定 目的 attr绑定可以给关联DOM元素的任何属性赋值.这个绑定很棒,比如,当你想要设置通过视图模型给元素的title属性.img标签的src属性或超链接的href值,当视图模型对应 ...
- chromedriver 下载
https://sites.google.com/a/chromium.org/chromedriver/downloads 百度网盘链接:https://pan.baidu.com/s/1nwL ...