unix 权限_Unix权限的简单方法

unix 权限

I recently had to deliver a project hosted in Linux and I lost count of the number of times I had to fiddle with file and directory permissions… Yes I understand how they work; yes I can work them out in my head; yes I have memorised the most common ones by now; yes I can use the stat command; and yes I can use the symbolic notation instead! But why shall I do this EVERY.SINGLE.TIME if I can just look them up? So I wrote a quick and dirty python script to generate the full list of permissions and then I used it as a reference to lookup any combination I came across along the way.

我最近不得不交付一个在Linux上托管的项目,而我却浪费了数次不得不摆弄文件和目录权限的次数。是的,我知道它们如何工作的。 是的,我可以在脑海中解决它们; 的,到目前为止我已经记住了最普通的那些。 是的,我可以使用stat命令; 是的,我可以改用符号表示法! 但是,如果我只能查一下它们,为什么还要每次都这样做呢? 因此,我编写了一个快速且肮脏的python脚本来生成权限的完整列表,然后将其用作查找我在此过程中遇到的任何组合的参考。

For those cases that you prefer to use your brainpower for things that matter and you just want the easy answer for the mundane ones, this article is for you. I will quickly cover the basics for fear of it being the most uninspiring article ever, but …

对于那些您希望将脑力用于重要事情的情况,而您只想为平凡的事情提供简单的答案,本文适合您。 由于担心它是有史以来最令人鼓舞的文章,我将快速介绍其基本知识,但是…

My main intention is to provide a ‘cheat-sheet’ of all permission permutations from 0 to 777!

我的主要目的是提供一个从0到777的所有权限排列的“备忘单”!

基础 (The Basics)

Unix permissions are granted to three different entities:

Unix权限被授予三个不同的实体:

  • Owner

    所有者
  • Group members

    小组成员
  • Others (i.e. The World)

    其他人(即世界)

There are three permission attributes: r, w and x.

有三个权限属性:r,w和x。

read (r)Reading the contents of a file or ability to list all the files in a directory.

读(r) 读取文件的内容或列出目录中所有文件的功能。

write (w)Change the contents of a file or create new files in the directory.

写(w) 更改文件的内容或在目录中创建新文件。

execute (x)This implies the right to execute a file (e.g. bash or program). For directories, execute permissions grant the right to enter a directory and to access any of its files.

execute(x)这意味着执行文件(例如bash或程序)的权利。 对于目录,执行权限授予进入目录和访问其任何文件的权限。

Image for post

Permissions can be represented not only with rwx’s but also in the octal notation (0 to 7). Each octal is the sum of its component bits in the binary numeral system:

权限不仅可以用rwx表示,还可以用八进制表示法(0到7)表示。 每个八进制数都是二进制数字系统中其组成位的总和:

Image for post

A set of three octals reflects the three entities: from left to right, the first digit represents the permissions for user, the second one is for the group and the third one is for others.

一套三个八进制反映了三个实体:从左至右,第一个数字代表了用户的权限,第二个是该,第三个是给别人

Image for post

That’s it! It is very simple indeed!

而已! 确实很简单!

简单的方法 (The Easy Way)

As promised though, feel free to look them up below:

如所承诺的,请随时在下面查找它们:

