有关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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. User and User Groups in Linux

    本文梳理了一下Linux用户和用户组的常用的一些命令. 有关的配置文件: /etc/group 存储当前系统中所有用户组信息 /etc/gshadow 存储当前系统中所有用户组的密码 /etc/pas ...

  5. 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 ...

  6. 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 ...

  7. Modify File Descriptor Limit on Linux

    System-wide File Descriptor Limit Get current value: sysctl fs.file-max modify max fd limit: sysctl ...

  8. 无法完成安装:'Cannot access storage file '/

    今天自己编译了spice-protocol spice-gtk spice qemu,然后想用virsh去创建一个虚机: # virsh define demo.xml     定义域 demo(从 ...

  9. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

随机推荐

  1. 主DNS服务-反向解析

    上篇说了主DNS正向解析 当中是有个小问题的,什么问题呢? 试问当我们输入wwww或ww或更多w的时候它还能解析出来吗? 或者不输入w的时候还能解析吗? 上篇没有定义是解析不了的,怎么定义呢?很简单, ...

  2. Mac OSX: 有线共享WiFi

    首先连上有线 系统偏好设置->网络->点击左侧WiFi,再点击右下角[高级] 勾选[创建电脑对电脑网络],然后单击[好] 在顶部菜单栏击WiFi图标,如果WiFi未打开,则单击打开,如果已 ...

  3. sed快速学习

  4. (转)去除背景色的方法,适合iOS5/6/7/8.0beta

    通常使用UISearchbar都需要去除其背景色来与自己的界面风格保持协调,但是UISearchbar的设计随着iOS版本的升级不断地在发生着变化,下面我们通过分析UISearchbar在各个iOS版 ...

  5. 剑指Offer(书):合并两个排序的列表

    题目:输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 递归版本: public ListNode Merge(ListNode list1,ListNod ...

  6. uboot的readme

    ## (C) Copyright 2000 - 2008# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## See file CREDI ...

  7. IOS 自动布局-UIStackPanel和UIGridPanel(二)

    在上一篇中我提到了如何使用stackpanel和gridpanel来实现自动布局.而在这一篇中我着重讲解下其中的原理. 在(UIPanel   UIStackPanel  UIGridPanel)中主 ...

  8. Appium+python自动化-环境搭建

    一.前言 本文是在windows10  X64系统下搭建appium,流程如下: 1.安装jdk1.8+python3.6 (64位) 2.安装node.js 3.安装Appium-desktop 4 ...

  9. apache下虚拟域名配置

    在我们开发中通过虚拟域名来访问一个指定的项目确实很方便,接下来教大家如何通过手动的方式去配置虚拟域名(已apache服务器为例) 一.首页我们得找到host文件.windows下这个文件在c盘中WIN ...

  10. CentOS 下通过命令登录Mysql

    CentOS 下通过命令登录Mysql: mysql -uroot -p 按回车键后输入密码