not able to change file permission in linux

Jeet picture Jeet · Oct 21, 2014 · Viewed 7k times · Source

This seems a very basic question but I am not able to change the file permission in 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. 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

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

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: 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

Answer

Jeet picture Jeet · Oct 29, 2014

ntfs partition does not support the linux file permissions. 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. Suppose you mentioned 0022, it means the file will get created with 755 and same for folder as well. Rest 2 fields are "/dev/sda6" is my device which is mounted on a folder named "/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).

Please correct if anything wrong.

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