`
61party
  • 浏览: 1136066 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Advanced File Permissions in Linux

 
阅读更多

原文:http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php

Here we will discuss about the 3 special attributes other than the common read/write/execute.
Example:
drwxrwxrwt - Sticky Bits - chmod 1777
drwsrwxrwx - SUID set - chmod 4777
drwxrwsrwx - SGID set - chmod 2777

Sticky bit

Sticky bits are mainly set on directories.
If the sticky bit is set for a directory, only the owner of that directory or the owner of a file can delete or rename a file within that directory.

Example:
Consider you have a directory " test ".
chmod it to " 777 ". This gives permissions for all the users to read, write and execute.
chmod +t test

Example: ls -al
drwxrwxrwt 2 a1 a1 4096 Jun 13 2008 .
-rw-rw-r-- 1 a1 a1 0 Jun 11 17:30 1.txt
-rw-rw-r-- 1 b2 b2 0 Jun 11 22:52 2.txt

From the above example a1 is the owner of the test directory.
a1 can delete or rename the files 1.txt and 2.txt.
b2 can delete or rename the file 2.txt only.

SUID - [ Set User ID ]

SUID bit is set for files ( mainly for scripts ).
The SUID permission makes a script to run as the user who is the owner of the script, rather than the user who started it.

Example:
If a1 is the owner of the script and b2 tries to run the same script, the script runs with the ownership of a1.
If the root user wants to give permissions for some scripts to run by different users, he can set the SUID bit for that particular script.
So if any user on the system starts that script, it will run under the root ownership.

Note:
root user much be very carefull with this.

SGID - [ Set Group ID ]

If a file is SGID, it will run with the privileges of the files group owner, instead of the privileges of the person running the program.
This permission set also can make a similar impact. Here the script runs under the groups ownership.

You can also set SGID for directories.
Consider you have given 2777 permission for a directory. Any files created by any users under this directory will come as follows.

Example:
-rw-rw-r-- 1 b2 a1 0 Jun 11 17:30 1.txt

In the above example you can see that the owner of the file 1.txt is b2 and the group owner is a1.
So both b2 and a1 will have access to the file 1.txt.

Now lets make this more intresting and complicated.
Create a directory "test". Chmod it to 2777. Add sticky bit to it.

Example:
mkdir test
chmod 2777 test
chmod +t test

ls -al test
drwxrwsrwt 2 a1 a1 4096 Jun 13 2008 test

From the above permission set you can understand that SGID and sticky bit is set for the folder "test".
Now any user can create files under the test directory.

Example:
drwxrwsrwt 2 a1 a1 4096 Jun 13 2008 .
-rw-rw-r-- 1 b2 a1 0 Jun 11 17:30 1.txt
-rw-rw-r-- 1 c3 a1 0 Jun 11 17:30 2.txt
-rw-rw-r-- 1 d4 a1 0 Jun 11 17:30 3.txt

So all the a1 user has access to all the files under the test directory. He can edit, rename or remove the file.
b2 user has access to 1.txt only, c3 has access to 2.txt only...

If sticky bit was not set for the test directory, any user can delete any files from the test directory, since the test directory has 777 permissions.
But now it not possible.

Example:
If d4 tries to remove 1.txt
rm -f 1.txt
rm: cannot remove `1.txt': Operation not permitted



分享到:
评论

相关推荐

    Mastering Linux Security and Hardening

    controlling special permissions, encrypting file systems, and much moreMaster the art of securing a Linux environment with this end-to-end practical guideBook Description This book has extensive ...

    Linux Administration A Beginner's Guide 5ed.pdf

    - **File System Management:** Understanding file permissions, managing directories, and working with different types of files and storage devices. - **User and Group Management:** Best practices for ...

    Linux_slides.rar

    Module 1 — Introduction to Linux Module 2 — Logging In and General Orientation Module 3 — Navigating the File System Module 4 — Managing Files Module 5 — File Permissions and Access...

    Wiley.Publishing.Fedora.Linux.Toolbox.1000+.Commands.for.Fedora.CentOS.and.Red.Hat.Power.Users.and.Red.Hat.Power.Users.2008.pdf

    In this chapter, readers are introduced to Fedora Linux, an advanced and powerful Linux distribution. The authors cover the basic concepts and features that make Fedora stand out as a leading choice ...

    IMP_Linux 文件和目录的属性.pdf

    - [Advanced Linux File System Administration](https://www.linuxjournal.com/article/8395) - [Linux 文件系统权限详解](https://www.redhat.com/sysadmin/linux-permissions-explained) #### 14. 相关文档 - ...

    CompTIA.Linux.LPIC-1.Cert.Guide.07897545

    Devices, Linux Filesystems, Filesystem Hierarchy Standard Shells, Scripting and Data Management User Interfaces and Desktops Administrative Tasks Essential System Services Networking Fundamentals ...

    linux名次解释

    不同发行版使用不同的包管理器,如APT(Advanced Package Tool)用于Debian系发行版,YUM(Yellowdog Updater Modified)用于RHEL系发行版等。 #### 6. 用户空间(Userspace) 用户空间是指非内核空间,所有应用...

    Android Application Security Essentials

    Advanced Encryption Standard (AES) 115 Message Authentication Codes 116 Summary 117 Chapter 7: Securing Application Data 119 Data storage decisions 120 Privacy 120 Data retention 121 Implementation ...

    Ubuntu Pocket Guide and Reference: A concise companion for day-to-day Ubuntu use

    - **Advanced Features**: Advanced features like searching for files, previewing file contents, and managing permissions are explored. **Command-Line Interface (CLI)** - **Basics of Command Line**: ...

    Django 1.0 Website Development.pdf

    Using permissions in views 166 Summary 167 Chapter 9: Advanced Browsing and Searching 169 Adding RSS feeds 170 Creating the recent bookmarks feed 170 Customizing item fields 174 Creating the ...

    Ubuntu The Complete Reference

    - **Permissions and Ownership**: Detailed explanation of file permissions and ownership, including how to change them using commands like `chmod` and `chown`. #### Part V - Applications **Chapter 13...

    UNIX环境高级编程(第二版,英文版)

    Praise for Advanced Programming in the UNIX® Environment, Second Edition Praise for the First Edition Addison-Wesley Professional Computing Series Foreword Preface Introduction ...

    Sams.Ubuntu.Unleashed.2010.Edition.Dec.2009.pdf

    - Configuring Ubuntu as a server for web hosting, file sharing, and other services. - Managing user accounts and permissions to control access to resources. ##### Multimedia - Playing and managing ...

    cuteEditor6.0

    You can also create your own policy files that define arbitrary permission sets. <br/>Comparison of the sample security policy file <br/> Permissions/Resource Setting Admin Default ...

    The Buildroot user manual

    以及如何定制生成的目标文件系统(Customizing the generated target filesystem),比如设置文件权限和所有权(Setting file permissions and ownership)、添加自定义设备节点(Adding custom device nodes)和...

    encase4.2教程,计算机取证软件

    - **NTFS and Unix File Permissions and Ownership**:增强了对NTFS和Unix文件权限和所有权的处理能力。 - **NTFS Compression**:支持NTFS压缩,提升了存储空间利用率。 - **Threaded Crash Protection**:通过...

Global site tag (gtag.js) - Google Analytics