I'm following a guide for installing tomcat on ubuntu, and I'm stuck on a step which is to run the following command:

sudo chmod g+r conf/*

What does the /* mean? Does it mean make the change for all files in the /conf folder? When I run the command, I get the following error:

chmod: cannot access 'conf/*': No such file or directory

This is what the folder looks like:

bin  conf  lib  LICENSE  logs  ...

So the /conf folder is in there - other commands I run on the folder work ok:

sudo chgrp -R tomcat conf
sudo chmod g+rwx conf

The guide is here.

I'm at "Step 4: Update Permissions".

Here is an ls -la of the /opt/tomcat folder:

drwxr-xr-x 9 root root    4096 Aug 15 03:15 .
drwxr-xr-x 3 root root    4096 Aug 15 03:14 ..
drwxr-x--- 2 root root    4096 Aug 15 03:15 bin
drwxrwx--- 2 root tomcat  4096 Jul  6 08:45 conf
drwxr-x--- 2 root root    4096 Aug 15 03:15 lib
-rw-r----- 1 root root   57092 Jul  6 08:45 LICENSE
drwxr-x--- 2 root root    4096 Jul  6 08:43 logs
-rw-r----- 1 root root    1723 Jul  6 08:45 NOTICE
-rw-r----- 1 root root    7063 Jul  6 08:45 RELEASE-NOTES
-rw-r----- 1 root root   15946 Jul  6 08:45 RUNNING.txt
drwxr-x--- 2 root root    4096 Aug 15 03:15 temp
drwxr-x--- 7 root root    4096 Jul  6 08:44 webapps
drwxr-x--- 2 root root    4096 Jul  6 08:43 work

and these are the files that are in the /conf folder:

sudo ls -al conf/
-rw------- 1 root tomcat  12502 Jul  6 08:45 catalina.policy
-rw------- 1 root tomcat   7203 Jul  6 08:45 catalina.properties
-rw------- 1 root tomcat   1338 Jul  6 08:45 context.xml
-rw------- 1 root tomcat   1149 Jul  6 08:45 jaspic-providers.xml
-rw------- 1 root tomcat   2358 Jul  6 08:45 jaspic-providers.xsd
-rw------- 1 root tomcat   3622 Jul  6 08:45 logging.properties
-rw------- 1 root tomcat   7283 Jul  6 08:45 server.xml
-rw------- 1 root tomcat   2164 Jul  6 08:45 tomcat-users.xml
-rw------- 1 root tomcat   2633 Jul  6 08:45 tomcat-users.xsd
-rw------- 1 root tomcat 168577 Jul  6 08:45 web.xml
  • Could you provide a link to the guide you are using? Also could you do an ls -la on the directory rather than just an ls – pcnate Aug 15 '16 at 3:31
  • how about sudo chmod g+r ./conf/* or sudo chmod -R g+r ./conf ? if those don't work, confirm your pwd. – Frank Thomas Aug 15 '16 at 4:15
  • @Frank Thomas the [sudo chmod -R g+r ./conf] option worked - do you know why that might be? – user3203425 Aug 15 '16 at 4:24

I suspect you are not in the tomcat group while running the commands. The problem here is that the * glob is going to be expanded by your shell before executing sudo so it will be expanding it as your current user. If that user is not in the tomcat directory it has no permission to list the files in conf, and so the glob fails to expand, which usually means you get the string back unchanged, then you try the sudo command, but glob expansion is already done, so it is looking for a file literally named conf/* which clearly does not exist.

So you could either use a user who has permission in that directory, or you could have sudo run a command that will defer the glob expansion like

sudo sh -c "chmod g+r conf/*"

so the glob will be expanded after sudo has given you elevated permissions

To answer your question of "what does it mean," as I mentioned above the * is a glob character for shells. You can read a lot about it here. It's a way to match lots of files without having to specifically enumerate them by hand. You just specify patterns that will match the names you want, and * basically means "pretty much anything any number of times"

Since order of operations seems to be important to this question, here is a page that talks about the order in which different expansions happen in the shell (at least bash but most are similar). All that happens before the command is executed, so it all happens before sudo is invoked in this specific situation.

| improve this answer | |
  • Oh I see - yeah when I run the "groups" command, I only get back "testuser sudo" (testuser is my original group). So this user is not part of group "tomcat". Your recommended workaround command works, even though I am not part of the group. I added my user to the tomcat group afterwards as a test, and then the original command finally works, glorious! – user3203425 Aug 15 '16 at 12:56
  • Shell expansion is the key. I didn't know in the past that when we put * , it is actually shell that finds every matching item and virtually adds it to argument list. – sdkks Aug 15 '16 at 13:29

To add to what @Eric Renoufs answer you can give shell access to tomcat8 user by using this command

$ sudo -s -u <tomcat user> then issue
$ chmod g+r conf/*

This link directed me to this answer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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