1

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
  • 113

2 Answers2

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.

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
  • 121