Linux Ubuntu 上的只读文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12404922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:20:48  来源:igfitidea点击:

read-only files on Ubuntu

linuxubuntu

提问by petwho

when trying to delete file, I got the rm command on ubuntu page at https://help.ubuntu.com/community/DeletingFiles. And on, this page I got the term read-onlyfiles. I have tried to google read-only file linux, but cannot find any definition about this. Could you tell me what read-only mean? Does it mean all owner, group and other have only read permission? Thank you!

尝试删除文件时,我在https://help.ubuntu.com/community/DeletingFiles 的ubuntu 页面上收到了 rm 命令。在这个页面上,我得到了术语只读文件。我试图谷歌只读文件 linux,但找不到任何关于此的定义。你能告诉我只读是什么意思吗?这是否意味着所有所有者、组和其他人都只有读取权限?谢谢!

采纳答案by RuntimeException

Does it mean all owner, group and other have only read permission?

这是否意味着所有所有者、组和其他人都只有读取权限?

They may have different permissions. But you (the current user) have only read permission.

他们可能有不同的权限。但是您(当前用户)只有读取权限。

回答by Se?kin Sava???

A read-only file is a file that you don't have permission to alter its content. To see detailed info about your permissions use ls -l; if you want to change the permissions, use chmod. Also see this examplefor better understanding.

只读文件是您无权更改其内容的文件。要查看有关您的权限的详细信息,请使用ls -l;如果要更改权限,请使用chmod. 另请参阅此示例以更好地理解。

回答by CloudyMarble

Change the Permissions with chmodor try with sudu:

chmod使用 sudu更改权限或尝试使用:

sudo rm file.xxx

sudo rm file.xxx

回答by Zagorax

Linux has three kind of permission for user, group and others.

Linux 有用户、组和其他三种权限。

  1. r: read permission
  2. w: write permission
  3. x: execute permission
  1. r: 读取权限
  2. w: 写权限
  3. x: 执行权限

If the file is read-only, it means you (the user) don't have the wpermission on it and so you cannot delete the file.

如果该文件是只读的,则意味着您(用户)对其没有w权限,因此您无法删除该文件。

Use:

用:

chmod +w FILE

chmod +w FILE

To add that permission. You can change files permission only if you're the owner of the file.

添加该权限。只有当您是文件的所有者时,您才能更改文件权限。

Otherwise, you can remove the file using sudo, gaining super user privilege.

否则,您可以使用 删除文件sudo,获得超级用户权限。

sudo rm FILE

sudo rm FILE

It will prompt you for a password and it will works only if you're in the /etc/sudoers/file (and you're likely to be there if you're the only user, since you're using Ubuntu).

它会提示你输入密码,并且只有当你在/etc/sudoers/文件中时它才会工作(如果你是唯一的用户,你很可能在那里,因为你使用的是 Ubuntu)。