0----------1---------x2--------w-3--------wx4-------r--5-------r-x6-------rw-7-------rwx10------x---11------x--x12------x-w-13------x-wx14------xr--15------xr-x16------xrw-17------xrwx20-----w----21-----w---x22-----w--w-23-----w--wx24-----w-r--25-----w-r-x26-----w-rw-27-----w-rwx30-----wx---31-----wx--x32-----wx-w-33-----wx-wx34-----wxr--35-----wxr-x36-----wxrw-37-----wxrwx40----r-----41----r----x42----r---w-43----r---wx44----r--r--45----r--r-x46----r--rw-47----r--rwx50----r-x---51----r-x--x52----r-x-w-53----r-x-wx54----r-xr--55----r-xr-x56----r-xrw-57----r-xrwx60----rw----61----rw---x62----rw--w-63----rw--wx64----rw-r--65----rw-r-x66----rw-rw-67----rw-rwx70----rwx---71----rwx--x72----rwx-w-73----rwx-wx74----rwxr--75----rwxr-x76----rwxrw-77----rwxrwx100---x------101---x-----x102---x----w-103---x----wx104---x---r--105---x---r-x106---x---rw-107---x---rwx110---x--x---111---x--x--x112---x--x-w-113---x--x-wx114---x--xr--115---x--xr-x116---x--xrw-117---x--xrwx120---x-w----121---x-w---x122---x-w--w-123---x-w--wx124---x-w-r--125---x-w-r-x126---x-w-rw-127---x-w-rwx130---x-wx---131---x-wx--x132---x-wx-w-133---x-wx-wx134---x-wxr--135---x-wxr-x136---x-wxrw-137---x-wxrwx140---xr-----141---xr----x142---xr---w-143---xr---wx144---xr--r--145---xr--r-x146---xr--rw-147---xr--rwx150---xr-x---151---xr-x--x152---xr-x-w-153---xr-x-wx154---xr-xr--155---xr-xr-x156---xr-xrw-157---xr-xrwx160---xrw----161---xrw---x162---xrw--w-163---xrw--wx164---xrw-r--165---xrw-r-x166---xrw-rw-167---xrw-rwx170---xrwx---171---xrwx--x172---xrwx-w-173---xrwx-wx174---xrwxr--175---xrwxr-x176---xrwxrw-177---xrwxrwx200--w-------201--w------x202--w-----w-203--w-----wx204--w----r--205--w----r-x206--w----rw-207--w----rwx210--w---x---211--w---x--x212--w---x-w-213--w---x-wx214--w---xr--215--w---xr-x216--w---xrw-217--w---xrwx220--w--w----221--w--w---x222--w--w--w-223--w--w--wx224--w--w-r--225--w--w-r-x226--w--w-rw-227--w--w-rwx230--w--wx---231--w--wx--x232--w--wx-w-233--w--wx-wx234--w--wxr--235--w--wxr-x236--w--wxrw-237--w--wxrwx240--w-r-----241--w-r----x242--w-r---w-243--w-r---wx244--w-r--r--245--w-r--r-x246--w-r--rw-247--w-r--rwx250--w-r-x---251--w-r-x--x252--w-r-x-w-253--w-r-x-wx254--w-r-xr--255--w-r-xr-x256--w-r-xrw-257--w-r-xrwx260--w-rw----261--w-rw---x262--w-rw--w-263--w-rw--wx264--w-rw-r--265--w-rw-r-x266--w-rw-rw-267--w-rw-rwx270--w-rwx---271--w-rwx--x272--w-rwx-w-273--w-rwx-wx274--w-rwxr--275--w-rwxr-x276--w-rwxrw-277--w-rwxrwx300--wx------301--wx-----x302--wx----w-303--wx----wx304--wx---r--305--wx---r-x306--wx---rw-307--wx---rwx310--wx--x---311--wx--x--x312--wx--x-w-313--wx--x-wx314--wx--xr--315--wx--xr-x316--wx--xrw-317--wx--xrwx320--wx-w----321--wx-w---x322--wx-w--w-323--wx-w--wx324--wx-w-r--325--wx-w-r-x326--wx-w-rw-327--wx-w-rwx330--wx-wx---331--wx-wx--x332--wx-wx-w-333--wx-wx-wx334--wx-wxr--335--wx-wxr-x336--wx-wxrw-337--wx-wxrwx340--wxr-----341--wxr----x342--wxr---w-343--wxr---wx344--wxr--r--345--wxr--r-x346--wxr--rw-347--wxr--rwx350--wxr-x---351--wxr-x--x352--wxr-x-w-353--wxr-x-wx354--wxr-xr--355--wxr-xr-x356--wxr-xrw-357--wxr-xrwx360--wxrw----361--wxrw---x362--wxrw--w-363--wxrw--wx364--wxrw-r--365--wxrw-r-x366--wxrw-rw-367--wxrw-rwx370--wxrwx---371--wxrwx--x372--wxrwx-w-373--wxrwx-wx374--wxrwxr--375--wxrwxr-x376--wxrwxrw-377--wxrwxrwx400-r--------401-r-------x402-r------w-403-r------wx404-r-----r--405-r-----r-x406-r-----rw-407-r-----rwx410-r----x---411-r----x--x412-r----x-w-413-r----x-wx414-r----xr--415-r----xr-x416-r----xrw-417-r----xrwx420-r---w----421-r---w---x422-r---w--w-423-r---w--wx424-r---w-r--425-r---w-r-x426-r---w-rw-427-r---w-rwx430-r---wx---431-r---wx--x432-r---wx-w-433-r---wx-wx434-r---wxr--435-r---wxr-x436-r---wxrw-437-r---wxrwx440-r--r-----441-r--r----x442-r--r---w-443-r--r---wx444-r--r--r--445-r--r--r-x446-r--r--rw-447-r--r--rwx450-r--r-x---451-r--r-x--x452-r--r-x-w-453-r--r-x-wx454-r--r-xr--455-r--r-xr-x456-r--r-xrw-457-r--r-xrwx460-r--rw----461-r--rw---x462-r--rw--w-463-r--rw--wx464-r--rw-r--465-r--rw-r-x466-r--rw-rw-467-r--rw-rwx470-r--rwx---471-r--rwx--x472-r--rwx-w-473-r--rwx-wx474-r--rwxr--475-r--rwxr-x476-r--rwxrw-477-r--rwxrwx500-r-x------501-r-x-----x502-r-x----w-503-r-x----wx504-r-x---r--505-r-x---r-x506-r-x---rw-507-r-x---rwx510-r-x--x---511-r-x--x--x512-r-x--x-w-513-r-x--x-wx514-r-x--xr--515-r-x--xr-x516-r-x--xrw-517-r-x--xrwx520-r-x-w----521-r-x-w---x522-r-x-w--w-523-r-x-w--wx524-r-x-w-r--525-r-x-w-r-x526-r-x-w-rw-527-r-x-w-rwx530-r-x-wx---531-r-x-wx--x532-r-x-wx-w-533-r-x-wx-wx534-r-x-wxr--535-r-x-wxr-x536-r-x-wxrw-537-r-x-wxrwx540-r-xr-----541-r-xr----x542-r-xr---w-543-r-xr---wx544-r-xr--r--545-r-xr--r-x546-r-xr--rw-547-r-xr--rwx550-r-xr-x---551-r-xr-x--x552-r-xr-x-w-553-r-xr-x-wx554-r-xr-xr--555-r-xr-xr-x556-r-xr-xrw-557-r-xr-xrwx560-r-xrw----561-r-xrw---x562-r-xrw--w-563-r-xrw--wx564-r-xrw-r--565-r-xrw-r-x566-r-xrw-rw-567-r-xrw-rwx570-r-xrwx---571-r-xrwx--x572-r-xrwx-w-573-r-xrwx-wx574-r-xrwxr--575-r-xrwxr-x576-r-xrwxrw-577-r-xrwxrwx600-rw-------601-rw------x602-rw-----w-603-rw-----wx604-rw----r--605-rw----r-x606-rw----rw-607-rw----rwx610-rw---x---611-rw---x--x612-rw---x-w-613-rw---x-wx614-rw---xr--615-rw---xr-x616-rw---xrw-617-rw---xrwx620-rw--w----621-rw--w---x622-rw--w--w-623-rw--w--wx624-rw--w-r--625-rw--w-r-x626-rw--w-rw-627-rw--w-rwx630-rw--wx---631-rw--wx--x632-rw--wx-w-633-rw--wx-wx634-rw--wxr--635-rw--wxr-x636-rw--wxrw-637-rw--wxrwx640-rw-r-----641-rw-r----x642-rw-r---w-643-rw-r---wx644-rw-r--r--645-rw-r--r-x646-rw-r--rw-647-rw-r--rwx650-rw-r-x---651-rw-r-x--x652-rw-r-x-w-653-rw-r-x-wx654-rw-r-xr--655-rw-r-xr-x656-rw-r-xrw-657-rw-r-xrwx660-rw-rw----661-rw-rw---x662-rw-rw--w-663-rw-rw--wx664-rw-rw-r--665-rw-rw-r-x666-rw-rw-rw-667-rw-rw-rwx670-rw-rwx---671-rw-rwx--x672-rw-rwx-w-673-rw-rwx-wx674-rw-rwxr--675-rw-rwxr-x676-rw-rwxrw-677-rw-rwxrwx700-rwx------701-rwx-----x702-rwx----w-703-rwx----wx704-rwx---r--705-rwx---r-x706-rwx---rw-707-rwx---rwx710-rwx--x---711-rwx--x--x712-rwx--x-w-713-rwx--x-wx714-rwx--xr--715-rwx--xr-x716-rwx--xrw-717-rwx--xrwx720-rwx-w----721-rwx-w---x722-rwx-w--w-723-rwx-w--wx724-rwx-w-r--725-rwx-w-r-x726-rwx-w-rw-727-rwx-w-rwx730-rwx-wx---731-rwx-wx--x732-rwx-wx-w-733-rwx-wx-wx734-rwx-wxr--735-rwx-wxr-x736-rwx-wxrw-737-rwx-wxrwx740-rwxr-----741-rwxr----x742-rwxr---w-743-rwxr---wx744-rwxr--r--745-rwxr--r-x746-rwxr--rw-747-rwxr--rwx750-rwxr-x---751-rwxr-x--x752-rwxr-x-w-753-rwxr-x-wx754-rwxr-xr--755-rwxr-xr-x756-rwxr-xrw-757-rwxr-xrwx760-rwxrw----761-rwxrw---x762-rwxrw--w-763-rwxrw--wx764-rwxrw-r--765-rwxrw-r-x766-rwxrw-rw-767-rwxrw-rwx770-rwxrwx---771-rwxrwx--x772-rwxrwx-w-773-rwxrwx-wx774-rwxrwxr--775-rwxrwxr-x776-rwxrwxrw-777-rwxrwxrwx

Thanks for reading!

谢谢阅读!

I regularly write about Leadership, Technology & Data on Medium — if you would like to read my future posts then please ‘Follow’ me!

我会定期撰写有关领导力,技术和数据的媒体文章-如果您想阅读我将来的文章,请“关注”我

翻译自: https://towardsdatascience.com/unix-permissions-the-easy-way-98cc19979b3e

unix 权限

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值