7

分享一个Linux无法创建文件夹,但是目录权限却显示正常的问题和解决

 3 years ago
source link: https://zhang.ge/201.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

分享一个Linux无法创建文件夹,但是目录权限却显示正常的问题和解决

Jager · 12月19日 · 2013年linux · linux安全设置 · 运维 6041次已读

今天发现一个疑难杂症:发现批量发布一个新版本程序时,发现有一台没有成功。亲自登陆上去看了下,发现原来是发布帐号在某个目录下创建目录失败了!

人工 touch 试了下,发现提示没有权限。

然后 ls -l 看了下,发现一切正常:

[[email protected]:/data/TNM2/release]# ll
36240
-rw-r--r-- 1 publish users 56 2013-12-29 18:44 release_status
drwxr-xr-x 41 publish users 4096 2013-12-29 18:44 backup
drwxr-xr-x 2 publish users 4096 2013-12-29 16:47 server
-rwxr-xr-x 1 publish users 1746 2013-12-29 15:41 release-server.sh

奇了怪了啊,于是看下上层目录是否有权限,结果发现从/ 到 release 权限都是正常的!

最终,灵机一动,这个帐号是否可能是被删除过,后面又添加的呢???

先使用id 看了下这个用户信息:

[[email protected]:/data/TNM2/release]# id publish
uid=1000(publish) gid=100(users) groups=100(users)

然后,对没有权限的目录使用 ls -nd /data/TNM2/release

drwxr-xr-x 4 998 100 4096 2015-08-27 18:43 /data/TNM2/release/

果然啊!这UID都对不上,如果不看UID还真不知道是什么原因呢!

既然知道怎么回事了,那就简单了。

使用 chmod 重新授权即可:chmod -R publish:users /data/TNM2/release

Ps:没有权限新建文件或修改文件其实还有其他一些因素,比如比较隐秘的“加锁”命令:chattr

感兴趣的可以看下:

Linux下巧用chattr、watch命令的实


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK