Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a file on my HDD,

cd /media/celebisait/5AC69788C6976355

There is my file called myFile.tar.gz. I do als -l,

-rw------- 2 celebisait celebisait  1387745311 Jun  6  2013 myFile.tar.gz

Everything seems fine. However, when I do,

$ sudo chmod 755 myFile.tar.gz

I do not have any errors but nothing happens, i.e., when I do ls -l again, I get the same output,

-rw------- 2 celebisait celebisait  1387745311 Jun  6  2013 myFile.tar.gz

Chmod does not change.. Why?

PS: I use Ubuntu 13.04.

Edit:

$ cd /media/celebisait/5AC69788C6976355
$ df

Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda2       89873576  42976028  42325544  51% /
none                   4         0         4   0% /sys/fs/cgroup
udev            16436736         4  16436732   1% /dev
tmpfs            3289260       920   3288340   1% /run
none                5120         0      5120   0% /run/lock
none            16446280       764  16445516   1% /run/shm
none              102400        52    102348   1% /run/user
/dev/sda1          94759      2208     92551   3% /boot/efi
/dev/sdb1      767999996 541212516 226787480  71% /media/celebisait/5AC69788C6976355
/dev/sdb2      767999996   1466472 766533524   1% /media/celebisait/54D09DBDD09DA5B0

Edit 2:

$ cd /media/celebisait/5AC69788C6976355
$ mount

/dev/sda2 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /sys/firmware/efi/efivars type efivarfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
/dev/sda1 on /boot/efi type vfat (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfsd-fuse on /run/user/celebisait/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=celebisait)
/dev/sdb1 on /media/celebisait/5AC69788C6976355 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)
/dev/sdb2 on /media/celebisait/54D09DBDD09DA5B0 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)

Edit 3:

$ sudo fdisk -l /dev/sdb1

Disk /dev/sdb1: 786.4 GB, 786432000000 bytes
255 heads, 63 sectors/track, 95611 cylinders, total 1536000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x6e697373

This doesn't look like a partition table
Probably you selected the wrong device.

     Device Boot      Start         End      Blocks   Id  System
/dev/sdb1p1   ?  1936269394  3772285809   918008208   4f  QNX4.x 3rd part
Partition 1 does not start on physical sector boundary.
/dev/sdb1p2   ?  1917848077  2462285169   272218546+  73  Unknown
Partition 2 does not start on physical sector boundary.
/dev/sdb1p3   ?  1818575915  2362751050   272087568   2b  Unknown
Partition 3 does not start on physical sector boundary.
/dev/sdb1p4   ?  2844524554  2844579527       27487   61  SpeedStor
Partition 4 does not start on physical sector boundary.

Partition table entries are not in disk order

Edit 4:

$ sudo fdisk -l /dev/sdb

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x9c73d093

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  1536002047   768000000    7  HPFS/NTFS/exFAT
/dev/sdb2      1536002048  3072002047   768000000    7  HPFS/NTFS/exFAT
/dev/sdb3      3072002048  3907026943   417512448    7  HPFS/NTFS/exFAT
share|improve this question
    
what is the file system of that external drive? df command result would be nice –  Kiwy Jan 21 at 14:21
    
You don't need sudo if you own the file and directory, depending on the way it's been mounted (read only ? rootsquash ?) of maybe it's a cd or write protected usb stick ? –  X Tian Jan 21 at 14:29
    
@Kiwy I added the output of df. –  celebisait Jan 21 at 14:46
    
@Braiam How to mount? –  celebisait Jan 21 at 14:46
    
post the output of blkid. –  Avinash Raj Jan 21 at 14:47
show 6 more comments

5 Answers

up vote 10 down vote accepted

TL;DR;

NOTE: Based on the continuous updating of the question by the OP with new information it was determined that the issue was he was mounting a NTFS partition. So #3 below is the actual answer to his problem. I leave the other 2 methods here for others that may encounter similar issues that aren't using an NTFS partition.


Idea #1 - media's readonly (ISO/CD/DVD)?

Take a look at the output of the mount command, specifically something like this:

$ mount | grep '/media'

The device that's mounted under /media/celebisait is likely either an ISO file or a CD/DVD media. In which case you won't be able to gain write access to, since these are typically read only.

You can tell what's mounted read/write vs. readonly by again turning to the mount command's output.

Example

/dev/mapper/fedora_greeneggs-root on / type ext4 (rw,relatime,seclabel,data=ordered)

Notice the output in the parenthesis. The first argument before the first comma is rw which denotes read/write access. If it were a readonly device it would have a ro there instead.

Alternative method

You can also find out what device a particular location on your HDD is sourced from by using the df -h . command. This will show you the current directory's source device.

