Ownership remains unchanged after `sudo chown` in ubuntu

0

sudo chown reports that it has changed ownership but stat shows that they remain unchanged. I have absolutely no clue as to what might be causing this behavior. Commands and their output are listed below:

iceberg@iceberg-Vostro-3446:/media/iceberg/Data3/Open_Source_Projects/container$ stat ./logs/mysql/tomcat/error.log
  File: './logs/mysql/tomcat/error.log'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d  Inode: 397758      Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/ iceberg)   Gid: ( 1000/ iceberg)
Access: 2017-08-03 21:53:37.845481100 +0530
Modify: 2017-08-03 21:53:37.845481100 +0530
Change: 2017-08-03 21:53:37.845481100 +0530
 Birth: -
iceberg@iceberg-Vostro-3446:/media/iceberg/Data3/Open_Source_Projects/container$ sudo chown -vR 999:999 ./logs/mysql/tomcat/error.log
[sudo] password for iceberg: 
changed ownership of './logs/mysql/tomcat/error.log' from iceberg:iceberg to 999:999
iceberg@iceberg-Vostro-3446:/media/iceberg/Data3/Open_Source_Projects/container$ stat ./logs/mysql/tomcat/error.log
  File: './logs/mysql/tomcat/error.log'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d  Inode: 397758      Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/ iceberg)   Gid: ( 1000/ iceberg)
Access: 2017-08-03 21:53:37.845481100 +0530
Modify: 2017-08-03 21:53:37.845481100 +0530
Change: 2017-08-03 21:53:37.845481100 +0530
 Birth: -

Edit 1: Updated information related to file locations.

Edit 2: The filesystem being used is NTFS. Windows partition is mounted inside ubuntu.

Ayushya

Posted 2017-08-03T16:44:45.897

Reputation: 103

What kind of filesystem is this file stored on? – duskwuff -inactive- – 2017-08-03T17:32:39.317

I am using zsh, maybe that might look confusing, I'll update the question with bash syntax, which is probably more popular and widely used. – Ayushya – 2017-08-03T18:02:53.567

No -- I mean the filesystem, not your shell. Is this directory mounted over FUSE or something else weird? Is it on a non-Linux filesystem like NTFS or FAT32? – duskwuff -inactive- – 2017-08-03T18:04:02.890

@duskwuff It is stored in a local filesystem, mounted in my media volumes. – Ayushya – 2017-08-03T18:04:11.870

Usually chown doesn't produce any kind of output... which makes me suspicious about the chown command you're actually using. Try running which chown, and see what kind of file it is (the official one should be a binary). If it's a script, it's possibly a wrapper doing who knows what else. – nKn – 2017-08-03T18:08:04.790

-v option of chown is used for --verbose and is responsible for output. -c option is used to report any changes that are made by chown Running which chown results in /bin/chown and cat /bin/chown showed some illegible output, I think it is a binary – Ayushya – 2017-08-03T18:10:33.967

@duskwuff it is NTFS filesystem. The windows filesystem is mounted in ubuntu – Ayushya – 2017-08-03T19:27:04.490

Answers

1

In comments, you mentioned that the filesystem is NTFS.

This is the source of your problem. The filesystem was mounted as the user iceberg, and all of its files are represented as being owned by that user.

To change this, you will probably need to either:

  • Mount the filesystem as root, using different options so that file ownership from NTFS is respected. You may need to fix the ownership of other files after making this change.

  • Mount the filesystem as user 999. This will make all of its files owned by that user, which may or may not be what you want.

  • Change the permissions (not ownership) on that file to allow it to be written to by user 999.

  • Store these files on a disk with a native Linux filesystem, instead of storing them on an NTFS drive.

duskwuff -inactive-

Posted 2017-08-03T16:44:45.897

Reputation: 3 824

0

Since your output mention "container", I assume you are using docker...

Are you sure this file is in your docker itself? This can happend if the file come from a mounted directory from outside the docker.

Could you check the file from the host?

# stat /var/lib/docker/aufs/diff/<container id>/<path in container>/logs/mysql/tomcat/error.log

If you don't see the file here, it's from outside of the docker image.

Or it could also be the file comming from an upper aufs layer. Try to rm it and create (touch) a new file, then chown it.

Elektordi

Posted 2017-08-03T16:44:45.897

Reputation: 111

Its not in the docker volumes. The file I am trying to chown is in media volume. – Ayushya – 2017-08-03T18:04:52.173