【转】How to Change File Ownership & Groups in Linux
2017-02-04 09:31
597 查看
有关linux下 文件权限的问题,一直不是很清楚。(参考菜鸟教程: http://www.runoob.com/linux/linux-file-attr-permission.html)
像上面这样,default 这个链接文件的权限 rwx rwx rwx 即该文件的所有者的权限rwx(4-2-1),所有者所在的组的权限rwx, 其它用户(该组之外的所有用户)的权限rwx.
对于文件来说,它都有一个特定的所有者,也就是对该文件具有所有权的用户。
同时,在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.
This file is owned by the root user and belongs to the www-data group.
To change the ownership of a file:
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.
You can then change the group ownership of a specific file using the chgrp command:
The file file.txt now belongs to the webdev group.
The file file.txt is now owned by Tito and belongs to the editors group.
像上面这样,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 |
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 |
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 |
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 |
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 |
相关文章推荐
- How To Install Programs In Linux (.gz &.bz & RPM)
- How to Output a List of Files to a File and Sort Them in Linux
- How to change the output color of echo in Linux
- how to search new file in linux
- How to change the resolution in text mode for Linux5+
- How to change window manager to OpenBox in Linux Mint 13 Mate
- How to Mount and Unmount Filesystem / Partition in Linux (Mount/Umount Command Examples)
- How to write/use DLL in Linux sy…
- How to programmatically clear the filesystem memory cache in C++ on a Linux system?
- How to change the name in open with list / File association.
- How to Change the Icon for a File Type in Windows 7 and Vista(转)
- Howto change all file and directory in a folder to 777?
- How to build & install GLFW 3 and use it in a Linux project
- git tip: How to undo an uncommitted change/deletion for a specific file in your working directory
- How to change I/O scheduler in Linux
- 5 Linux Touch Command Examples (How to Change File Timestamp)
- How to create patch file in Linu…
- How to read Mac .DMG file in Linux or PC
- How to check ip address in linux
- [Linux cmd line] How to convert a binary file into output in C include file style.