$ df -h .
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/fedora_greeneggs-home  402G  156G  226G  41% /home

Here we can see that I'm in a directory/subdirectory that's part of the mount /home, which is backed by the device /dev/mapper/fedora_greeneggs-home.

With the device's name you could then look for that as well in the output of mount.

Example

$ mount | grep '/dev/mapper/fedora_greeneggs-home'
/dev/mapper/fedora_greeneggs-home on /home type ext4 (rw,relatime,seclabel,data=ordered)

Idea #2 - But the device is mounted read/write!

If you find that your device is mounted read/write you might want to try installing PySDM - a Storage Device Manager that allows full customization of hard disk mountpoints without manual access to /etc/fstab. It also allows the creation of udev rules for dynamic configuration of storage devices

steps to read/write

  1. install physical storage device manager: sudo apt-get install pysdm
  2. open storage device manger: sudo pysdm
  3. choose your required drives
  4. press assist
  5. uncheck open as read only
  6. check owner user of file system and write your username: celebisait
  7. press ok
  8. press apply
  9. umount Drive
  10. mount it

Source: How can I change permissions on external drives?

Idea #3 - NTFS partitions

Based on the output you posted for the command:

$ sudo fdisk -l /dev/sdb

...
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  1536002047   768000000    7  HPFS/NTFS/exFAT

You have NTFS partitions, which explains why you weren't able to chmod the files on the NTFS mounted partition(s). If you're using the ntfs-3g module to access the NTFS partition you should be able to read/write the disk, just not affect its permissions using the normal Unix suite of tools.

share|improve this answer
2  
i think celebisait is his username. –  Avinash Raj Jan 21 at 14:58
    
@AvinashRaj, yes it is true. :) –  celebisait Jan 21 at 15:04
    
I don't think Idea #1 matches the information originally given - trying to chmod a file on a read-only filesystem should result in an error (EROFS). And I'm kind of confused as to what Idea #2 actually accomplishes. It looks like a fancy way of remounting the filesystem read/write - but you say this applies to the case that the filesystem is already read-write. –  Nate Eldredge Jan 22 at 4:04
    
@NateEldredge - It was very unclear what exactly was going on in the beginning of this Q, hence my 1st suggestion was to establish how the device was mounted. My 2nd method I've used personally to fix permissions on my USB MP3 player that occasionally shows up in Nautilus as readonly. Files show up similar to how the OP describes, and I use PySDM to resolve the problem. The issue is not merely the FS being mounted as RO, the partition on the MP3 player is put into a readonly mode, and yet it's mounted RW. –  slm Jan 22 at 4:13
add comment

As you are mentionning a HDD.
My answer is that it's not possible to chmod a file on a NTFS or FAT32 partition.
In fact only unix/linux file system like ext3,ext4 support those attributes.

/dev/sdb1            2048  1536002047   768000000    7  HPFS/NTFS/exFAT

It clearly shows that /dev/sdb1 was a NTFS partition.

share|improve this answer
1  
how do you know it's NTFS ? it is probably but youcan't assume that from the question –  Kiwy Jan 21 at 14:32
    
@Kiwy this is actually more likely to be the case than the other answer since the OP mentions a HDD. –  Joseph R. Jan 21 at 14:41
add comment
/dev/sdb1            2048  1536002047   768000000    7  HPFS/NTFS/exFAT

/dev/sdb1 on /media/celebisait/5AC69788C6976355 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)

The type fuseblk and the output of fdisk indicates that your partition is an NTFS partition. These doesn't support UNIX/LINUX file permissions scheme as other *NIX native filesystems.

The solution is just moving the file to a filesystem that supports these permissions like your root. The way you want to do it will simply not work.

cp /media/celebisait/5AC69788C6976355/myFile.tar.gz ~/
chmod 755 ~/myFile.tar.gz
ls -l ~/myFile.tar.gz
share|improve this answer
add comment

I had a similar problem with an NTFS partition recently. It has already been stated that NTFS can't have permissions changed, but these permissions can be set on mounting the file system. Given the ids of the groups or users you want to be able to access the files, you could do something like:

sudo mount -t ntfs -o gid=46,fmask=0003,dmask=0002 /dev/sdb1 /media/DATAPART1

mount man page so you can tailor it to your use case:

http://linux.die.net/man/8/mount

share|improve this answer
add comment

The directory is probably read-only. Try this:

ls -ld .
chmod 755 .
chmod 755 myFile.tar.gz
share|improve this answer
    
This is not correct. On an ordinary Unix filesystem, it works fine to chmod a file in a read-only directory. You don't need write permissions on a directory to read, write, or change metadata of a file in that directory. You do need write permission to create new files or delete existing ones. –  Nate Eldredge Jan 22 at 4:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.