【转】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 ...
随机推荐
- (原) 剑指offer--之数值的整数次方
题目描述 给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方. 初次看题觉得这题好简单,直接用库函数power()不就行了,仔细想了想,万 ...
- H.264 与 MPEG-4 压缩格式的变革
h.264 和 mpeg-4 的关系: h.264 /avc ( advanced video coding )标准,是 mpeg-4 的第 10 部分. mpeg-4的初衷是将dvd质量的图像码流从 ...
- nginx+django+uwsgi+https 配置问题点
- ssl 证书申请 申请域名的网站申请下载对应文件即可 - nginx 配置 https [root@VM_2_29_centos conf]# nginx -t nginx: [emerg] u ...
- BRVAH(让RecyclerView变得更高效) (3)
本文来自网易云社区 作者:吴思博 3 实现列表加载动画效果 3.1默认动画 我们只需将自建的 adapter 继承它对应满足需求的 Adapter,然后在 Activity 中实例化,通过ope ...
- ffmpeg的函数av_samples_get_buffer_size分析,对齐的意思
/* * 此函数只应用于音频. * 计算出:要把一系列的样本保存起来,需要多大的缓存. * sample,单个通道的单次采样所得到的样本数据. * planar,和yuv存储格式一样,声音也分平面(p ...
- ASP.NET上传大文件404报错
报错信息: Failed to load resource: the server responded with a status of 404 (Not Found) 尝试1: 仅修改Web.con ...
- 2.ruby基本语法,类的定义
1.在ruby中的定义class,ruby中定义类也是以关键字class开头 后面带着类名,类名以大写开头.一个类的结束以关键字end 结束.如: class Customer end 2.ruby类 ...
- 【Luogu】P1593因子和(唯一分解定理,约数和公式)
题目链接 首先介绍两个定理. 整数唯一分解定理:任意正整数都有且只有一种方式写出素数因子的乘积表达式. \(A=(p1k1 p2k2 ...... pnkn \) 求这些因子的代码如下 ;i*i< ...
- BZOJ 3028 食物 ——生成函数
把所有东西的生成函数搞出来. 发现结果是x*(1-x)^(-4) 然后把(1-x)^(-4)求逆,得到(1+x+x^2+...)^4 然后考虑次数为n的项前的系数,就相当于选任意四个非负整数构成n的方 ...
- [luoguP3953] 逛公园(DP + spfa)
传送门 看到求方案数,应该很容易想到dp f[u][i]表示到点u,且比到u的最短距离多i的方案数 那么需要先预处理dis数组,spfa或者堆优化的dijk 因为考虑到dp的顺序,f[u][i]转移到 ...