简体   繁体   English

无法在linux中更改文件权限

[英]not able to change file permission in linux

This seems a very basic question but I am not able to change the file permission in linux.这似乎是一个非常基本的问题,但我无法更改 linux 中的文件权限。

I am a root user, I can change the file permission if I copy the same file in the Filesystem of the installed linux.我是 root 用户,如果我在已安装的 linux 的文件系统中复制相同的文件,我可以更改文件权限。 I can't change the permissions to files/ folder which are kept on the other partition.我无法更改保存在另一个分区上的文件/文件夹的权限。

Please give me a term to at-least how to start debugging, I don't see any errors as well.请给我一个至少如何开始调试的术语,我也没有看到任何错误。 There is no sticky bits set.没有设置粘滞位。 Help me by giving steps which I can follow to debug this issue.通过提供我可以用来调试此问题的步骤来帮助我。

This is the output of df -h这是 df -h 的输出

Filesystem                                              Size  Used Avail Use% Mounted on
rootfs                                                   46G   22G   22G  50% /
udev                                                     10M     0   10M   0% /dev
tmpfs                                                   393M  1.9M  391M   1% /run
/dev/disk/by-uuid/49c0f59c-9bb3-4755-8c1f-06da6159865e   46G   22G   22G  50% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   786M  944K  785M   1% /run/shm
/dev/sda2                                                46G   43G  1.3G  98% /home
/dev/sda6                                               278G  122G  157G  44% /media/056AFEAB51156F3F___
/dev/sda3                                                92G   16G   72G  18% /media/3a7cb05d-b822-4f3e-a330-da91013b605c_

Output for ls -al ls -al 的输出

drwx------ 1 prasenjit prasenjit     0 Oct 21 15:08 abi
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 art
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 bionic
drwx------ 1 prasenjit prasenjit     0 Oct 21 15:08 bootable
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 build
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 cts
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 dalvik
drwx------ 1 prasenjit prasenjit     0 Oct 21 15:08 developers
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:08 development
drwx------ 1 prasenjit prasenjit  4096 Oct 21 15:09 device
drwx------ 1 prasenjit prasenjit     0 Oct 21 15:09 docs
drwx------ 1 prasenjit prasenjit 36864 Oct 21 15:17 external

output for lsattr : lsattr 的输出:

lsattr: Inappropriate ioctl for device While reading flags on ./abi
lsattr: Inappropriate ioctl for device While reading flags on ./art
lsattr: Inappropriate ioctl for device While reading flags on ./bionic
lsattr: Inappropriate ioctl for device While reading flags on ./bootable
lsattr: Inappropriate ioctl for device While reading flags on ./build
lsattr: Inappropriate ioctl for device While reading flags on ./cts
lsattr: Inappropriate ioctl for device While reading flags on ./dalvik
lsattr: Inappropriate ioctl for device While reading flags on ./developers
lsattr: Inappropriate ioctl for device While reading flags on ./development
lsattr: Inappropriate ioctl for device While reading flags on ./device
lsattr: Inappropriate ioctl for device While reading flags on ./docs
lsattr: Inappropriate ioctl for device While reading flags on ./external

Output of mount挂载输出

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=210750,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=401948k,mode=755)
/dev/disk/by-uuid/49c0f59c-9bb3-4755-8c1f-06da6159865e on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=803880k)
/dev/sda2 on /home type ext4 (rw,relatime,data=ordered)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda6 on /media/056AFEAB51156F3F___ type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sda3 on /media/3a7cb05d-b822-4f3e-a330-da91013b605c_ type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks)

Let me know other commands which can help me to debug.让我知道可以帮助我调试的其他命令。 Any help is appreciated.任何帮助表示赞赏。

Thanks in advance提前致谢

ntfs partition does not support the linux file permissions. ntfs 分区不支持 linux 文件权限。 So you can not change the permissions.所以你不能改变权限。 Alternatively you can mount the drive with the required permission set.或者,您可以使用所需的权限集挂载驱动器。

Example :例子 :

mount -t ntfs -o rw,auto,user,fmask=0022,dmask=0022 /dev/sda6 /mnt/ntfsDrive/

Here my partition format was ntfs, So I mentioned it, rw is read / write permission, fmask and dmask are default file and Directory permission when you create any file or folder and the existing folders.这里我的分区格式是ntfs,所以我提到了它,rw是读/写权限,fmask和dmask是创建任何文件或文件夹以及现有文件夹时的默认文件和目录权限。 Suppose you mentioned 0022, it means the file will get created with 755 and same for folder as well.假设您提到了 0022,这意味着文件将使用 755 创建,文件夹也相同。 Rest 2 fields are "/dev/sda6" is my device which is mounted on a folder named "/mnt/ntfsDrive/".其余 2 个字段是“/dev/sda6”是我的设备,它安装在名为“/mnt/ntfsDrive/”的文件夹中。

You still won't be able to change the file / folder permission and it will be same as you mentioned while mounting the drive (fmask and dmask).您仍然无法更改文件/文件夹权限,并且与您在安装驱动器时提到的相同(fmask 和 dmask)。

Please correct if anything wrong.如有不对请指正。

Please refer : https://askubuntu.com/questions/11840/how-do-i-use-chmod-on-an-ntfs-or-fat32-partition请参考: https : //askubuntu.com/questions/11840/how-do-i-use-chmod-on-an-ntfs-or-fat32-partition

try using the lsattr and chattr commands尝试使用 lsattr 和 chattr 命令

it's possible that for some files/directories the chattr +i file has been performed so unless you undo that it will be impossible to modify them even under root.对于某些文件/目录,可能已经执行了 chattr +i 文件,因此除非您撤消,否则即使在 root 下也无法修改它们。

This is not directly related to the OP's question, but if you ended up here during something related to WSL (Windows Subsystem for Linux) 1 or 2 and the error messages in the question are similar to yours, this question is helpful .这与 OP 的问题没有直接关系,但如果您在与 WSL(Linux 的 Windows 子系统)1 或 2 相关的事情中结束了这里,并且问题中的错误消息与您的类似,则此问题很有帮助

It details the steps needed to disable auto-generation of the resolve.conf (which I was trying to edit after figuring out I had a DNS issue).它详细说明了禁用resolve.conf自动生成所需的步骤(我在发现 DNS 问题后试图编辑)。 I didn't go further than that file, so I don't know what other configs exist for auto-generated files in WSL.我没有比那个文件更进一步,所以我不知道 WSL 中自动生成的文件还有哪些其他配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM