我正在尝试更改我的.bash_profile
并将其吐回
错误写入.bash_profile权限被拒绝
所以,我使用chattr -i .bash_profile
使它成为不可变的,它给了我
-bash:chattr:找不到命令。
有人可以帮我解决这个问题吗?
答案 0 :(得分:3)
为什么从该消息中假设该文件是“不可变的”并且需要您执行chattr -i
?
你没有提供足够的信息来说明问题是什么,但我的第一个想法是1)文件不属于你(也许是在sued或sudo'ed时创建的),或2)权限不允许您写入文件。
如果您确实是所有者(或者可以chown
让自己成为拥有者,假设合适)尝试对其进行chmod u+w
。
答案 1 :(得分:2)
这将安装chattr
:apt-get install e2fsprogs
答案 2 :(得分:1)
如果你使用Ubuntu或Debian,你可以使用
apt-get install e2fsprogs
然后再试一次。
答案 3 :(得分:0)
“Permission denied” - 错误可能是因为您在传统的UNIX权限模型下没有足够的权限。
Immutability(以及此特定文件属性系统)是Linux特有的。 Chattr不包含在coreutils中,因此您可能需要单独安装它(如何执行此操作取决于您的Linux发行版)。
此外,chattr -i
将删除不变性标志,而不是设置它。
答案 4 :(得分:0)
Okay I am not sure if this will help since the question of what OS was being used was not answered but I encountered a similar issue working within FreeBSD where the Man Pages seem to imply that FreeBSD supports chattr as well as lsattr however when you try to use either one you get the "command not found" error which makes it a bit confusing.
Still after some extensive digging I found the following and this may solve this problem as well or if not at least perhaps point someone in the right direction
FreeBSD offers write protection by using the special bit called Immutable to turn this on you do the following command:
$ chflags schg filename
To test to see if this flag is set you do the following command:
$ ls -lo filename
Which gets you the following results:
-r--r--r-- 1 root wheel schwa 12 Nov 16 15:36 filename
To clear or remove the file Immutable bit you do the following:
$ chflags noschg filename
Now the file can be deleted
Note: This Immutable flag can only be set by the root user.
Further chflags supports a few other interesting flags:
Note: Putting a "no" before an option causes the flag to be turned off
So if you do not have access to chattr and lsattr then perhaps it is because they use this methodology to do the same thing.
P.S. If a file has been made Immutable or Append-Only it cannot be deleted until that attribute of the file has been changed. Not sure about any of the other settings but that was the information stated about these two.