Linux chmod command to modify file permissions is forbidden Exit code 126 from SFTP

In the LAMP environment built on the Alibaba Cloud host, when modifying the properties of the related file config.cache.inc.php,
chmod 777 config.cache.inc.php
chmod: changing permissions of `config.cache.inc.php': Operation not permitted

But after reporting an error above

, after a lot of trouble, I finally found out that chattr can be used to lift this restriction

. First, check the attribute
lsattr config.cache.inc.php
----i-------- config. cache.inc.php
 
Then remove the i attribute
chattr -i config.cache.inc.php

After this step, you can use chmod to modify the file attributes
 
 
 
 
 
 
 
 
 
 

I want to delete a file, but it prompts that the operation has no permission and is rejected.

 

[root@vmlin0342 php]# chmod -R u+w labs/config/conf

chmod: changing permissions of `labs/config/conf/redis.ini': Operation not permitted
chmod: changing permissions of `labs/config/conf/mysql.ini': Operation not permitted

chmod: changing permissions of `labs/config/conf/zookeeper.ini': Operation not permitted

After searching, I found that chattr can modify the attributes of the file.

 

[root@vmlin0342 php]# chattr -i labs/config/conf/
[root@vmlin0342 php]# lsattr labs/config/conf/
----i-------- labs/config/conf/redis.ini
----i-------- labs/config/conf/mysql.ini
----i-------- labs/config/conf/zookeeper.ini

This will allow you to modify the file.

[root@vmlin0342 php]# chattr -R -i labs/config/conf/
[root@vmlin0342 php]# 
[root@vmlin0342 php]# lsattr labs/config/conf/
------------- labs/config/conf/redis.ini
------------- labs/config/conf/mysql.ini
------------- labs/config/conf/zookeeper.ini
[root@vmlin0342 php]# chmod -R 777 labs/config/conf/
[root@vmlin0342 php]# rm -rf labs
[root@vmlin0342 php]# ls -al
total 8
drwxr-xr-x 2 root root 4096 Apr 21 11:34 .
drwxr-xr-x 6 root root 4096 Apr 21 11:26 ..

 

至此,文件属性被修改,文件也已经被删除

 

 

 

Exit code 126 from SFTP

$ /dev/null
-bash: /dev/null: Permission denied
$ echo $?
126
-rwxr-xr-x 1 root root 63552 Apr 11  2013 /path/to/sftp-server

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326195233&siteId=291194637