0

I've created a directory as root, but when I try to change ownership if it, it won't change! I have no idea why. (I've snipped the results of ls -halg for brevity, in case you're wondering why some files are missing...)

root@localhost:/opt/tomcat/conf# mkdir Catalina
root@localhost:/opt/tomcat/conf# ls -halg
total 244K
drwxr-x--- 3 tomcat 4.0K May 12 17:09 .
drwxr-xr-x 9 tomcat 4.0K May 10 02:34 ..
drwxr-xr-x 2 root   4.0K May 12 17:09 Catalina
-rw-r----- 1 tomcat  13K May 12 15:32 catalina.policy
-rw-r----- 1 tomcat 7.1K Mar 30 10:29 catalina.properties
root@localhost:/opt/tomcat/conf# chown tomcat Catalina
root@localhost:/opt/tomcat/conf# ls -halg
total 244K
drwxr-x--- 3 tomcat 4.0K May 12 17:09 .
drwxr-xr-x 9 tomcat 4.0K May 10 02:34 ..
drwxr-xr-x 2 root   4.0K May 12 17:09 Catalina
-rw-r----- 1 tomcat  13K May 12 15:32 catalina.policy
-rw-r----- 1 tomcat 7.1K Mar 30 10:29 catalina.properties
root@localhost:/opt/tomcat/conf#

When I made the tomcat directory yesterday, it was happy to chown -R /opt/tomcat everything to the tomcat user like it should. I'm really at a loss at why such a simple command fails.

corsiKa
  • 363
  • 1
  • 6
  • 18
  • 4
    You change the *user* but your command displays only the *group*. Just try again with a simple `ls -l`. – A.B May 12 '21 at 20:32
  • You can also verify with: `stat Catalina`. @A.B feel free to submit that as an answer. – Aaron Copley May 13 '21 at 00:43
  • Use this command ls -lrt and share the output with us. – asmath May 16 '21 at 15:28
  • Sorry, I had some things come up and this sort of sat in the background for a while - @A.B 's suggestion did show properly - if that was an answer instead of a comment it would have a checkmark by now – corsiKa May 17 '21 at 16:23

1 Answers1

2

On the one hand:

chown with a simple user parameter, not including the separator : (or obsolete .) changes the user ownership of further given file(s) and leaves the group ownership of the file(s) unchanged.

On the other hand:

ls -halg displays only the group ownership of a file in its output because of the included option -g.

Thus changing only the user, which worked (no error was displayed) didn't change the result of ls -halg. ls -hal should have been used here to see the change.

A.B
  • 9,037
  • 2
  • 19
  • 37