更改文件权限 Linux [英] Changing File Permissions Linux

查看:29
本文介绍了更改文件权限 Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于文件权限,我似乎无法写入此文件

It looks like I can't write to this file because of the file permission

访问:(0644/-rw-r--r--) Uid:( 0/root) Gid:( 0/
根)

Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/
root)

如何更改文件权限以便我可以写入?

How do I change the file permission so I can write to it?

推荐答案

chmod

chmod 命令用于更改文件或目录的权限.要使用它,请指定所需的权限设置以及要修改的文件.指定权限有两种方式,我只教一种方式.

The chmod command is used to change the permissions of a file or directory. To use it, you specify the desired permission settings and the file or files that you wish to modify. There are two ways to specify the permissions, but I am only going to teach one way.

很容易将权限设置视为一系列位(这就是计算机如何看待它们).这是它的工作原理:

It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here's how it works:

rwx rwx rwx = 111 111 111

rw- rw- rw- = 110 110 110

rwx --- --- = 111 000 000

等等...

rwx = 111 in binary = 7

rw- = 110 in binary = 6

r-x = 101 in binary = 5

r-- = 100 in binary = 4

777

(rwxrwxrwx) 没有权限限制.任何人都可以做任何事情.通常不是一个理想的设置.

(rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

755

(rwxr-xr-x) 文件的所有者可以读取、写入和执行文件.所有其他人都可以读取和执行该文件.此设置适用于所有用户使用的程序.

(rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

700

(rwx------) 文件的所有者可以读取、写入和执行文件.其他人没有任何权利.此设置对于只有所有者才能使用且必须对其他人保密的程序很有用.

(rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

666

(rw-rw-rw-) 所有用户都可以读写文件.

(rw-rw-rw-) All users may read and write the file.

644

(rw-r--r--) 所有者可以读写文件,而其他所有人只能读取文件.每个人都可以阅读但只有所有者可以更改的数据文件的通用设置.

(rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

600

(rw-------) 所有者可以读写文件.所有其他人都没有权利.所有者希望保密的数据文件的通用设置.

(rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.

目录权限

chmod 命令也可以用来控制目录的访问权限.在大多数情况下,目录的权限方案的工作方式与它们对文件的工作方式相同.但是,执行权限的使用方式不同.它提供对文件列表和其他内容的访问控制.以下是一些有用的目录设置:

The chmod command can also be used to control the access permissions for directories. In most ways, the permissions scheme for directories works the same way as they do with files. However, the execution permission is used in a different way. It provides control for access to file listing and other things. Here are some useful settings for directories:

777

(rwxrwxrwx) 没有权限限制.任何人都可以列出文件、在目录中创建新文件和删除目录中的文件.通常不是一个好的设置.

(rwxrwxrwx) No restrictions on permissions. Anybody may list files, create new files in the directory and delete files in the directory. Generally not a good setting.

755

(rwxr-xr-x) 目录所有者拥有完全访问权限.所有其他人可以列出目录,但不能创建文件或删除它们.此设置适用于您希望与其他用户共享的目录.

(rwxr-xr-x) The directory owner has full access. All others may list the directory, but cannot create files nor delete them. This setting is common for directories that you wish to share with other users.

700

(rwx------) 目录所有者具有完全访问权限.其他人没有任何权利.此设置对于只有所有者可以使用且必须对其他人保密的目录很有用.

(rwx------) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.

这篇关于更改文件权限 Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